void UserLoginData::setLoginMap(const MyUtil::Int2IntMap& loginMap) { IceUtil::RWRecMutex::WLock lock(_init_flag_mutex); for(Int2IntMap::const_iterator iter=loginMap.begin(); iter!=loginMap.end(); ++iter) { _userLoginMap[iter->first] = bitset<32>(iter->second); } MCE_INFO("[UserLoginData] setLoginMap _userLoginMap size(" << _userLoginMap.size() << ")"); }
void MyUtil::__writeInt2IntMap(::IceInternal::BasicStream* __os, const ::MyUtil::Int2IntMap& v) { __os->writeSize(::Ice::Int(v.size())); ::MyUtil::Int2IntMap::const_iterator p; for(p = v.begin(); p != v.end(); ++p) { __os->write(p->first); __os->write(p->second); } }
void OnlineStateFilterManagerI::updateOnlineStateBatch(const ::MyUtil::Int2IntMap& onlinestatemap, const Ice::Current& current) { ostringstream op; for (Int2IntMap::const_iterator it = onlinestatemap.begin(); it != onlinestatemap.end(); ++it) { if (it->second) { _online_state.set(it->first); } else { _online_state.reset(it->first); } op << it->first << "(" << it->second << ") "; } MCE_INFO("OnlineStateFilterManagerI::updateOnlineStateBatch -> " << op.str() ); }
void StatusCacheManagerI::updateStatusBatch(const ::MyUtil::Int2IntMap& statusmap, const Ice::Current& current){ ostringstream op; for (Int2IntMap::const_iterator it = statusmap.begin(); it != statusmap.end(); ++it) { if ( (it->second!=0)&&(it->second!=3) ) { _status.set(it->first); } else { _status.reset(it->first); } op << it->first << "(" << it->second << ") "; } MCE_INFO("StatusCacheManagerI::updateStatusBatch -> " << op.str() ); }
void MyUtil::__readInt2IntMap(::IceInternal::BasicStream* __is, ::MyUtil::Int2IntMap& v) { ::Ice::Int sz; __is->readSize(sz); while(sz--) { ::std::pair<const ::Ice::Int, ::Ice::Int> pair; __is->read(const_cast< ::Ice::Int&>(pair.first)); ::MyUtil::Int2IntMap::iterator __i = v.insert(v.end(), pair); __is->read(__i->second); } }
void FeedItemManagerI::addFeed(const FeedItem& item, const FeedConfigPtr& config, const MyUtil::Int2IntMap& id2weight, const Ice::Current&) { MCE_DEBUG("FeedItemManagerI::addFeed --> feed="<<item.feed); // MCE_DEBUG("FeedItemManagerI::addFeed --> feed="<<item.feed << " merge="<<item.merge << " type="<<item.type << " time="<<item.time<<"\n\ttarget-->"); for (MyUtil::Int2IntMap::const_iterator it = id2weight.begin(); it != id2weight.end(); ++it) { UserFeedSetPtr feedSet = locateUserFeedSet(it->first); if (feedSet) { FeedPtr f = new Feed(item, it->second); feedSet->addFeed(f, config); } } }
RelationshipEntryList BuddyRelationCacheManagerI::getRelationBatch(const MyUtil::Int2IntMap & ids, const Ice::Current& current){ ostringstream msg; msg << ids.size() ; InvokeClient client = InvokeClient::create(current, msg.str(), InvokeClient::INVOKE_LEVEL_INFO); RelationshipEntryList list; for(MyUtil::Int2IntMap::const_iterator it=ids.begin(); it!=ids.end(); ++it) { Relationship relation ; relation.from = it->first; relation.to = it->second; BuddyDesc desc=BuddyRelationCacheLogic::instance().getRelation(relation); RelationshipEntry entry ; entry.relation = relation; entry.desc = desc; list.push_back(entry); } return list; }
MyUtil::Int2IntMap BuddyByAddTimeCacheAdapter::getFriendCounts(const MyUtil::IntSeq& ids){ if (ids.empty()){ return MyUtil::Int2IntMap(); } size_t numCluster_sizeT = getCluster(); int numCluster = (int)numCluster_sizeT; if (numCluster < 0) { MCE_WARN("[BuddyByAddTimeCacheAdapter::getFriendCounts] this should not be seen! Why cluster=" << numCluster_sizeT << " ???" ); return MyUtil::Int2IntMap(); } if (numCluster == 0 || numCluster == 1) { try { return getProxy(ids.at(0))->getFriendCounts(ids); } catch (...) { return MyUtil::Int2IntMap(); } } else { vector< vector<int> > seperatedIds; seperatedIds.resize(numCluster); for (MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it) { seperatedIds.at(*it % numCluster).push_back(*it); } MyUtil::Int2IntMap result; for (int posCluster = 0; posCluster < numCluster; ++posCluster) { MyUtil::Int2IntMap someResult; if( seperatedIds.at(posCluster).size() > 0 ){ try { someResult = getProxy(posCluster)->getFriendCounts(seperatedIds.at(posCluster)); } catch (...) { MCE_WARN( "BuddyByAddTimeCacheAdapter::getFriendCounts from Proxy(" << posCluster << ") handle unknown exception." ); } result.insert( someResult.begin(), someResult.end() ); } } return result; } }
void UserStateFilterManagerI::updateUserStateBatch(const ::MyUtil::Int2IntMap& statemap, const Ice::Current& current){ ostringstream op; for (Int2IntMap::const_iterator it = statemap.begin(); it != statemap.end(); ++it) { op << " " << it->first; if (it->second&1) { _user_state_star.set(it->first); op << "(1:true)"; } else { _user_state_star.reset(it->first); op << "(1:false)"; } if (it->second&5) { _user_state_guide.reset(it->first); op << "(5:false)"; } else { _user_state_guide.set(it->first); op << "(5:true)"; } } MCE_INFO("UserStateFilterManagerI::updateUserStateBatch -> " << op.str() << " " << current.con->toString().substr(current.con->toString().find("remote", 25))); }
void DataNodeManager::putBatch(const FeedItem& feed, const MyUtil::Int2IntMap& usersWeight) { static const unsigned int MAX_MSG_SIZE = 5000; map<int, vector<pair<bool, BlockInfoSeq> > > blkInfoMap; Int2IntMap::const_iterator it = usersWeight.begin(); //pair<bool, BlockInfoSeq> p = make_pair<bool, BlockInfoSeq>(false, BlockInfoSeq()); for(; it!=usersWeight.end(); ++it) { //if((it->first%10 > 5)){ // continue; //} if(it->first == 0) { continue; } BlockInfoPtr blk = get(it->first, true); if(!blk) { MCE_WARN("DataNodeManager::putBatch --> can not get a block " << it->first); continue; } if(blk->userId==261947900 || blk->userId==227805680) { MCE_INFO("#put# userid:"<<it->first<<" file:"<<blk->fileId<<" index:"<<blk->blockIndex <<" tc:"<<blk->totalCount<<" cc:"<<blk->curCount << " preF:" << blk->preFileId << " preB:" << blk->preBlockIndex <<" -- " << " feed:" << feed.feed); } blk->weight = it->second; //MCE_INFO("@@get block " << userIds.at(i) << " " << blk->serverId); //Blk2FeedPtr tmp = new Blk2Feed; //tmp->blkInfo = blk; //tmp->feed = it->second; if(blkInfoMap[blk->serverId].empty() || blkInfoMap[blk->serverId].rbegin()->second.size() >= MAX_MSG_SIZE) { blkInfoMap[blk->serverId].push_back(pair<bool, BlockInfoSeq>(false, BlockInfoSeq())); } if(blk->curCount == 1) { blkInfoMap[blk->serverId].rbegin()->first = true; } blkInfoMap[blk->serverId].rbegin()->second.push_back(blk); //blkInfoMap[blk->serverId].push_back(blk); } map<int, vector<pair<bool, BlockInfoSeq> > >::iterator tmpIt = blkInfoMap.begin(); for(; tmpIt!=blkInfoMap.end(); ++tmpIt) { for(size_t i=0; i<tmpIt->second.size(); i++) { //最多重试10次 //for(int j=0; j<10; j++){ TimeStat t; try { MCE_INFO("DataNodeManager::putBatch --> invoke SSDFeedDBData" << tmpIt->first << " size:" << tmpIt->second.at(i).second.size()); SSDFeedDBDataAdapter::instance().putBatchBinary(feed, tmpIt->second.at(i).second); } catch(Ice::Exception& e) { MCE_WARN("DataNodeManager::putBatch --> invoke SSDFeedDBData" << tmpIt->first << " err, " << e); RetryTimer::instance().push(feed, tmpIt->second.at(i).second); //string tmp = e.what(); //if(tmp.find("TimeoutException") != string::npos){ // break; //} //if(!tmpIt->second.at(i).first){ // break; //} } PerformanceStat::instance().stat("CallData", t.getTime()); //} } } //MCE_INFO("batch put --> " << usersWeight.size() << " " << blkInfoMap.size()); }