Exemplo n.º 1
0
void FeedDBDataI::putBatch(const FeedItem& feed, const BlockInfoSeq& blkInfoSeq, const Ice::Current&){
	if(!_inited){
		MCE_WARN("FeedDBDataI::putBatch --> not initialized");
		return;
	}
	//MCE_INFO("@@@@@@");
	//MCE_INFO("FeedDBDataI::putBatch --> to size:" << blkInfoSeq.size());
	TimeStat t;
	map<int, FeedItemBlockInfoSeq> split;
	for(int i=0; i<blkInfoSeq.size(); i++){
		if(blkInfoSeq.at(i)->serverId != _index){
			MCE_WARN("FeedDBDataI::putBatch --> serverid err " << _index << " " << blkInfoSeq.at(i)->serverId);
			continue;
		}
		FeedItemBlockInfoPtr data = new FeedItemBlockInfo;
		data->blk = blkInfoSeq.at(i);
		data->item = feed;
		data->item.weight = blkInfoSeq.at(i)->weight;
		split[blkInfoSeq.at(i)->fileId].push_back(data);
	}
	map<int, FeedItemBlockInfoSeq>::iterator it = split.begin();
	for(; it!=split.end(); ++it){
		if(it->second.empty()){
			MCE_WARN("FeedDBDataI::putBatch --> empty fileid:" << it->first);
		}
		CacheManager::instance().asyncPut(it->second, true, 0);
	}
	PerformanceStat::instance().stat("putBatch", t.getTime());
}
Exemplo n.º 2
0
pair<float,float> FeedItemManagerI::GetFeedContentDict(GetRequest & req,FeedContentDict & fdict){
  set<long> & fidset = req.GetShowedFids();;
  vector<long> fids(fidset.begin(),fidset.end());

  TimeStat ts;
	try {
    fdict = FeedContentAdapter::instance().getFeedDict(fids);
  } catch (Ice::Exception& e) {
    MCE_WARN("FeedItemManagerI::GetFeedContentDict. get memcached fail. uid:" << req.uid_ << " err:" << e);
  }
  int memcnt = fdict.size();
  float memcost = ts.Get();

  bool load_db = false;
  if(fdict.size() < fids.size()){
    CheckLoad(req.uid_,fids,fdict);
    load_db = true;
  }
  int dbcnt = fdict.size() - memcnt;
  float dbcost = ts.Get();

  MCE_INFO("FeedItemManagerI::GetFeedContentDict. uid:" << req.uid_
  		<< " request:" << fids.size()
  		<< " load_db:" << load_db
  		<< " memcnt:" << memcnt << " dbcnt:" << dbcnt
  		<< " total:" << fdict.size()
  		<< " memcost:" << memcost << " dbcost:" << dbcost
  );
  return make_pair(memcost,dbcost);
//  MCE_INFO("show fids:" << PrintHelper::Print(fids));
//  if(fids.size() > 100){
//  	MCE_WARN("@@@@@@@@@@ TOOLARGE. uid:" << req.uid_);
//  	PrintHelper::Print(req.item3d_);
//  }
}
Exemplo n.º 3
0
FeedIndexPtr DbHelper::getFeedIndex(Ice::Long feed) {
  TimeStat ts;
  Statement sql;
  sql << "SELECT * FROM " << getIndexTab(feed) << " WHERE " << COL_FEED
      << " = " << feed;
  mysqlpp::StoreQueryResult res = QueryRunner(DB_INSTANCE, CDbRServer,
      getIndexTab(feed)).store(sql);
  if (!res) {
		MCE_WARN("DbHelper::getFeedIndex --> query db fail ");
    return 0;
  }
	if(res.empty()){
		MCE_INFO("DbHelper::getFeedIndex --> res is empty");
		return 0;
	}
  FeedIndexPtr index = new FeedIndex;
  for (size_t i = 0; i < res.num_rows(); ++i) {
    mysqlpp::Row& row = res.at(i);
    index->feed = row[COL_FEED];
    index->newsMerge = row[COL_NEWS_MERGE];
    index->miniMerge = row[COL_MINI_MERGE];
    index->source = row[COL_SOURCE];
    index->psource = row[COL_PSOURCE];
    index->stype = row[COL_SMALLTYPE];
    index->ptype = row[COL_PTYPE];
    index->actor = row[COL_ACTOR];
    index->time = (time_t) mysqlpp::DateTime(row[COL_TIME]);
  }
  MCE_INFO("DbHelper::getFeedIndex --> cost:" << ts.getTime());
  return index;
}
Exemplo n.º 4
0
void DispatchTask::GetFocusSource(const FeedSeedPtr & seed,map<int,int> & rank){
	vector<int> sources;
	int actor = seed->actor;
	int stype = seed->type & 0xFFFF;
	long fid = seed->feed;
	int oldsz = rank.size();
	TimeStat ts;
	try{
		sources = FeedFocusInvertReplicaAdapter::instance().GetSources(actor);
		//sources = FeedFocusInvertAdapter::instance().GetSources(actor);
	} catch (Ice::Exception& e) {
		MCE_WARN("DispatchTask::GetFocusSource. actor:" << actor << " fid:" << fid << " stype:" << stype << " error:  "<< e);
		return;
	}catch(...){
		MCE_WARN("DispatchTask::GetFocusSource. actor:" << actor << " fid:" << fid << " stype:" << stype << " unknown error" );
		return;
	}
	BOOST_FOREACH(int source,sources){
		rank[source] = 100;
	}
	MCE_INFO("DispatchTask::GetFocusSource. actor:" << actor << " fid:" << fid << " stype:" << stype
			<< " sources:" << sources.size() << " oldrank:" << oldsz << " newranksize:" << rank.size()
			<< " cost:" << ts.getTime()
	);
}
Exemplo n.º 5
0
void MucTalkRoomManagerI::CreateRoom(const MucRoomIdPtr& roomid, const Ice::Current& current){
	TimeStat ts;
	RoomPoolPtr pool = GetPool(roomid);
	if(pool){
		pool->CreateRoom(roomid);
	}
	MCE_INFO("interface CreateRoom usetime : " << ts.getTime());
}
Exemplo n.º 6
0
void MucTalkRoomManagerI::RemoveRoomMember(int userid, const MucRoomIdPtr& roomid, const Ice::Current& current){
	TimeStat ts;
  RoomPoolPtr pool = GetPool(roomid);
  if(pool){
    pool->RemoveRoomMember(userid, roomid);
  }
	MCE_INFO("interface RemoveRoomMember usetime : " << ts.getTime());
}
Exemplo n.º 7
0
void MucOnlineManagerI::SetPermision(int opuser, Permisions permision, int targetuser, const MucRoomIdPtr& roomid, const Ice::Current& current) {
    TimeStat ts;
    RoomPoolPtr pool = GetPool(roomid);
    if(pool) {
        pool->SetPermision(opuser, permision, targetuser, roomid);
    }
    MCE_INFO("interface SetPermision usetime : " << ts.getTime());
}
Exemplo n.º 8
0
void MucOnlineManagerI::SendPrivateMsg(const JidPtr& sender, const MucUserIdentityPtr& recidentity, const string& msg, const Ice::Current& current) {
    TimeStat ts;
    RoomPoolPtr pool = GetPool(recidentity->roomid);
    if(pool) {
        pool->SendPrivateMsg(sender, recidentity, msg);
    }
    MCE_INFO("interface SendPrivateMsg usetime : " << ts.getTime());
}
Exemplo n.º 9
0
void MucOnlineManagerI::ChatSetingChange(int userid, const MucRoomIdPtr& roomid, int set, const Ice::Current& current) {
    TimeStat ts;
    RoomPoolPtr pool = GetPool(roomid);
    if(pool) {
        pool->ChatSetingChange(userid, roomid, set);
    }
    MCE_INFO("interface ChatSetingChange usetime : " << ts.getTime());
}
Exemplo n.º 10
0
void MucOnlineManagerI::UserOnline(const MucActiveUserPtr& activeuser, const Ice::Current& current) {
    TimeStat ts;
    RoomPoolPtr pool = GetPool(activeuser->identity->roomid);
    if(pool) {
        pool->UserOnline(activeuser);
    }
    MCE_INFO("interface UserOnline usetime : " << ts.getTime());
}
Exemplo n.º 11
0
void MucOnlineManagerI::AwayRoom(const JidPtr& opuser, const MucRoomIdPtr& roomid, const Ice::Current& current) {
    TimeStat ts;
    RoomPoolPtr pool = GetPool(roomid);
    if(pool) {
        pool->AwayRoom(opuser, roomid);
    }
    MCE_INFO("interface AwayRoom usetime : " << ts.getTime());
}
Exemplo n.º 12
0
void MucOnlineManagerI::SendTalkMessage(const JidPtr& opuser, const MucRoomIdPtr& roomid, const string& msg, const Ice::Current& current) {
    TimeStat ts;
    RoomPoolPtr pool = GetPool(roomid);
    if(pool) {
        pool->SendTalkMessage(opuser, roomid, msg);
    }
    MCE_INFO("interface SendTalkMessage usetime : " << ts.getTime());
}
Exemplo n.º 13
0
IntSeq MucTalkRoomManagerI::GetRoomMember(const MucRoomIdPtr& roomid , const Ice::Current& current){
	TimeStat ts;
	IntSeq ans;
  RoomPoolPtr pool = GetPool(roomid);
  if(pool){
    ans = pool->GetRoomMember(roomid);
  }
	MCE_INFO("interface GetRoomMember usetime : " << ts.getTime());
  return ans;
}
Exemplo n.º 14
0
JidSeq MucOnlineManagerI::GetActiveJids(const MucRoomIdPtr& roomid, const Ice::Current&) {
    TimeStat ts;
    JidSeq ans;
    RoomPoolPtr pool = GetPool(roomid);
    if(pool) {
        ans = pool->GetActiveJids(roomid);
    }
    MCE_INFO("interface GetActiveJids usetime : " << ts.getTime());
    return ans;
}
Exemplo n.º 15
0
void DispatchNManagerI::QuitChat(::Ice::Int uid, const GroupIndexSeq& groups,
    const ::Ice::Current&) {
	TimeStat ts;
  if (!enable_chat_) {
    MCE_INFO("DispatchNManagerI::QuitChat chat is already disabled,uid:"<< uid);
    return;
  }
  UgcChatController::instance().QuitChat(uid, groups);
	FunStatManager::instance().Stat("DispatchNManagerI::QuitChat", ts.getTime(), false);
}
Exemplo n.º 16
0
bool MucOnlineManagerI::SetPermisionForIM(int opuser, Permisions permision, int targetuser, const MucRoomIdPtr& roomid, const Ice::Current& current) {
    TimeStat ts;
    bool ans = false;
    RoomPoolPtr pool = GetPool(roomid);
    if(pool) {
        ans = pool->SetPermisionForIM(opuser, permision, targetuser, roomid);
    }
    MCE_INFO("interface SetPermisionForIM usetime : " << ts.getTime());
    return ans;
}
Exemplo n.º 17
0
void DispatchNManagerI::JoinChat(const vector<int> & uids, const GroupIndex& gindex,
    const ::Ice::Current&) {
	TimeStat ts;
  if (!enable_chat_) {
    MCE_INFO("DispatchNManagerI::QuitChat chat is already disabled,gindex " << PrintGroupIndex(gindex) << " uids:" << PrintHelper::Print(uids) );
    return;
  }
  UgcChatController::instance().JoinChat(uids, gindex);
  MCE_INFO("DispatchNManagerI::JoinChat: gindex " << PrintGroupIndex(gindex) << " uids:" << PrintHelper::Print(uids) );
	FunStatManager::instance().Stat("DispatchNManagerI::JoinChat", ts.getTime(), false);
}
Exemplo n.º 18
0
void MucOnlineManagerI::UserOnlineBySeq(const MucActiveUserSeq& onlineuserseq, const Ice::Current& current) {
    TimeStat ts;
    MucActiveUserSeq::const_iterator it = onlineuserseq.begin();
    for(; it != onlineuserseq.end(); ++it) {
        MucActiveUserPtr activeuser = (*it);
        RoomPoolPtr pool = GetPool(activeuser->identity->roomid);
        if(pool) {
            pool->UserOnline(activeuser);
        }
    }
    MCE_INFO("interface UserOnlineBySeq usetime : " << ts.getTime());
}
Exemplo n.º 19
0
FeedDataResPtr FeedItemManagerI::GetFeedDataImpl(int uid, const IntSeq& types,
    bool stype, int begin, int limit, bool hot) {
	FeedDataResPtr res = new FeedDataRes;

	try{
	TimeStat ts; GetCost tc;
	GetRequest req(uid,types,stype,begin,limit,hot);
	if(!req.CheckArgs()) return res;

	UserInfoPtr uinfo = LocateUserInfo(uid);

	if(!uinfo) return res;
	tc.loadtime = ts.Get();

	uinfo->GetFeeds(req);

	tc.mergetime = ts.Get();

	FeedContentDict fdict;
	GetFeedContentDict(req,fdict);
//	tc.contenttime = ts.Get();
//
	FeedBuilder builder(uid,fdict,req.showed_comment_map_,req.sort_);
	res = builder.BuildFeedData(req);
//	tc.buildtime = ts.Get();
//
	uinfo->SetMaxRead(req.GetMaxFid());
	uinfo->SetReadByIdsExactly(builder.GetNullFids());
//	tc.othertime = ts.Get();
//
	uinfo->UploadMaxRead();
//	uinfo->RefreshPreMaxRead();
//	uinfo->AddRefresh(req.GetNowTime(),req.GetMaxFid());
//
//
	MCE_INFO("FeedItemManagerI::GetFeedDataImpl --> uid:" << uid << " begin:" << begin << " limit:" << limit
			<< " types:" << types.size() << " bystype:" << stype << " hot:" << hot << " feedsize:" << uinfo->Size()
//			<< " res:" << builder.GetSucc()
			<< tc.ToString()
			<< " fdict:" << fdict.size()
			<< " nullfids:" << PrintHelper::Print(builder.GetNullFids())
			<< " types:" << PrintHelper::Print(types)
			<< " mark_fids:" << PrintHelper::Print(req.GetMarkedFids())
	);

	return res;

	} catch(Ice::Exception& e) {
		MCE_WARN(" FeedItemManagerI::GetFeedDataImpl uid:" << uid
				<<" error:" << e);
		return res;
	}
}
Exemplo n.º 20
0
bool HashDB::get(BlockDBKey key, BlockData& blk) {
    TimeStat t;
    int size = 0;
    void* res = tchdbget(_db, &key, sizeof(BlockDBKey), &size);
    if(!res) {
        return false;
    }
    blk = *((BlockData*)res);
    free(res);
    PerformanceStat::instance().stat("HashDBGet", t.getTime());
    return true;
}
Exemplo n.º 21
0
MucActiveUserSeq MucTalkRoomManagerI::GetRoomActiveUserSeq(const MucRoomIdPtr& roomid, const Ice::Current& current){
	TimeStat ts;
	MucActiveUserSeq ans;
	MCE_DEBUG("MucTalkRoomManagerI::GetRoomActiveUserSeq --> roomname = " << roomid->roomname);
  RoomPoolPtr pool = GetPool(roomid);
  if(pool){
		MCE_DEBUG("MucTalkRoomManagerI::GetRoomActiveUserSeq --> has pool ");
    ans = pool->GetRoomActiveUserSeq(roomid);
  }
	MCE_INFO("interface GetRoomActiveUserSeq usetime : " << ts.getTime());
  return ans;
}
Exemplo n.º 22
0
bool DefaultHandler::handle(MatchHandlerParamter& para, AdResultMap& result) {
  MCE_DEBUG("[MAIN_PROCESS] DefaultHandler::handle ==>NO DEFAULT  line:"<<__LINE__<<",uid " << para.userProfile_.id()<<",adzone:"<< para.adzone_->id()<<",pick_count:"<< para.PickCount())
  TimeStat ts;
  if(100000000075 == para.adzone_->id()) {
    return true;
  }

  if((100000000070 == para.adzone_->id() || 100000000072 == para.adzone_->id()) && para.is_selected_vip_) {
   // para.is_selected_vip_ = false;
    return true;
  }
  if (para.PickCount() > 0) {
    set<AdGroupPtr> default_groups;
    /*if(100000000072 != para.adzone_->id() && 100000000070 != para.adzone_->id()
      && 100000000063 != para.adzone_->id() && 100000000001 != para.adzone_->id()) {
      AdZonePtr adzone = AdZonePool::instance().GetAdZone(100000000072);
   //   MCE_DEBUG("[MAIN_PROCESS] DefaultHandler::handle ==>NO DEFAULT  line:"<<__LINE__<<",adzone:" << adzone->id())
      if(adzone) {
        default_groups = adzone->GetDefaultGroups(para.PickCount());
    //    MCE_DEBUG("[MAIN_PROCESS] DefaultHandler::handle ==>NO DEFAULT  line:"<<__LINE__)
      }
    } else {
      default_groups = para.adzone_->GetDefaultGroups(para.PickCount());
     // MCE_DEBUG("[MAIN_PROCESS] DefaultHandler::handle ==>NO DEFAULT  line:"<<__LINE__)
    }*/
    /*if(100000000072 == para.adzone_->id() || 100000000070 == para.adzone_->id()
      || 100000000063 == para.adzone_->id() || 100000000001 == para.adzone_->id()) {
      default_groups = para.adzone_->GetDefaultGroups(para.PickCount());
    }*/
    default_groups = para.adzone_->GetDefaultGroups(para.PickCount());
    if (default_groups.empty()) {
      MCE_INFO("[MAIN_PROCESS] DefaultHandler::handle ==>NO DEFAULT ads  is got, needed ad count = "
          << para.PickCount());
    } else {
      MCE_INFO("[MAIN_PROCESS] DefaultHandler::handle ==>Get DEFAULT ad from AdZone : get default_groups.size() = "
          << default_groups.size() << ", needed ad count = " << para.PickCount());
    }

    for(set<AdGroupPtr>::iterator it = default_groups.begin(); it != default_groups.end(); ++it) {
      SelectedAdGroupPtr p = new SelectedAdGroup(*it);
      p->pos_ = para.zone_selected_groups_.size() + 1;  //cost = 0
      para.zone_selected_groups_.insert(p);
      para.total_selected_groups_.insert(p);
    }

//    para.zone_selected_groups_.insert(default_groups.begin(), default_groups.end());
//    para.total_selected_groups_.insert(default_groups.begin(), default_groups.end());
  }

  STATISTICS("DefaultHandler::handle --> time = " << ts.getTime());
  return true;
}
Exemplo n.º 23
0
MucActiveUserSeq MucOnlineManagerI::GetUserByPermision(const MucRoomIdPtr& roomid, Permisions permision, const Ice::Current& current) {
    TimeStat ts;
    MucActiveUserSeq ans;
    if(None == permision) {
        return ans;
    }
    RoomPoolPtr pool = GetPool(roomid);
    if(pool) {
        pool->GetUserByPermision(roomid, permision);
    }
    MCE_INFO("interface GetUserByPermision usetime : " << ts.getTime());
    return ans;
}
Exemplo n.º 24
0
// 调整广告展示位置
bool PosAdjustHandler::handle(MatchHandlerParamter& para, AdResultMap& result) {
  TimeStat ts;
  // 调整广告展示的位置
  vector<SelectedAdGroupPtr> zone_selected(para.zone_selected_groups_.begin(), para.zone_selected_groups_.end());
  MCE_DEBUG("ads num " <<  zone_selected.size());
  /*  if(para.adzone_->id() == 100000000001) {
      Adjust(zone_selected, para.zone_selected_groups_);
    } else if ((para.adzone_->id() == 100000000063) && para.has_re_) {
      AdjustForInner(zone_selected, para.zone_selected_groups_);
    }*/
   //调整后的
  para.final_selected_groups_.swap(zone_selected);
  STATISTICS("PosAdjustHandler::handle --> time = " << ts.getTime());
  return true;
}
Exemplo n.º 25
0
bool HashDB::flushDataNode(const map<int, DataNode>& nodes) {
    if(nodes.empty()) {
        return false;
    }
    TimeStat t;
    static DataNode data[DataNodeManager::MAX_DATANODE];
    map<int, DataNode>::const_iterator it = nodes.begin();
    for(int i=0; it!=nodes.end(); i++, ++it) {
        *(data+i) = it->second;
    }
    int key = 0;
    bool suc = tchdbput(_db, &key, sizeof(int), data, nodes.size()*sizeof(DataNode));
    PerformanceStat::instance().stat("HashDBPut", t.getTime());
    return suc;
}
Exemplo n.º 26
0
map<string, string> DbHelper::getFeedConfigProp(Ice::Long fid) {
  TimeStat ts;
  map<string, string> prop;
  Statement sql;
  sql << "SELECT prop FROM " << DbHelper::instance().getContentTab(fid)
      << " WHERE feed=" << fid;
  mysqlpp::StoreQueryResult res = QueryRunner(DB_INSTANCE, CDbRServer,
      getContentTab(fid)).store(sql);
  string propStr;
  if (!res || res.num_rows()==0) {
    MCE_WARN("DbHelper::getFeedConfigProp --> load from db null, fid:" << fid);
    return prop;
  }
  for (size_t i = 0; i < res.num_rows(); ++i) {
    mysqlpp::Row row = res.at(i);
    propStr = row["prop"].data();
    size_t pos = 0;
    string::size_type idx;
    string key;
    string val;

    while (pos < propStr.size()) {

      idx = propStr.find('=', pos);
      if (idx == string::npos) {
        return prop;
      }

      key = propStr.substr(pos, idx - pos);
      pos = idx + 1;
      idx = propStr.find(',', pos);
      if (idx == string::npos) {
        return prop;
      }

      val = propStr.substr(pos, idx - pos);
      pos = idx + 1;

      prop[key] = val;

    }

    return prop;
  }
  MCE_INFO("DbHelper::getFeedConfigProp --> cost:" << ts.getTime());
  return prop;

}
Exemplo n.º 27
0
void IndexLoader::SqlExecuteTask::handle() {
  MCE_INFO("IndexLoader --> SqlExecuteTask  instance:" << _dbInstance << " _pattern:" << _pattern);
  TimeStat ts;
  if (_isSelect) {
    mysqlpp::StoreQueryResult res;
    try{
      res = QueryRunner(_dbInstance, CDbRServer, _pattern).store(_sql);
    }catch(std::exception& e){
      MCE_WARN("IndexLoader::SqlExecuteTask --> err, " << e.what() << " " << _dbInstance << " _pattern:" << _pattern);
    }
    if (!res) {
      MCE_WARN("IndexLoader::SqlExecuteTask::handle --> query return null"<< " " << _dbInstance << " _pattern:" << _pattern);
      return;
    } else {
      MCE_INFO("IndexLoader::SqlExecuteTask::handle -->1 cost:" << ts.getTime() << " rows:" << res.num_rows()<< " " << _dbInstance << " _pattern:" << _pattern);
    }
    //MCE_INFO("IndexLoader::SqlExecuteTask::handle -->1 cost:" << ts.getTime() << " rows:" << res.num_rows() << " expr:" << _pattern);
    FeedIndexSeq seq;
    for (size_t i = 0; i < res.num_rows(); ++i) {
      mysqlpp::Row row = res.at(i);

      FeedIndexPtr index = new FeedIndex;
      index->feed = row[COL_FEED];
      index->newsMerge = row[COL_NEWS_MERGE];
      index->miniMerge = row[COL_MINI_MERGE];
      index->source = row[COL_SOURCE];
      index->psource = row[COL_PSOURCE];
      index->stype = row[COL_SMALLTYPE];
      index->ptype = row[COL_PTYPE];
      index->actor = row[COL_ACTOR];
      index->time = (time_t) mysqlpp::DateTime(row[COL_TIME]);
      seq.push_back(index);

    }
    _loader->finish(seq);

  } 
//  else {
//    try{
//      QueryRunner(_dbInstance, CDbWServer, _pattern).store(_sql);
//    }catch(std::exception& e){
//      MCE_WARN("IndexLoader::SqlExecuteTask --> err, " << e.what());
//    }
//    _loader->finish();
//  }
  //MCE_INFO("IndexLoader::SqlExecuteTask::handle  --> cost:" << ts.getTime());
}
Exemplo n.º 28
0
bool StyleHandler::handle(MatchHandlerParamter& para, AdResultMap& result) {
  if((100000000070 == para.adzone_->id() || 100000000072 == para.adzone_->id()) && para.is_selected_vip_) {
    para.is_selected_vip_ = false;
    return true;
  }
  TimeStat ts;
  MCE_DEBUG("StyleHandler::handle() --> user_id = " << para.userProfile_.id()
            << ", adzone_id = " << para.adzone_->id()
            << ", para.final_selected_groups_.size() = " << para.final_selected_groups_.size());
  AdStylePtr style = para.style_;
  if( style ){
    MCE_DEBUG("style replace with styleId=" << style->style_id());
	  int abs_pos = 0;
	    vector<int> bigs = style->big_widgets();
	    vector<int> smalls = style->small_widgets();
	    for(vector<SelectedAdGroupPtr>::iterator sit = para.final_selected_groups_.begin();
	        sit != para.final_selected_groups_.end(); ++sit, ++abs_pos){
	    	AdGroupPtr group_ptr = (*sit)->group_;
        if(group_ptr->member_id() == 999) {
          continue;
        }
        int widget_id = 0;
	    	map<Ice::Long, Ice::Long> creative2widget = group_ptr->creative2widget();
        if(!creative2widget.empty()) {
          (*sit)->selected_creative_id_ = creative2widget.begin()->first;
          widget_id = creative2widget.begin()->second;
        }
	    	int newId = 0;
	    	if( StyleHandler::isBig(widget_id) ){
	    		if( abs_pos < bigs.size() && bigs[abs_pos] > 0 )
	    		  newId = bigs[abs_pos];
	    	}else{
	    		if( abs_pos < smalls.size() && smalls[abs_pos] > 0)
	    		  newId = smalls[abs_pos];
	    	}
        MCE_DEBUG("adgroup_id " << group_ptr->group_id() << " widget replace: " << widget_id <<" --> " << newId);
	    	if( newId != 0 ){
          (*sit)->selected_widget_id_ = newId;
          (*sit)->extra_ = "style_test";
        }
	    }
  }
  STATISTICS("StyleHandler::handle --> time = " << ts.getTime());
  return true;
}
Exemplo n.º 29
0
void AdMatchManagerI::Init(){
  TimeStat ts;
  MCE_INFO("AdMatchManagerI::Init --> begin init :" << Date(time(NULL)).toDateTime());
  AdMemberPool::instance().Init();
  MCE_INFO("AdMatchManagerI::Init --> AdMemberPool::instance().Init(); DONE");
  AdCampaignPool::instance().Init();
  MCE_INFO("AdMatchManagerI::Init -->  AdCampaignPool::instance().Init(); DONE");
  AdGroupPool::instance().Init();
  MCE_INFO("AdMatchManagerI::Init -->  AdGroupPool::instance().Init(); DONE");
  AdZonePool::instance().Init();
  MCE_INFO("AdMatchManagerI::Init -->  AdZonePool::instance().Init(); DONE");
  MCE_INFO("AdMatchManagerI::Init -->  AdStyleDispatcher::instance().Init(); START");
  AdStyleDispatcher::instance().Init();
  MCE_INFO("AdMatchManagerI::Init -->  AdStyleDispatcher::instance().Init(); DONE");
  CompeteRef::instance().Init();
  MCE_INFO("AdMatchManagerI::Init -->  CompeteRef::instance().Init(); DONE");
  STATISTICS("AdMatchNManagerI::Init -->  TIME_TEST ALL END  time = " << ts.getTime());
}
Exemplo n.º 30
0
/* brief : 利用fcgi,调用PageCache获取数据
 *
 */
