bool SocialGraphFFUCRTripodAdapter::Remove(const std::string& key) {
  if (!tripod_client_) {
    MCE_ERROR("SocialGraphFFUCRTripodAdapter::Remove tripod_client is NULL! ns:" << kSgRcdNamespaceId << "\tbiz:" << kSgRcdBizId);
    return false;
  }
  return tripod_client_->Remove(key);
}
bool SocialGraphFFUCRTripodAdapter::Set(const std::string& key, const std::string& value, int expire_time) {
  if (!tripod_client_) {
    MCE_ERROR("SocialGraphFFUCRTripodAdapter::Set tripod_client is NULL! ns:" << kSgRcdNamespaceId << "\tbiz:" << kSgRcdBizId);
    return false;
  }
  return tripod_client_->Set(key, value, expire_time);
}
bool SocialGraphFFUCRTripodAdapter::Get(const std::string& key, std::string* value) {
  if (!tripod_client_) {
    MCE_ERROR("SocialGraphFFUCRTripodAdapter::Get tripod_client is NULL! ns:" << kSgRcdNamespaceId << "\tbiz:" << kSgRcdBizId);
    return false;
  }
  return tripod_client_->GetAndIgnoreMiss(key, value);
}
示例#4
0
bool CacheManagerI::loadListCache(const std::string& key, const std::string& namespace_id, const std::string& biz_id, bool use_master, const Ice::Current& current) {
  std::ostringstream os;
  os << "key :" << key;
  os << " namespaceId :" << namespace_id;
  os << " businessId :" << biz_id;
  os << " use_master :" << use_master;
  MyUtil::InvokeClient ic = MyUtil::InvokeClient::create(current, os.str(), MyUtil::InvokeClient::INVOKE_LEVEL_INFO);
  ProducerManagerClientPtr producer = getProducer();
  if(!producer) {
    MCE_ERROR("CacheManagerI::loadListCache() getProducer() return NULL!!!");
    return false;
  }

  KeySeq input_keys;
  input_keys.push_back(key);
  KeySeq locked_keys;
  KeySeq failed_locked_keys;
  bool result = false;
  while(true) {
    xce::tempmutext::Locks<std::string> locks(&tempMutexManager_, input_keys, locked_keys, failed_locked_keys);
    if(!locked_keys.empty()) {
      DataMap data;
      try {
        data = producer->produce(locked_keys, biz_id, use_master, 10000);
      } catch (Ice::Exception& e) {
        MCE_ERROR("CacheManagerI::loadListCache() rpc call produce() " << e.what());
      }
      DataMap::const_iterator iter = data.begin();
      for (; iter != data.end(); ++iter) {
        if (!iter->second.empty()) {
          ListOrHashValue list_value;
          list_value.ParseFromArray(iter->second.data(), iter->second.size());
          if (list_value.values_size() > 0) {
            StrList str_list;
            BOOST_FOREACH(const std::string& v, list_value.values()) {
              str_list.push_back(v);
            }
            RedisCacheClientPtr cache = GetRedisCache();
            if (!cache) {
              MCE_ERROR("CacheManagerI::loadListCache() GetRedisCache() return NULL !!!");
              continue;
            }
            result = cache->SetList(key, str_list, namespace_id, biz_id);
          }
        }
      }
std::map<std::string, bool> SocialGraphFFUCRTripodAdapter::MultiGet(const StringListType& keys, StringMapType* values) {
  std::map<std::string, bool> result;
  if (!tripod_client_) {
    MCE_ERROR("SocialGraphFFUCRTripodAdapter::MultiGet tripod_client is NULL! ns:" << kSgRcdNamespaceId << "\tbiz:" << kSgRcdBizId);
    return result;
  }
  result = tripod_client_->MultiGetAndIgnoreMiss(keys, values);
  return result;
}
示例#6
0
// UpdateModel 此处不是增量更新
int ModelUpdater::UpdateModel(long WORKER, long WORKERNUM, long STEP)
{
	char fname[128];
	sprintf(fname, "/data/xce/friendranknew/data/user_models.dat_%ld", WORKER);
	FILE* fp = fopen(fname, "wb");
	if (fp==NULL)
	{
		MCE_ERROR("ModelUpdater::UpdateModel(): "<<strerror(errno)<<": " << fname);
		return -1;
	}
	
	long totalUser = 0;
	long increUser = 0;
	int stepno = 0;
	map<USERID,UserModel> models;

	int usetime[8];
	memset(usetime, 0, 8*sizeof(int));
	time_t time_start = 0, time_end = 0;

	while (true)
	{
		//GetStepInterval(WORKER, WORKERNUM, STEP, stepno++, models);
		GetStepOverall(WORKER, WORKERNUM, STEP, stepno++, models);
		
		if ((increUser=models.size())>0)
		{
			time_start = time(NULL);
			ReadUserInfo(models, usetime);
			SaveModels(models, fp);
			models.clear();
			time_end = time(NULL);

			totalUser += increUser;
			MCE_INFO("0:"<<usetime[0]<<" 1:"<<usetime[1]<<" 2:"<<usetime[2]<<" 3:"<<usetime[3]<<" 4:"<<usetime[4]<<" 5:"<<usetime[5]<<" 6:"<<usetime[6]<<" 7:"<<usetime[7]<<"  | ["<<WORKER<<"] "<<time_end-time_start<<" | "<<increUser<<" / "<<totalUser);
		}

		if (increUser<STEP)
		{
			MCE_INFO("Worker["<<WORKER<<"] read "<<totalUser<<" users totally. byebye.");
			break;
		}
	}
	fclose(fp);
	return 0;
}//