// FriendRankLoaderFactory::create(const MyUtil::IntSeq& ids) {{{ ObjectResultPtr FriendRankLoaderFactory::create(const MyUtil::IntSeq& ids) { MCE_DEBUG("FriendRankLoaderI::create group -> id size: "<<ids.size()); MyUtil::ObjectResultPtr results = new MyUtil::ObjectResult; if (ids.size()<=0) return results; Statement sql; sql << "SELECT user_id,rank FROM friend_rank_new" << " WHERE user_id in (" << ids[0]; for (size_t i=1; i < ids.size(); ++i) { sql << "," << ids[i]; } sql << ")"; try { QueryRunner("friend_rank", CDbRServer).query( sql, FriendRankBatchResultHandler(results)); } catch (Ice::Exception& e) { MCE_WARN("[create] Ice::Exception " << e.what()); } catch (std::exception& e) { MCE_WARN("[create] std::excetpion " << e.what()); } catch (...) { MCE_WARN("[create] exception"); } return results; }// }}}
ObjectResultPtr BuddyApplyCacheNPreloaderFactory::create(const MyUtil::IntSeq& ids) { MCE_INFO("BuddyApplyCacheNPreloaderFactory::create group -> id size: "<<ids.size()); int minId = ids.front(); int maxId = ids[ids.size()-1]; MCE_INFO("BuddyApplyCacheNPreloaderFactory::create group -> id from: "<<minId <<" to: "<<maxId); ObjectResultPtr results = new ObjectResult; for(std::vector<int>::const_iterator it = ids.begin(); it != ids.end() ; ++it) { int id = *it; BuddyApplyCacheNPtr buddyApplyCacheResult = new BuddyApplyCacheN(); buddyApplyCacheResult->ownerId = id; BuddyApplyCacheResultHandlerI handler(buddyApplyCacheResult); Statement sql; sql << "SELECT applicant,UNIX_TIMESTAMP(time) AS unix_time,why,stat_from,group_name" << " FROM buddyapply_accepter_" << abs(id % 100) << " WHERE accepter = '" << id << "'" << " ORDER BY time DESC" << " LIMIT 100"; ostringstream pattern; pattern << "buddyapply_accepter_" << id % 100; QueryRunner("buddyapplycache_accepter", CDbRServer,pattern.str()).query(sql, handler); results->data.insert(make_pair(*it, buddyApplyCacheResult)); } MCE_INFO("BuddyApplyCacheNPreloaderFactory::create group -> data.size: "<< results->data.size()); return results; }
void FeedMemcContentI::Test2(const MyUtil::IntSeq & ids, const Ice::Current&) { if(ids.size() == 0){ return; } return; if(ids.size()%10 < 10){ //TalkCacheClient::instance().GetUserBySeqWithLoad(0, ids); } }
Int2IntSeqMap FeedGroupManagerI::GetMembers(const ::MyUtil::IntSeq& gids, const ::Ice::Current&) { Int2IntSeqMap res; for (unsigned i = 0; i != gids.size(); ++i) { res[gids.at(i)] = UnreadInfoPool::instance().GetMembersInGroup(gids.at(i)); } MCE_INFO("FeedGroupManagerI::GetMembers gids size:" << gids.size() << " res size:" << res.size() ); return res; }
void SocialFeedCacheI::remove(::Ice::Int hostId, const MyUtil::IntSeq& friendIds, const MyUtil::IntSeq& newCommonIds, const Ice::Current& current) { MCE_INFO("[SocialFeedCacheI] remove hostId(" << hostId << ") friendIds size(" << friendIds.size() << ") newCommonIds size(" << newCommonIds.size() << ")"); Feed feedItem; feedItem.friendIds = friendIds; feedItem.newCommonIds = newCommonIds; TaskManager::instance().execute( new RemoveTask(hostId, feedItem) ); }
MyUtil::IntSeq OfferFriendsUtil::getPhotoIdsFrom(const MyUtil::IntSeq& ids){ try { return PhotoStateFilterAdapter::instance().getPhotoIdsFrom( ids ); } catch( Ice::Exception e ){ MCE_WARN("[OfferFriendsUtil::getPhotoIdsFrom] ids.size()=" << ids.size() << " found Ice::Exception : " << e.what() ); return ids; } catch( ... ){ MCE_WARN("[OfferFriendsUtil::getPhotoIdsFrom] ids.size()=" << ids.size() << " found unknown exception : " ); return ids; } return ids; }
void UserAdsCacheLoaderI::load(const MyUtil::IntSeq& ids, const Ice::Current& current) { MCE_DEBUG("UserAdsCacheLoaderI::load -> size: "<<ids.size()<<" " << current.con->toString().substr(current.con->toString().find("remote",25))); MyUtil::IntSeq is; for (MyUtil::IntSeq::const_iterator i = ids.begin(); i != ids.end(); ++i) { if (*i > 0) { is.push_back(*i); } } if (is.size() <= 0) { return ; } CacheLoader<UserAdsCacheManagerPrx>::instance().reload(is); }
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; }
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; }
void OnlineManagerI::setStats(const ::MyUtil::IntSeq& userIds, ::Ice::Int onlineType, bool online, const Ice::Current& current) { MCE_DEBUG("OnlineManagerI::setStats working..."); for (size_t i = 0; i< userIds.size() ; ++i) { setStat(userIds.at(i) , onlineType, online); } }
void HatDataWriterI::reload(const MyUtil::IntSeq& ids, const Ice::Current & current) { ostringstream inMsg; inMsg<<"id size = " << ids.size(); MyUtil::InvokeClient ic = MyUtil::InvokeClient::create(current, inMsg.str(), MyUtil::InvokeClient::INVOKE_LEVEL_INFO); MyUtil::ObjectResultPtr result = new MyUtil::ObjectResult; com::xiaonei::xce::Statement sql; sql << "SELECT * FROM " << TABLE_HAT << " WHERE id IN ( "; for(MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it) { if(it != ids.begin()) { sql << ","; } sql << *it; } sql << " )"; BatchHatDataResultHandlerI handler(result); { com::xiaonei::xce::QueryRunner(DB_MEMBERS, com::xiaonei::xce::CDbRServer).query(sql, handler); xce::adapter::hatdata::HatDataReaderAdapter::instance().setData(result); } }
void MiniGroupWriterAdapter::run() { while (true) { MyUtil::IntSeq userIds; MyUtil::LongSeq miniGroupIds; { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_mutex); if (_userIdSet.empty() && _miniGroupIdSet.empty()) { _mutex.wait(); } userIds.insert(userIds.end(), _userIdSet.begin(), _userIdSet.end()); _userIdSet.clear(); miniGroupIds.insert(miniGroupIds.end(), _miniGroupIdSet.begin(), _miniGroupIdSet.end()); _miniGroupIdSet.clear(); } if (!userIds.empty()) { try { getMiniGroupWriterPrx(0)->reloadUsers(userIds); } catch(Ice::Exception& e) { MCE_WARN("[MiniGroupWriterAdapter::run] reloadUsers size = " << userIds.size()); } } if (!miniGroupIds.empty()) { try { getMiniGroupWriterPrx(0)->reloadMiniGroups(miniGroupIds); } catch(Ice::Exception& e) { MCE_WARN("[MiniGroupWriterAdapter::run] reloadMiniGroups size = " << miniGroupIds.size()); } } } }
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); } }
//获取uid的好友用户中不是gid的粉丝的那些用户 MyUtil::IntSeq MutualFriendsCacheManagerI::getUnMutualFriends(int uid, const MyUtil::GlobalIdPtr& gid, int begin, int limit, const Ice::Current& current) { ostringstream msg; msg << "uid = " << uid << ", gid = " << GlobalIdTransfer::get(gid) << ", begin = " << begin << ", limit = " << limit; InvokeClient ic = InvokeClient::create(current, msg.str(), InvokeClient::INVOKE_LEVEL_INFO); MyUtil::IntSeq fids = getAllFansAsc(gid); MyUtil::IntSeq uids = getFriendsAsc(uid); MyUtil::IntSeq result; if (limit < -1 || begin < 0 || uid < 0) { return result; } else { int count = 0; int countLimit = (limit == -1) ? uids.size() : limit; MyUtil::IntSeq::iterator fit = fids.begin(); MyUtil::IntSeq::iterator uit = uids.begin(); while (fit != fids.end() && uit != uids.end() && count < countLimit + begin) { if (*fit < *uit) { fit++; } else if (*uit < *fit) { if(count >= begin){ result.push_back(*uit); } count++; uit++; } else { fit++; uit++; } } return result; } }
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)); }
::MyUtil::IntSeq BuddyManagerI::getBlockSeq(::Ice::Int from, ::Ice::Int begin, ::Ice::Int limit, const Ice::Current& current) { MyUtil::IntSeq result; result = locateBuddyRelation(from)->getBuddyList(Block); MCE_DEBUG("BuddyManagerI::getBlockSeq -> " << from << " -> " << result.size()); return result; }
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; }
::MyUtil::IntSeq BuddyManagerI::getFriendSeq(::Ice::Int userId, ::Ice::Int begin, ::Ice::Int limit, const Ice::Current& current) { MyUtil::IntSeq result; result = locateBuddyRelation(userId)->getBuddyList(Friend); MCE_DEBUG("BuddyManagerI::getFriendSeq -> " << userId << " -> " << result.size()); return result; }
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)); // } } }
MyUtil::IntSeq RecentlyOnlineBuddyData::get_most_recent(int limit) { IceUtil::Mutex::Lock lock(*this); MyUtil::IntSeq result; for (std::deque<int>::reverse_iterator it = _buddies.rbegin(); (int) result.size() < limit && it != _buddies.rend(); ++it) { if (find(result.begin(), result.end(), *it)!=result.end()) continue; result.push_back(*it); } return result; }
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 ); }
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; } };
void BuddyManagerI::cacheUserCountGuestRequest(uint32_t userId) { uint32_t count = 0; MyUtil::IntSeq applied = locateBuddyRelation(userId)->getBuddyList(Applied); count = applied.size(); if(count > 100){ count = 100; } TaskManager::instance().execute(new CacheUserCountGuestRequestTask(userId, count)); }
MyUtil::IntSeq UserLoginData::getActiveUser(const MyUtil::IntSeq& userList) { MCE_INFO("[UserLoginData] getActiveUser userList size = " << userList.size()); IntSeq result; for(IntSeq::const_iterator iter=userList.begin(); iter!=userList.end(); ++iter) { if( _negtiveUserList.count(*iter) <= 0 ) { //活跃用户 result.push_back(*iter); } } return result; }
void xce::compareinfo::CompareInfoReloaderI::reload(const MyUtil::IntSeq& ids, const Ice::Current& current) { ostringstream oss; oss << "CompareInfoReloaderI::reload -> size: "<<ids.size() << current.con->toString().substr(current.con->toString().find("remote",25)); TimeCost tc = TimeCost::create(oss.str(), TimeCost::LOG_LEVEL_INFO); MyUtil::IntSeq tempids; for (MyUtil::IntSeq::const_iterator i=ids.begin(); i!=ids.end();++i){ if (*i > 0) { tempids.push_back(*i); } } MyUtil::TaskManager::instance().execute(new ReloadTask(tempids, current)); }
//-------------------------------------------------------------------------------- void VertifyPipe::handle(const ObjectSeq& seq) { //MCE_INFO("VertifyPipe::handle --> thread_id = " << pthread_self()); if (seq.empty()) { return; } else { //MCE_DEBUG("VertifyPipe::handle --> objectseq size = " <<seq.size()); } VerifySeq vSeq; IntSeq needNotVerifyUsers; for (size_t i = 0; i < seq.size(); ++i) { MessagePtr m = MessagePtr::dynamicCast(seq.at(i)); //MCE_INFO("m->from = " << m->from->userId << " m->to = " << m->to->userId); if( (m->type != MESSAGE && m->type != OFFLINE_MESSAGE) || (m->from->userId == 365734329 || m->to->userId == 365734329) ){//客服ID,不检查好友。 //MCE_INFO("VertifyPipe::handle --> m->from = " << m->from << " m->to = " << m->to); needNotVerifyUsers.push_back(i); continue; } VerifyPtr v = new Verify(); v->from = m->from->userId; v->to = m->to->userId; /*if(MESSAGE != m->type){ v->to = v->from; }*/ v->type = m->type; /* if (v->type == SYSTEM_MESSAGE) { v->sysMsgType = m->from->endpoint; }*/ v->index = i; vSeq.push_back(v); } MyUtil::IntSeq indexSeq; try{ indexSeq = TalkRightAdapter::instance().batchVerify(getIndex(), vSeq); }catch(Ice::Exception& e){ MCE_WARN("VertifyPipe::handle-->TalkRightAdapter::batchVerify-->" << e); } indexSeq.insert(indexSeq.end(), needNotVerifyUsers.begin(), needNotVerifyUsers.end()); //MCE_DEBUG("VertifyPipe::handle -->indexSeq size:"<<indexSeq.size()); for (size_t i = 0; i < indexSeq.size(); ++i) { MessagePtr m = MessagePtr::dynamicCast(seq.at(indexSeq.at(i))); //MCE_DEBUG("VertifyPipe::handle --> "<<m->to->index); if (m->to->index == 0 || m->to->index == 2 || m->to->index >1) { //MCE_DEBUG("VertifyPipe::handle --> endpoint:"<<m->to->endpoint); PipePool::instance().push(m->to->endpoint, 0, m); } } }
bool BuddyList::load() { IceUtil::Mutex::Lock lock(_mutex); StatFunc statF("BuddyList::load --> ***"); MCE_DEBUG("BuddyList::load --> load online buddies " << _userId); MyUtil::IntSeq ids; try { MCE_DEBUG("BuddyList::load --> invoke BuddyCore " << _userId); ids = BuddyByIdCacheAdapter::instance().getFriendListAsc(_userId, 5000); MCE_DEBUG("BuddyList::load --> buddies count " << ids.size()); } catch (Ice::Exception& e) { MCE_WARN("BuddyList::load -> get buddies error" << e); return false; } for(size_t i=0; i<ids.size(); i++){ if(OnlineManagerI::instance().has(ids.at(i))){ _buddies.insert(ids.at(i)); } } MCE_DEBUG("BuddyList::load --> online buddies count " << _buddies.size()); return true; }
::MyUtil::Int2IntSeqMap BuddyByOnlineTimeCacheManagerI::getFriendLists( const MyUtil::IntSeq& hostIds, const Ice::Current& current){ ostringstream msg; msg << "hostIds.size()=" << hostIds.size(); InvokeClient ic = InvokeClient::create(current, msg.str(), InvokeClient::INVOKE_LEVEL_INFO); Int2IntSeqMap result; for(MyUtil::IntSeq::const_iterator it = hostIds.begin();it!=hostIds.end();++it) { result.insert( make_pair( *it, locateBuddyByOnlineTimeDataI(*it)->get_most_recent(0,-1) ) ); } return result; }
void xce::usercache::UserCacheReloaderI::rebuildOnline(const MyUtil::IntSeq& ids, const Ice::Current& current) { ostringstream oss; oss << "UserCacheReloaderI::rebuildOnline -> size: "<< ids.size() << " " << current.con->toString().substr(current.con->toString().find("remote",25)); TimeCost tc = TimeCost::create(oss.str(), TimeCost::LOG_LEVEL_INFO); MyUtil::IntSeq rebuildIds; for (MyUtil::IntSeq::const_iterator i=ids.begin(); i!=ids.end();++i){ if (*i > 0) { rebuildIds.push_back(*i); } } RebuildOnline::instance().rebuild(rebuildIds); }
void RecommendData::removeBatch(const MyUtil::IntSeq& idSeq) { MCE_INFO("[RecommendData] removeBatch ownerId(" << _ownerId << ") idSeq size(" << idSeq.size() << ")"); IceUtil::Mutex::Lock lock(*this); for(IntSeq::const_iterator iter=idSeq.begin(); iter!=idSeq.end(); ++iter) { _recommendMap.erase(*iter); _friendrank.erase(*iter); } if( _recommendMap.empty() ) { TaskManager::instance().execute( new BuildTask(_ownerId) ); } }