Str2StrMap FeedServerStateBackDoorI::control(const Str2StrSeqMap& data, const Ice::Current& c) {
  MCE_INFO("FeedServerStateBackDoorI --> id: " << id_);
  Str2StrSeqMap::const_iterator i = data.find("setstatus");
  if (i != data.end()) {
    switch (i->second.size()) {
      case 1:
        subscriber_.setStatus(boost::lexical_cast<int>(i->second.at(0)));
        break;
      case 2:
        subscriber_.setStatus(boost::lexical_cast<int>(i->second.at(0)), i->second.at(1));
        break;
    }
    return Str2StrMap();
  }
  i = data.find("getstatus");
  if (i != data.end()) {
    Str2StrMap m;
    int status = -1;
    switch (i->second.size()) {
      case 0:
        status = subscriber_.getStatus();
        m.insert(make_pair<string, string>("status", boost::lexical_cast<string>(status)));
        break;
      case 1:
        status = subscriber_.getStatus(i->second.at(0));
        m.insert(make_pair<string, string>("status", boost::lexical_cast<string>(status)));
        break;
    }
    return m;
  }
  return Str2StrMap();
}
Exemple #2
0
void RestTask::_handle(){
	_timeStamp = time(NULL);
	--_retryCount;
	//handle();
  Str2StrMap paras;
	paras["call_id"] = boost::lexical_cast<string>(time(NULL));
	paras["v"] = "1.0";
	paras["format"] = "xml";
  Str2StrMap tmp = parameters();
  paras.insert(tmp.begin(), tmp.end());
	if(paras.find("api_key") == paras.end()){
    paras["api_key"] = "ffa4add0b30141aa9eb9a8f1af34a8c3";
  }
	paras["sig"] = makeSig(paras);
	if(paras.empty()){
		return;
	}
	string path = "http://api.renren.com/server/restserver.do";

	int userid = boost::lexical_cast<int>(paras["session_key"]);
	try{
		RestMediatorAdapter::instance().restRequest(id(), userid, path, paras);
	}catch(Ice::Exception& e){
		MCE_WARN("RestTask::handle-->RestMediatorAdapter::restRequest-->" << e);
	}
}
Exemple #3
0
/// @brief SearchDataI::add 建立两个倒排索引(postingsHZ和postingsPY) 一个是纯拼音的,一个是非纯拼音的, 
///// 
///// @param result (in) 好友ID->好友名字
void SearchDataI::add(const Str2StrMapSeq& docs,const Str2IntMap& config, int timeout)
{
  unsigned int id=0;
  stores_ = Str2StrMapSeq(0);
  for(Str2StrMapSeq::const_iterator it=docs.begin();it!=docs.end();++it,++id) {
    int total = 0;
    Str2StrMap storeMap;
    for(Str2StrMap::const_iterator itt=it->begin();itt!=it->end();itt++){
      Str2IntMap::const_iterator itC = config.find(itt->first);
      if(itC == config.end()){
        continue;
      } 
      int cfg = itC->second;
      bool pyIndex = isPyIndex(cfg);
      bool hzIndex = isHzIndex(cfg);
      bool store = isStore(cfg);
      if(!store && !pyIndex && !hzIndex)
        continue;
      string word = itt->second;
      vector<string> words;
      splitWord(word,words);
      for(unsigned int i=0;i<words.size();++i) {
        if(words[i].size() == 3)  {
          if(hzIndex) {
            // MCE_INFO("AddTerm " << words[i]);
            hzIndex_.addTerm(words[i],id,total+i);
          }
          if(pyIndex){
            StringSeqPtr ssp = Dictionary::instance().getPinyin(words[i]);
            if (ssp) {
              for(vector<string>::iterator it=ssp->seq_.begin();it!=ssp->seq_.end();++it){
                pyIndex_.addTerm(*it,id,total+i);
                //MCE_INFO("AddPY "<<words[i]<<" : "<<(*it)<<" id: "<<id);
              }
            }
          }
        }else if(words[i].size() == 1)  {
          if(hzIndex)
            hzIndex_.addTerm(words[i],id,total+i);
        }
      }
      if(store){
        storeMap.insert(*itt);
      }
      if(pyIndex || hzIndex)
        total +=words.size()+1;
    }
    stores_.push_back(storeMap);
  }
  outTime_ = time(NULL) + timeout;
}