Пример #1
0
MyUtil::IntSeq StatusCacheManagerI::getStatusIdsFrom(const MyUtil::IntSeq& ids, const Ice::Current& current){
	ostringstream op;
	IntSeq res;
	for( MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it ){
		if( !_status[*it] ){
			res.push_back( *it );
			op << *it << "(0) ";
		}
	}
	MCE_INFO("StatusCacheManagerI::getStatusIdsFrom -> " << op.str()
                << " " << current.con->toString().substr(current.con->toString().find("remote", 25)));
	return res;
}
Пример #2
0
map<string, string> UseImNotifyTask::parameters(){
	map<string, string> paras;

	paras["method"] = "notifications.send";
	paras["session_key"] = boost::lexical_cast<string>(_userid);
	//paras["api_key"] = "ffa4add0b30141aa9eb9a8f1af34a8c3";
	//paras["call_id"] = boost::lexical_cast<string>(time(NULL));
	//paras["v"] = "1.0";
	//paras["format"] = "xml";
  MyUtil::IntSeq ids;
	try{
	 ids = BuddyByOnlineTimeCacheAdapter::instance().getFriendList(_userid, 20);
	}
	catch(Ice::Exception& e){
		MCE_WARN("UseImNotifyTask::parameters-->BuddyByOnlineTimeCacheAdapter::getFriendList-->" << e);
		}
	if(ids.empty()) {
	 return map<string, string>();
	}
	MCE_INFO("UseImNotifyTask::parameters --> " << _userid << " " << ids.size());
	ostringstream buddyids;
	for(size_t i = 0; i < ids.size(); ++i) {
	 //  int c = ids.size() < 10? ids.size(): 10;
	 //  for(size_t i = 0; i < c; ++i) {
	 if(i) {
		 buddyids << ",";
	 }
	 buddyids << ids.at(i);
	}
	paras["to_ids"] = buddyids.str();

	ostringstream msg[3];

	msg[0] << "<xn:name uid=\""<<_userid<<"\" linked=\"true\"/>悄悄安装了<a href=\"http://im.renren.com/desktop.html?answer1\">人人桌面</a>,能定时启动游戏,采摘你的果实,升级更快了!| <a href=\"http://im.renren.com/desktop/ver19/rrsetup.exe?answer1\">赶紧安装不能落后!</a>";
	
	msg[1] << "<xn:name uid=\""<<_userid<<"\" linked=\"true\"/>抢先体验了<a href=\"http://im.renren.com/desktop.html?settime2\">人人桌面</a>,留言提醒、快速回复、好友聊天更快更稳定! | <a href=\"http://im.renren.com/desktop/ver19/rrsetup.exe?settime2\">快来安装吧</a>";
	
	msg[2] << "<xn:name uid=\""<<_userid<<"\" linked=\"true\"/>用<a href=\"http://im.renren.com/desktop.html?onemin3\">人人桌面</a>登录了人人网,TA不开网页,就能一键登录、隐身上线、定时玩游戏! | <a href=\"http://im.renren.com/desktop/ver19/rrsetup.exe?onemin3\">我也要安装</a>";
	
	paras["notification"] = msg[abs(_userid)%3].str();
/*	paras["sig"] = makeSig(paras);


	string path = "http://api.xiaonei.com/server/restserver.do";
	try{
		RestMediatorAdapter::instance().restRequest(id(), _userid, path, paras);
	}catch(Ice::Exception& e){
		MCE_WARN("UseImNotifyTask::handle --> invoke RestMediatorAdapter error" << e);
	}*/
	return paras;
}
Пример #3
0
MyUtil::IntSeq UserStateFilterManagerI::getGuideIdsFrom(const MyUtil::IntSeq& ids, const Ice::Current& current){
	ostringstream op;
	IntSeq res;
	for( MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it ){
		if( _user_state_guide[*it] ){
			res.push_back( *it );
		} else{
			op << *it << " ";
		}
	}
	MCE_INFO("UserStateFilterManagerI::getGuideIdsFrom " << ids.size() << " ids -> res: " << res.size() << " ids. filter: " << op.str()
                << " " << current.con->toString().substr(current.con->toString().find("remote", 25)));
	return res;
}
Пример #4
0
MyUtil::IntSeq IPRecordData::get(int limit){
	IceUtil::Mutex::Lock lock(*this);
	if( limit < 0){
		return _users;
	}
	MyUtil::IntSeq result;
	for( MyUtil::IntSeq::reverse_iterator it = _users.rbegin(); it != _users.rend(); ++it ) {
		if (--limit < 0 ) {
			break;
		}
		result.push_back(*it);
	}
	return result;
}
Пример #5
0
map<int,bool> OfferFriendsUtil::getStateGuideBatch(const MyUtil::IntSeq& ids){
        try {
                return UserStateFilterAdapter::instance().getStateGuideBatch( ids );
        } catch( Ice::Exception e ){
                MCE_WARN("[OfferFriendsUtil::getStateGuideBatch] ids.size()=" << ids.size() << " found Ice::Exception : " << e.what() );
        } catch( ... ){
                MCE_WARN("[OfferFriendsUtil::getStateGuideBatch] ids.size()=" << ids.size() << " found unknown exception" );
        }
	map<int,bool> res;
	for( MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it ){
		res[*it] = false;
	}
	return res;
}
Пример #6
0
void UserCounterI::sort() {
	map<int, int> m;
	for (unsigned int i = 0; i < types.size(); ++i) {
		m.insert(make_pair(types[i], values[i]));
	}
	MyUtil::IntSeq t;
	MyUtil::IntSeq v;
	for (map<int, int>::iterator i = m.begin(); i != m.end(); ++i) {
		t.push_back(i->first);
		v.push_back(i->second);
	}
	types = t;
	values = v;
}
void ReloadTask::handle(){
  MyUtil::IntSeq buddies;
  try {
    buddies = BuddyByIdCacheAdapter::instance().getFriendListAsc( _id, -1 );
  } catch( Ice::Exception e ){
    MCE_WARN("[ReloadTask] id=" << _id << " found Ice::Exception : " << e.what() );
    return;
  } catch( ... ){
    MCE_WARN("[ReloadTask] id=" << _id << " found Ice::Exception" );
    return;
  }
  multimap<int, int> orderFriend;
  try{
    Statement sql;
    sql	<< "SELECT guest, UNIX_TIMESTAMP(time) AS time FROM relation_"
      << (_id % 100)
      << " WHERE host="
      << _id;

    ostringstream pattern;
    pattern << "relation_" << (_id % 100);

    QueryRunner("relation_buddycache", CDbRServer, pattern.str()).query(
        sql, OrderedListHandler( buddies, orderFriend, "time", "guest" ) );
  }catch(std::exception& e){
    MCE_WARN( "[ReloadTask] handle " << _id << " std::exception " << e.what() );
    return;
  }catch(...){
    MCE_WARN( "[ReloadTask] handle " << _id << " unknown exception." );
    return;
  }

  int time_now = (int)time(NULL);
  MyUtil::IntSeq times;
  ostringstream timestr;
  for( MyUtil::IntSeq::iterator itB=buddies.begin(); itB!=buddies.end(); ++itB ){
    times.push_back( time_now );
    timestr << time_now << " ";
  }

  for (multimap<int, int>::reverse_iterator itMap = orderFriend.rbegin(); itMap
      != orderFriend.rend(); ++itMap ){
    buddies.push_back(itMap->second);
    times.push_back(itMap->first);
    timestr << itMap->first << " ";
  }

  BuddyByAddTimeDataNPtr obj = new BuddyByAddTimeDataN;
  buddies.swap(obj->friends);
  times.swap(obj->times);

  MCE_INFO("[ReloadTask] id=" << _id << " friends.size()=" << obj->friends.size() << " times=" << timestr.str() );
  SetDataHelper::instance().invokeDelay(_id,obj,timestr.str());
}
Пример #8
0
Int2SearchCacheResultMap SearchCacheManagerI::getSearchCacheList(const ::MyUtil::IntSeq& userIds, const Ice::Current& ic) {

    struct timeval tvStart;
    struct timeval tvStart1;
    struct timeval tvEnd;
	MyUtil::LongSeq uids;

    gettimeofday(&tvStart, NULL);

	Int2SearchCacheResultMap result;
	for (MyUtil::IntSeq::const_iterator it = userIds.begin(); it!= userIds.end(); ++it) {
        BinStringPtr binStrPtr = ObjectCacheHelper::instance().findObject<BinStringPtr> (*it);
		if (binStrPtr.get() != NULL) {
            SearchMemCacheDataPtr pSCData = new SearchMemCacheData();
            char* pBuf = NULL;
            int len = 0;
            binStrPtr->getBuf(&pBuf, &len);

            if (pBuf==NULL || len <= 0) continue;

            if (pSCData->Unserialize(pBuf, len)) {
                result[*it] = pSCData->getProperties();
            }
		} else {
            //scq
            if (*it != 0) {
                uids.push_back(*it);
            }
		}
	}

    gettimeofday(&tvStart1, NULL);

    if (!uids.empty())
        _invokeLoad.invoke(uids);

    gettimeofday(&tvEnd, NULL);
    int start = tvStart.tv_sec*1000000 + tvStart.tv_usec;
    int start1 = tvStart1.tv_sec*1000000 + tvStart1.tv_usec;
    int end = tvEnd.tv_sec*1000000 + tvEnd.tv_usec;
    if ((end - start) > 5000) {
        const Ice::ConnectionPtr con = ic.con;
        if (con.get() != NULL) {
            MCE_INFO(con->toString() << " Get SearchCache List: time=" << end-start << "us " << 
                     "invokeLoad: time=" << end - start1 << "us total=" << userIds.size());
        }
    }
	return result;
}
Пример #9
0
PageEntryList PageFansManagerI::getFansByUserIds(::Ice::Int pageId,const MyUtil::IntSeq&  userIds,
                        const Ice::Current& current){
		MCE_INFO("PageFansManagerI::getFansByUserIds: pageId" << pageId << " iDs.size " << userIds.size());
  		PageFansObjIPtr obj = locatePageFans(pageId);
		PageEntryList list =  obj->realfans;
		PageEntryList result ;
	    for(MyUtil::IntSeq::const_iterator it=userIds.begin();it!=userIds.end();it++)
		{
			PageEntryPtr pe = obj->getFan(*it);
			if(pe)
				result.push_back(pe);
		}	
        MCE_INFO("PageFansManagerI::getFansByUserIds result.size " << result.size() );
		return result;
}
Пример #10
0
void xce::distcache::userapicache::DistUserApiCacheReloaderI::reload(const MyUtil::IntSeq& ids, const Ice::Current& current) {
  ostringstream oss;
  oss << "DistUserApiCacheReloaderI::reload -> size: "<<ids.size()<< " " << current.con->toString().substr(current.con->toString().find("remote",25));
  MyUtil::TimeCost tc = MyUtil::TimeCost::create(oss.str(), MyUtil::TimeCost::LOG_LEVEL_INFO);
  oss<<"ids = ";
  MyUtil::IntSeq tempids;
  for (MyUtil::IntSeq::const_iterator i=ids.begin(); i!=ids.end();++i){
    if (*i > 0) {
      tempids.push_back(*i);
      oss<<*i<<" ";
    }
  }
  MCE_DEBUG(oss.str());
  MyUtil::TaskManager::instance().execute(new ReloadTask(tempids));
}
Пример #11
0
MyUtil::IntSeq TalkRightAdapter::batchVerify(int index, const VerifySeq& seq) {
	
	MyUtil::IntSeq res;
	
		try {
			res = getManager(abs(index) % getCluster())->batchVerify(seq);
			
		} catch(...) {
			for(size_t i = 0; i < seq.size(); ++i){
				res.push_back(seq.at(i)->index);
			}
		}
	
	return res;
}
Пример #12
0
// FriendRankCacheI::GetRevRank {{{
map<int,int> FriendRankCacheI::GetRevRank(int hostId, const MyUtil::IntSeq& guestIds,
		const Ice::Current& cur)
{
	//struct timeval start;
	//gettimeofday(&start, NULL);

	MCE_INFO("FriendRankCacheI::GetRevRank("<<hostId<<",guestIds.size="<<guestIds.size()<<")");
	map<int,int> revrank;
	RankData target;
	int guestId = 0;

	for (vector<int>::const_iterator iter = guestIds.begin();
			 iter != guestIds.end(); ++iter)
	{
		guestId = *iter;
		// 方案1:若Cache中找不到数据,会自动调用FriendRankFactoryI::create。
		//FriendRankDataPtr rank = ServiceI::instance().locateObject<FriendRankDataPtr>(
		//		FRIEND_RANK_DATA, guestId);
		//MCE_INFO("get rank of " << guestId << "\tsize=" << rank->data.size());
		
		// 方案2:若Cache中不存在,就直接返回空对象。前提DB与Cache保持一致
		FriendRankDataPtr rank =
			ServiceI::instance().findObject<FriendRankDataPtr>(FRIEND_RANK_DATA, guestId);
		if (!rank)
			continue;

		target.userid = hostId;
		vector<RankData>::iterator kIter = 
			lower_bound(rank->data.begin(), rank->data.end(), target, RankDataComp());
		if(kIter!=rank->data.end() && kIter->userid==target.userid)
		{
			revrank.insert(make_pair<int,int>(guestId, kIter->weight));
		}
	}

	//MCE_INFO("--------------------");
	//for (map<int,int>::const_iterator iter = revrank.begin();
	//		iter != revrank.end(); ++iter)
	//{
	//	MCE_INFO(iter->first << " : " << iter->second);
	//}

	//struct timeval end;
	//gettimeofday(&end, NULL);
	//double timeuse = 1000000*(end.tv_sec-start.tv_sec) + end.tv_usec-start.tv_usec;
	//MCE_INFO("FriendRankCacheI::GetRevRank() Time used "<<timeuse/1000000<<"second.");
	return revrank;
}// }}}
Пример #13
0
ObjectResultPtr LinkViewReaderPreloaderFactory::create(const MyUtil::IntSeq& ids) {
  MCE_INFO("LinkViewReaderPreloader::create group -> id size: "<<ids.size());
  ObjectResultPtr results = new ObjectResult;
  BatchLinkViewReaderPreloaderResultHandler handler(results );
  Statement sql;
  sql << "SELECT id, link, linkStatus" << " FROM " << TABLE_PERSONAL << " WHERE id IN (";
  for (MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it) {
    if (it != ids.begin()) {
      sql << ",";
    }
    sql << *it;
  }
  sql << ")";
  QueryRunner(DB_PERSONAL, CDbRServer).query(sql, handler);
  return results;
}
Пример #14
0
MyUtil::Int2IntMap OfferFriendsUtil::getFriendCountBatch(const MyUtil::IntSeq& ids) {
        MyUtil::Int2IntMap result;
        if (ids.empty()) {
                return result;
        }
	return FriendCountCacheAdapter::instance().getFriendCounts(ids);
}
Пример #15
0
MyUtil::Int2IntSeqMap OfferFriendsUtil::getFriendSeqBatch(const MyUtil::IntSeq& ids) {
        Int2IntSeqMap result;
        if (ids.empty()) {
                return result;
        }
        return BuddyByIdCacheAdapter::instance().getFriendLists(ids);
}
Пример #16
0
int main(int argc, char* argv[]) {
	MyUtil::IntSeq ids;
	ids.push_back(68126);
	std::map<int, UserCachePtr> res = UserCacheAdapter::instance().GetUserCache(ids);
	cout << "id: " << res.find(68126)->second->id() << endl;
	cout << "name: " << res.find(68126)->second->name() << endl;
	cout << "status: " << res.find(68126)->second->status() << endl;
	cout << "tinyurl: " << res.find(68126)->second->tinyurl() << endl;
	cout << "state: " << res.find(68126)->second->state() << endl;
	cout << "gender: " << res.find(68126)->second->gender() << endl;
	cout << "online: " << res.find(68126)->second->online() << endl;
	cout << "level: " << res.find(68126)->second->level() << endl;
	cout << "univ: " << res.find(68126)->second->univ() << endl;
	cout << res.find(68126)->second->IsSelected() << endl;
	return 0;
}
Пример #17
0
void MiniGroupWriterI::reloadUsers(const MyUtil::IntSeq& user_ids, const Ice::Current& current) {
  map<int, vector<int> > seperatedIds = DBUtil<int>::seperateIdsByMod<int>(TABLE_MOD, user_ids);
  MCE_INFO("[MiniGroupWriterI::reloadUsers] userIds.size = " << user_ids.size());
  for (map<int, vector<int> >::const_iterator it = seperatedIds.begin(); it != seperatedIds.end(); ++it) {
    reloadUser2MiniGroups(it->second, it->first);
  }
}
Пример #18
0
Ice::ObjectPtr UserPhotosInfoFactoryI::create(Ice::Int id) {
  MCE_INFO("[UserPhotosInfoFactoryI::create] userId = " << id);
  vector<UserPhotosInfoPtr> ptrs;
  Statement sql;
  string tableName = TABLE_NAME + "_" + boost::lexical_cast<string>(id % TABLE_MOD);
  sql << "select " << COLUMN_USERID << ", " << COLUMN_PHOTOS << " from " << tableName << " where "
      << COLUMN_USERID << " = " << id;
  QueryRunner(DB_SOURCE, CDbRServer, tableName).query(sql, UserPhotosInfoResultHandlerI(ptrs));
  if (ptrs.empty() || (*ptrs.begin())->getPhotoInfos().empty()) {
    return EMPTY_USER_PHOTOS_INFO_PTR;
  } else {
    MyUtil::IntSeq userIds;
    userIds.push_back(id);
    FriendsRecentPhotosWriterAdapter::instance().reloadUserPhotos(userIds);
    return *ptrs.begin(); 
  }
}
Пример #19
0
void FeedGroupManagerI::GetMembersTest(const ::MyUtil::IntSeq& group_ids,
                                       const ::Ice::Current&) {
    Int2IntSeqMap res1 = UnreadInfoPool::instance().GetMembers(group_ids);
    Int2IntSeqMap res;

    MCE_INFO("FeedGroupManagerI::GetMembers group_ids size:" << group_ids.size() << " res size:" << res.size() );
    return;
}
Пример #20
0
void RecentlyOnlineBuddyManagerI::notifySomebodyOnline(
		const ::MyUtil::IntSeq& buddies, ::Ice::Int theOnlineOne,
		const Ice::Current& current) {
	MCE_INFO("RecentlyOnlineBuddyManagerI::notifySomebodyOnline buddies.size="
			<< buddies.size() << " theOnlineOne:" << theOnlineOne);
	TaskManager::instance().execute(new NotifySomebodyOnlineTask(buddies,
			theOnlineOne));
}
Пример #21
0
MyUtil::Int2IntMap UserFeedsI::getItemCountMapByTypes(const MyUtil::IntSeq& userids, const MyUtil::IntSeq& types,const ::Ice::Current& current)
{
    set<int>mysettypes;
    for(vector<int>::const_iterator i=types.begin();i!=types.end();i++)
     { 
        mysettypes.insert(*i);
    }
    ostringstream oss;
    oss << " userId.size: " << userids.size() ;
    InvokeClient tm = InvokeClient::create(current, oss.str(), InvokeClient::INVOKE_LEVEL_INFO);
    //MCE_FATAL("begin getItemCountMapByTypes function");
    MyUtil::Int2IntMap result;
                
    fs_.getItemCountMapByTypes(userids,mysettypes,result);
                    
    return result;
}
Пример #22
0
void StatManagerI::login(const MyUtil::IntSeq& ids, const Ice::Current&) {
	MCE_DEBUG("StatManagerI::login --> ids.size:" << ids.size());
	for (size_t i = 0; i < ids.size(); ++i) {
		bool succ = addLoginUser(ids.at(i));
		/*if (succ) {
		 addNotifyId(ids.at(i));

		 //addNotifyId(128487631);
		 }*/
		StatPtr st = new Stat;
		st->loginCount = 1;
		setStat(ids.at(i), st);
		//		if(ids.at(i) == 200865373){
		//			RestMediatorAdapter::instance().useImNotify(ids.at(i));
		//		}
	}
}
Пример #23
0
void IqHandlerI::SendClientFocuslist(int uid,const Ice::Current& ic) {
  string xml = "<presence ";
  int res = 0;
  MyUtil::IntSeq ans;
  try {
    ans = FeedFocusAdapter::instance().GetFocuses(uid);
    res = 1;
  } catch (Ice::Exception& e) {
    MCE_WARN("IqGetTask::getfocuslist-->FeedFocusAdapter::GetFocuses error!"<<e.what());
    res = 0;
  } catch(...) {
    MCE_WARN("IqGetTask::getfocuslist-->FeedFocusAdapter::GetFocuses error!");
    res = 0;
  }
  if (res==0) {
    xml += "res='0'><x xmlns='http://talk.xiaonei.com/focuslist'/>";
  } else {
    xml += "res='1'><x xmlns='http://talk.xiaonei.com/focuslist'>";
    for (int i=0;i<ans.size();++i) {
      ostringstream os;
      os << ans[i];
      xml += "<uid>";
      xml += os.str();
      xml += "</uid>";
    }
    xml += "</x>";
  }
  xml += "</presence>"; 
  MCE_DEBUG(xml);
  JidSeq jseq;
  try {
    jseq = TalkFunStateAdapter::instance().getUserJids(uid,4);
  } catch(Ice::Exception& e) {
    MCE_WARN("IqHandlerI::SendClientFocuslist-->TalkFunState::getUserJids error!"<<e.what());
    return ;
  }
  for (JidSeq::iterator it = jseq.begin();it != jseq.end() ;++it) {
    try {
      TalkProxyAdapter::instance().express((*it), xml);
    } catch(Ice::Exception& e) {
      MCE_WARN("IqHandlerI::SendClientFocuslist-->TalkProxyAdapter::express error!"<<e.what());
    }
  }
  return ;
}
Пример #24
0
MyUtil::ObjectResultPtr FriendsRecentPhotosPreloaderFactory::create(const MyUtil::IntSeq& ids) {
    MCE_INFO("[FriendsRecentPhotosPreloaderFactory::create] ids.size = " << ids.size());
    MyUtil::ObjectResultPtr result = new MyUtil::ObjectResult;
    if (ids.empty()) {
        return result;
    }
    vector<UserPhotosInfoPtr> resultPtrs;
    //此处一定要注意,ids并不一定属于同一个尾号
    map<int, vector<int> > seperatedIds = xce::mngp::DBUtil<int>::seperateIdsByMod<int>(TABLE_MOD, ids);
    for (map<int, vector<int> >::const_iterator itv = seperatedIds.begin(); itv != seperatedIds.end(); ++itv) {
        Statement sql;
        string tableName = TABLE_NAME + "_" + boost::lexical_cast<string>(itv->first % TABLE_MOD);
        sql << "select " << COLUMN_USERID << ", " << COLUMN_PHOTOS << " from " << tableName << " where "
            << COLUMN_USERID << " in " << xce::mngp::DBUtil<int>::getIdsStr<int>(itv->second);
        QueryRunner(DB_SOURCE, CDbRServer, tableName).query(sql, UserPhotosInfoResultHandlerI(resultPtrs));
    }
    return UserPhotosInfo::changeToUserPhotosInfoMap(resultPtrs);
}
Пример #25
0
void RecentContactSet::updateDb(int ownerId,const ContactInfoSeq& contactInfos){
   	GetProps& props = GetProps::instance();
        string table = props.getTableName(ownerId);
        Statement sqlAdd;
	
	size_t guests_size = contactInfos.size() > size_t(GUESTS_SIZE) ? size_t(GUESTS_SIZE):contactInfos.size();
        MyUtil::IntSeq byteSeq;
        for ( size_t i = 0; i < guests_size; ++i ) {
                byteSeq.push_back((contactInfos[i]->guestId));
                byteSeq.push_back(time(NULL));
                byteSeq.push_back((contactInfos[i]->type));
        }

        sqlAdd << "REPLACE INTO " << table << "(" << COLUMN_HOST << ", " << COLUMN_GUESTS << ")" << "  values" << " ("<< ownerId << ","<<mysqlpp::quote<<IntSeqSerialize::serialize(byteSeq)<<")";

 //       QueryRunner(DB_SOURCE, CDbWServer, table).execute(sqlAdd);
          QueryRunner(DB_SOURCE, CDbWServer, table).schedule(sqlAdd);
}
Пример #26
0
MyUtil::IntSeq FriendInputManagerI::getFriendInput(Ice::Int hostID,const string& condition,Ice::Int limit,const Ice::Current& crt) {
	MCE_INFO("getFriendInput hostID= "<<hostID<<" condition="<<condition<<" limit="<<limit<<" condition size:"<<condition.size());

  if(limit <= 0) {
    MCE_WARN("limit is lower than zero~");
    return vector<int>();
  }

  int len = FriendSuggestUtil::getStrLen(condition);
  MCE_DEBUG("conditin len is:"<<len);
  if(len > 15 || len == 0) {
    MCE_WARN("condition len is:"<<len<<" is zero or large than 15");
		return vector<int>();
  }	else  {
		FriendInputDataIPtr  server = ServiceI::instance().findObject<FriendInputDataIPtr>(FRIENDINPUT_DATA, (long)hostID);
		if(server != NULL){
			time_t old = server->getTime();
			int duration = time(NULL) - old;
			MCE_DEBUG("duration is:"<<duration);
			if(duration >= TIMEOUT_CACHE)  {//remove and add
        MCE_DEBUG("cache timeout~~");
				ServiceI::instance().removeObject(FRIENDINPUT_DATA, (long)hostID);
		    createObject(hostID,server);
      } 
		} else {//add
       createObject(hostID,server);
    }
   MyUtil::IntSeq pids;
   if(server == NULL) {
     MCE_DEBUG("the server is null,createObject failure~");
     return vector<int>();
   }

   pids = server->search(condition,limit);

   if(pids.size() == 0) {
     MCE_INFO("getFriendInputManagerI result is null~");
   } else {
     MCE_INFO("res is not null~ and res.size()="<<pids.size()<<"FriendInputManagerI::getFriendInput done hostID= "<<hostID<<" condition="<<condition<<" limit="<<limit << " res:"  << PrintHelper::Print(pids));
   }
   return pids;
	}
};
Пример #27
0
void MiniGroupWriterI::reloadUser2MiniGroups(const MyUtil::IntSeq& userIds, int mod) {
  MCE_INFO("[MiniGroupWriterI::reloadUser2MiniGroups] userIds.size = " << userIds.size() << " mod = " << mod);
  vector<User2MiniGroupInfoPtr> ptrs;
  User2MiniGroupInfoResultHandlerI handler(ptrs);
  Statement sql;
  sql << "select " << TABLE_MEMBER_MINIGROUP_MNGP_ID << ", " << TABLE_MEMBER_MINIGROUP_MEMBER_ID
    << " from " << TABLE_MEMBER_MINIGROUP << "_" << mod << " where " << TABLE_MEMBER_MINIGROUP_MEMBER_ID
    << " in " << DBUtil<int>::getIdsStr(userIds) << " and " << TABLE_MEMBER_MINIGROUP_RESTRICT
    << TABLE_MEMBER_MINIGROUP_SORT;
  com::xiaonei::xce::QueryRunner(DB_SOURCE, com::xiaonei::xce::CDbRServer).query(sql, handler);
  set<int> userIdsToClear(userIds.begin(), userIds.end());
  for (vector<User2MiniGroupInfoPtr>::const_iterator it = ptrs.begin(); it != ptrs.end(); ++it) {
    minigroup::MiniGroupManagerAdapter::instance().setJoinedMiniGroups((*it)->userId, (*it)->miniGroupIds);
    userIdsToClear.erase((*it)->userId);
  }
  for (set<int>::const_iterator it = userIdsToClear.begin(); it != userIdsToClear.end(); ++it) {
    minigroup::MiniGroupManagerAdapter::instance().removeAllJoinedMiniGroups(*it);
  }
}
Пример #28
0
void FriendFinderByActiveUserI::setNegtiveList(const MyUtil::IntSeq& userList, const Ice::Current& current) {
	MCE_INFO("[FriendFinderByActiveUserI] setNegtiveList userList size = " << userList.size());

	if (g_userLoginData_ptr == NULL) {
		MCE_WARN("[FriendFinderByActiveUserI] setNegtiveList g_userLoginData_ptr is null");
		g_userLoginData_ptr = new UserLoginData();
	}

	g_userLoginData_ptr->setNegtiveUserList( userList );
}
Пример #29
0
int UserFeedsI::getItemCountByTypes(const MyUtil::IntSeq& userids,const MyUtil::IntSeq& types,const ::Ice::Current& current)
{
  set<int>mysettypes;
  for(vector<int>::const_iterator i=types.begin();i!=types.end();i++)
  {
    mysettypes.insert(*i);
  }
  ostringstream oss;
  oss << " userids.size: " << userids.size();
  InvokeClient tm = InvokeClient::create(current, oss.str(), InvokeClient::INVOKE_LEVEL_INFO);
  //MCE_FATAL("getItemCountByTypes function:start");
  try {
      return fs_.getItemCountByTypes(userids,mysettypes);
  } catch (std::exception& e) {
     MCE_WARN("UserFeedsI::getItemCountByTypes Exception!" << e.what());
  } catch (...) {
     MCE_WARN("UserFeedsI::getItemCountByTypes Exception");
  } 
  return -1;
}
Пример #30
0
MyUtil::ObjectResultPtr Icon2UrlDataReaderPreloaderFactory::create(const MyUtil::IntSeq& ids) {
	MCE_INFO("Icon2UrlDataReaderPreloaderFactory::create group -> id size: "<<ids.size());
        
	MyUtil::ObjectResultPtr result = new MyUtil::ObjectResult;
	
	xce::vipinfo::BatchIcon2UrlDataResultHandlerI handler(result);

	com::xiaonei::xce::Statement sql;
	sql << "SELECT * FROM " << TABLE_ICON_URL << " WHERE id IN (  ";
	for (MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it) {
		if (it != ids.begin()) {
			sql << ",";
		}
		sql << *it;
	}
	sql << ")";
	
	com::xiaonei::xce::QueryRunner(DB_MEMBERS, com::xiaonei::xce::CDbRServer ).query(sql, handler);
	
	return result;
}