bool PageCacheRequest::response() {
  if (!_fcgi_out) {
    MCE_WARN("_fcgi_out null");
    return false;
  }
  
  if(!Request::response()) {
    FCGX_FPrintF(_fcgi_out, "Content-type: text/html\r\n\r\nverify failure");
    return false;
  }
  if (strncmp(_path.c_str(), "/wpi/", 5) == 0) {
    _path = _path.substr(4);
  }

  // UserPagePtr user_pages = ServiceI::instance().locateObject<UserPagePtr>(kUserPageCacheIndex, _login_uid);
  // ContentPtr body = user_pages->body(_login_uid, _path, _cookies, _props);
  ContentPtr body;
	TimeStat ts;
  try {
    body = PageCacheAdapter::instance().GetContent(_login_uid, _path, _cookies, _props);
  } catch(Ice::Exception& e) {
    MCE_WARN("PageCacheRequest::response-->user " << _login_uid << " get PageCacheAdapter err:" << e);
  }
	MONITOR("SignForTimeuse::PageCacheRequest::response-->PageCache::GetContent-->" << ts.getTime());
	FunStatManager::instance().Stat("PageCache.GetContent", ts.getTime(), (ts.getTime() >= 250.0));	
  FunStatManager::instance().Stat(_path, ts.getTime(), (ts.getTime() >= 250.0));
  stringstream res;

  if (body) {
    MCE_DEBUG("status : " << body->statusCode);
    MCE_DEBUG("content type : " << body->contentType);
    MCE_DEBUG("body : " << body->data);
    MCE_DEBUG("timeout : " << body->timeout);

    res << "HTTP/1.1 "<< body->statusCode << " " << GetReasonPhrase(body->statusCode) << "\r\n"
        << "Content-type: " << body->contentType << "\r\n";

    if (body->timeout > 0 && body->statusCode == 200) {
      res << "Cache-Control: max-age="<< body->timeout << "\r\n"
          << "Expires: "<< GmtTime(time(NULL) + body->timeout) << "\r\n";
    } else {
      res << "Cache-Control: no-cache"<< "\r\n"
          << "Expires: Thu, 01 Jan 1970 00:00:00 GMT"<< "\r\n";
    }
    res << "\r\n" << body->data;
  } else {
    res << "HTTP/1.1 500 UpstreamTimeout\r\n" << "Content-type: text/html\r\n\r\n";
  }

  FCGX_PutS(res.str().c_str(), _fcgi_out);
  FunStatManager::instance().Stat("PageCacheRequest::response", ts.getTime(), (ts.getTime() >= 250.0));
  return true;
}