Beispiel #1
0
void
MyUtil::__writeLong2IntMap(::IceInternal::BasicStream* __os, const ::MyUtil::Long2IntMap& v)
{
    __os->writeSize(::Ice::Int(v.size()));
    ::MyUtil::Long2IntMap::const_iterator p;
    for(p = v.begin(); p != v.end(); ++p)
    {
        __os->write(p->first);
        __os->write(p->second);
    }
}
Beispiel #2
0
void DataNodeManager::putBatch(const FeedItem& feed, const MyUtil::Long2IntMap& usersWeight){
	static const unsigned int MAX_MSG_SIZE = 5000;
	map<int, vector<pair<bool, BlockInfo64Seq> > > blkInfoMap;
	Long2IntMap::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;
		}
		BlockInfo64Ptr blk = get(it->first, true);
		if(!blk){
			MCE_WARN("DataNodeManager::putBatch --> can not get a block " << it->first);
			continue;
		}
		if(blk->key==261947900 || blk->key==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, BlockInfo64Seq>(false, BlockInfo64Seq()));
		}
		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, BlockInfo64Seq> > >::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 FeedDBData" << tmpIt->first << " size:" << tmpIt->second.at(i).second.size());
					FeedDBDataAdapter::instance().putBatchBinary(feed, tmpIt->second.at(i).second);
				}catch(Ice::Exception& e){
					MCE_WARN("DataNodeManager::putBatch --> invoke FeedDBData" << 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());

}