Пример #1
0
void LogHelper::CookieEmptyCheck(UserProfile& upf){
  int userid = upf.id();
  if(!upf.id()){
    upf.set_id(888);
  }
  if(upf.age() > 100 || upf.age() < 15){
    upf.set_age(20 + AdMatchManagerI::instance().ServerIndex());
  }
  if(upf.ip_area().empty() || "0000000000000000" == upf.ip_area()){
    upf.set_ip_area("0086110000000000");
  }
  if(!upf.stage()){
    upf.set_stage(4);
  }
  if(!upf.ip()){
    upf.set_ip(975044608);
  }
  if(upf.current_area().empty()){
    upf.set_current_area("0086110000000000");
  }


  ///////////////////////////
  //if(!upf.home_area().empty()) {
  //  upf.set_ip_area(upf.home_area()); //for test only
  //}
  ///////////////////////////
}
Пример #2
0
int TriggerInterface::trigger(const UserProfile &profile, std::vector<long> &zones, GroupDict& groups)
{
	TriggerInputInfo input;
	input.age = profile.age();
	input.gender = profile.gender();
	input.stage = profile.stage();
	input.grade = profile.grade();
	input.uid = profile.id();
	stringstream ss;
	ss << profile.school();
	input.school = ss.str();

	input.ipArea = profile.ip_area();
	input.currentArea = profile.current_area();
	input.company = profile.work_place();
	input.zones = zones;

  PingStat stat;
	try
	{
		int ret = IndexServiceReplicaAdapter::instance().trigger(input, groups);
		return ret;
	}
	catch (Ice::Exception& e) 
	{
		MCE_WARN("IndexServiceReplicaAdapter trigger caught ICEexception: " << e << " ,uid: " << input.uid);
		return -1;
	}
	catch (std::exception& e) 
	{
		MCE_WARN("IndexServiceReplicaAdapter trigger caught STDexception: " << e.what() << " ,uid: " << input.uid);
		return -1;
	}

}
Пример #3
0
pair<double,int> UserDemographicCache::GetUserAdGroupsCtr(const UserProfile & user_profile, Ice::Long zone_id,int pos_id, Ice::Long group_id, Ice::Long sponsor_id,string app_name) {
    //get stage gender
    //Ice::Long group_id = group_ptr->group_id();
    //Ice::Long sponsor_id = group_ptr->member_id();
    int gender = user_profile.gender();
    int stage = user_profile.stage();
    int uid = user_profile.id();

    stringstream zone_name;
    zone_name.str("");
    if (zone_id == 100000000001 && app_name.size() > 0) {
        zone_name << app_name;
    } else {
        zone_name << zone_id;
    }
    pair <double ,int> res = GetDemoCtr(zone_name.str(),sponsor_id, group_id , pos_id ,  gender, stage, uid);
    //当zone_id == 100000000001 且 res.second == 3 时表示没有此app数据,此时回退到01位置的人口学
    if (zone_id == 100000000001 && res.second == 3 && app_name.size() > 0) {
        zone_name.str("");
        zone_name << zone_id;
        res = GetDemoCtr(zone_name.str(),sponsor_id, group_id , pos_id ,  gender, stage, uid);
    } else if (zone_id == 100000000001 && res.second >= 0 && res.second != 3 && app_name.size() > 0) {
        res.second += 1000;
    }


    //pair <double ,int> res = GetDemoCtr(zone_id,sponsor_id, group_id , pos_id ,  gender, stage, uid);
    //group_ptr->SetDemoState(res.second);
    //MCE_DEBUG("3Us::GetUserAdGroupsCtr:zone_id:" << zone_id <<",pos_id:" << pos_id <<",state:" << group_ptr->GetDemoState()<< ",uid:" << user_profile.id() <<"groupid:" << group_id);
    return res;
}
Пример #4
0
FeedContentPtr FeedMemcContentI::GetFeed(Ice::Long id, const Ice::Current&) {
  // for UserProfileClient test only
  vector<Ice::Long> feedids;
  feedids.push_back(8373921129);
  FeedContentDict dict = FeedMemcClient::instance().GetFeedDict(feedids);
  FeedContentPtr content;
  content = dict[8373921129];
  content->data->xml = "<f v=\"1.0\" type=\"blogPublish\"><time>1300185966866</time><type>601</type><from><id>257876975</id><name>远非</name><tinyimg>0/0/men_tiny.gif</tinyimg></from><blog><id>716684593</id><title>ooxxxwwoo</title><digest>&amp;#23002;&amp;#23452;&amp;#19996;&amp;#20998;&amp;#20139;&amp;#26446;&amp;#22025;&amp;#27427;&amp;#30340;&amp;#26085;&amp;#24535;&amp;#36716;&amp;#65306;&amp;#20854;&amp;#23454;&amp;#22823;&amp;#23478;&amp;#37117;&amp;#34987;&amp;#26085;&amp;#26412;&amp;#22320;&amp;#38663;&amp;#21560;&amp;#24341;&amp;#20102;&amp;#30524;&amp;#29699; &amp;#30495;&amp;#27491;&amp;#26368;&amp;#21361;&amp;#38505;&amp;#30340;&amp;#26159;&amp;#21152;&amp;#24030; &amp;#65288;&amp;#20197;&amp;#19979;&amp;#20026;&amp;#36716;&amp;#36733;&amp;#65289;&amp;#26085;&amp;#26412;&amp;#36825;&amp;#27425;&amp;#29378;&amp;#26292;&amp;#30340;&amp;#22320;&amp;#38663;&amp;#30495;&amp;#30340;&amp;#21560;&amp;#24341;&amp;#20102;&amp;#22823;&amp;#23478;&amp;#30340;&amp;#30524;&amp;#29699;&amp;#65292;&amp;#25105;&amp;#22269;&amp;#30005;&amp;#35270;&amp;#21488;&amp;#26356;&amp;#26159;&amp;#36830;&amp;#31687;&amp;#32047;&amp;#29261;&amp;#30340;&amp;#25253;&amp;#36947;&amp;#20197;&amp;#26399;&amp;#36716;&amp;#31227;&amp;#22823;&amp;#23478;&amp;#23545;&amp;#22269;&amp;#20869;&amp;#29616;&amp;#29366;&amp;#30340;&amp;#19981;&amp;#28385;&amp;#12290;&amp;#20854;&amp;#23454;&amp;#65292;&amp;#22823;&amp;#23478;&amp;#38590;&amp;#36947;&amp;#24536;&amp;#35760;&amp;#20102;&amp;#32654;&amp;#22269;&amp;#21152;&amp;#24030;&amp;#37027;&amp;#22855;&amp;#24618;&amp;#27515;&amp;#20129;&amp;#30340;500&amp;#19975;&amp;#26465;&amp;#40060;&amp;#20102;&amp;#21527;&amp;#65311;&amp;#25105;&amp;#35748;&amp;#20026;&amp;#19981;&amp;#36229;&amp;#36807;&amp;#19968;&amp;#20010;&amp;#26376;&amp;#65292;&amp;#21152;&amp;#24030;&amp;#23558;&amp;#21457;&amp;#29983;&amp;#24046;&amp;#19981;&amp;#22810;9&amp;#32423;&amp;#30340;&amp;#22320;&amp;#38663;&amp;#12290;&amp;#20026;&amp;#37027;&amp;#20123;&amp;#21363;&amp;#23558;&amp;#32633;&amp;#38590;&amp;#30340;&amp;#20154;&amp;#31048;&amp;#31095;&amp;#21543;&amp;#65281;&amp;#65281;&amp;#65281;&amp;#65281; &amp;#27425;&amp;#22768;&amp;#27874;&amp;#12290;&amp;#12290;&amp;#12290;&amp;#36807;&amp;#24378;&amp;#30340;&amp;#27425;&amp;#22768;&amp;#27874;...</digest><url>http://blog.renren.com/GetEntry.do?id=716684593&amp;owner=257876975</url></blog></f>"; 
  content->reply->oldReply = "<f><reply><id>1692426042</id><type>0</type><time>2011-03-15 18:51</time><body>&quot;test1&quot;</body><im><body>test1</body></im><from><id>238489851</id><name>袁飞</name><tinyimg>http://hdn.xnimg.cn/photos/hdn221/20110220/1735/tiny_2kcu_195010p019116.jpg</tinyimg><icon></icon></from></reply></f>";
  content->reply->newReply = "<f><reply><id>1692426042</id><type>0</type><time>2011-03-15 18:51</time><body>&quot;test2&quot;</body><im><body>test2</body></im><from><id>238489851</id><name>袁飞</name><tinyimg>http://hdn.xnimg.cn/photos/hdn221/20110220/1735/tiny_2kcu_195010p019116.jpg</tinyimg><icon></icon></from></reply></f>";
  FeedMemcClient::instance().SetFeed(content);
  return NULL; 
  UserProfile profile;
  MCE_INFO("get profile : " << id );
  bool b = UserProfileClient::instance().Get(id, &profile);
  if (b) {
  MCE_INFO("profile fields : " 
      << " id " << profile.id()
      << " stage " << profile.stage()
      << " gender " << profile.gender()
      << " age " << profile.age()
      << " school " << profile.school()
      << " major " << profile.major()
      << " grade " << profile.grade()
      << " home_area " << profile.home_area() << "@" << profile.home_area().size()
      << " current_area " << profile.current_area() << "@" << profile.current_area().size()
      << " ip " << profile.ip()
      << " ip_area " << profile.ip_area() << "@" << profile.ip_area().size() );
  } else {
    MCE_INFO("profile not found. id=" << id); 
  }

  return FeedMemcClient::instance().GetFeed(id);
};
Пример #5
0
bool UserProfileClient::Set(const UserProfile & o) {
  char key[32];
  GetUserKey(o.id(), key, 32);
   
  const UserProfile & profile = o;

  string value;
  o.SerializeToString(&value);

  return SetMemcached(key, value, 0);
}
AdResultMap AdEngineBReplicaAdapter::GetAds(const string & user_profile, const string & referer, int rotate_index, bool hide) {
  Ice::Context ctx;
  if(hide) {
    ctx["hide"] = "true";
  } else {
    ctx["hide"] = "false";
  }
  UserProfile profile;
  UserProfileClient::instance().Deserialize(user_profile, &profile);
  return getManager(GetServerIndex(profile.id()))->GetAds(user_profile, referer, rotate_index, ctx);
  // return getManager(profile.id() / 10 % 10)->GetAds(user_profile, referer, rotate_index);
}
Пример #7
0
void CookieEmptyCheck(UserProfile& upf) {
  MCE_DEBUG("id=" << upf.id() << ",iparea=" << upf.ip_area() << ",stage=" << upf.stage() << ",current_area=" << upf.current_area());
  if (!upf.id()) {
    upf.set_id(0);
  }
  if (upf.ip_area().empty() || "0000000000000000" == upf.ip_area()) {
    upf.set_ip_area("0086110000000000"); // 北京
  }
  if (!upf.stage()) {
    upf.set_stage(4);
  }
  if (!upf.ip()) {
    upf.set_ip(975044608); // 北京的一个随机IP
  }
  if (upf.current_area().empty()) {
    upf.set_current_area("0086110000000000"); // 北京
  }
  //测试代码,设置ip 10.2.17.35 (彭贺庭)和10.2.19.216(邢永涛)为国外
  /*if (upf.ip() == (10*256*256*256+2*256*256+17*256+35) || upf.ip() == (10*256*256*256+2*256*256+19*256+216)) {
    MCE_DEBUG("10.2.17.35 set to 0087110000000000, uid = " << upf.id());
    upf.set_current_area("0087110000000000");
    upf.set_ip_area("0087110000000000"); // 北京
  }*/
}
Пример #8
0
void CookieEmptyCheck(UserProfile& upf) {
  if (!upf.id()) {
    upf.set_id(8);
  }
  if (upf.ip_area().empty() || "0000000000000000" == upf.ip_area()) {
    upf.set_ip_area("0086110000000000"); // 北京
  }
  if (!upf.stage()) {
    upf.set_stage(4);
  }
  if (!upf.ip()) {
    upf.set_ip(975044608); // 北京的一个随机IP
  }
  if (upf.current_area().empty()) {
    upf.set_current_area("0086110000000000"); // 北京
  }
}
Пример #9
0
string LogHelper::MakeUbc(const UserProfile& upf){
  ostringstream ubc_ios;

  int birth_year = Date(time(NULL)).year() - upf.age();
  int user_stage = upf.stage();
  string valid_area = "";
  if(4 == user_stage){
    valid_area = upf.ip_area();
  }
  else{
    valid_area = upf.current_area();
  }
  if (valid_area.empty()) {
    valid_area = "-";
  }
  string current_area = (upf.current_area().empty()) ? "-" : upf.current_area();
  string ip_area = (upf.ip_area().empty()) ? "-" : upf.ip_area();

  ubc_ios << "1000000_" << upf.id() << "|" << upf.gender() << "|" << birth_year
      << "-01-01" << "|" << upf.age() << "|" << upf.stage() << "|" << valid_area << "|"
      << upf.school() << "_" << current_area << "|" << upf.grade() << "|0|0|" << ip_area;
  return ubc_ios.str();
}
Пример #10
0
FeedContentPtr MemcFeedTestI::GetFeed(Ice::Long id, const Ice::Current&) {
  // for UserProfileClient test only
  UserProfile profile;
  MCE_INFO("get profile : " << id );
  bool b = UserProfileClient::instance().Get(id, &profile);
  if (b) {
  MCE_INFO("profile fields : " 
      << " id " << profile.id()
      << " stage " << profile.stage()
      << " gender " << profile.gender()
      << " age " << profile.age()
      << " school " << profile.school()
      << " major " << profile.major()
      << " grade " << profile.grade()
      << " home_area " << profile.home_area() << "@" << profile.home_area().size()
      << " current_area " << profile.current_area() << "@" << profile.current_area().size()
      << " ip " << profile.ip()
      << " ip_area " << profile.ip_area() << "@" << profile.ip_area().size() );
  } else {
    MCE_INFO("profile not found. id=" << id); 
  }

  return FeedMemcClient::instance().GetFeed(id);
};
Пример #11
0
bool AdNewGetRequest::response() {
  timeval start;
  gettimeofday(&start, NULL);
  if (!_fcgi_out) {
    MCE_WARN("remove notify fcgi_out null");
    return false;
  }

  _login_uid = 2;
  string uid = getProperty("uid");
  if (_cookies.find("id") != _cookies.end()) {
    uid = _cookies["id"];
  }
  if (!uid.empty()) {
    try {
      _login_uid = boost::lexical_cast<int>(uid);
    } catch (...) {
      MCE_WARN("lexical_cast cookie id error : " << uid);
    }
  }

  string serialized;
  if (_login_uid > 0) {
    bool b = false;
    try {
      StatFunc stat("memc GetSerialized");
      b = UserProfileClient::instance().GetSerialized(_login_uid, &serialized);
    } catch (std::exception& e) {
      MCE_WARN("UserProfileClient error : " << e.what() << " uid="
          << _login_uid);
    }

    if (!b) {
      MCE_INFO("profile not found in memcache. id=" << _login_uid);
      try {
        StatFunc stat("memc AdUserCacheLoader");
        serialized = AdUserCacheLoaderAdapter::instance().GetById(_login_uid);
      } catch (Ice::Exception& e) {
        MCE_WARN("AdUserCacheLoaderAdapter GetById error : " << e << " uid="
            << _login_uid);
      } catch (std::exception& e) {
        MCE_WARN("AdUserCacheLoaderAdapter GetById error : " << e.what()
            << " uid=" << _login_uid);
      }
    }
  }
  // FCGX_PutS("Content-type: application/x-javascript; charset=utf-8\r\n\r\n{}", _fcgi_out);
  // return true;

  UserProfile profile;
  if (serialized.empty()) {
    profile.set_stage(4);
    profile.set_gender(0);
    profile.set_age(25);
    profile.set_school(0);
    profile.set_major(0);
    profile.set_grade(0);
    profile.set_home_area("");
    profile.set_current_area("");
  } else {
    profile.ParseFromString(serialized);
  }

  unsigned int ip = ntohl(inet_addr(GetRemoteAddr().c_str()));

  profile.set_id(_login_uid);
  profile.set_ip(ip);
  profile.set_ip_area(IpAreaCache::instance().GetIpArea(ip));
  profile.SerializeToString(&serialized);

  int rotate_slot = GetCookieInt("an_slot", rand());
  rotate_slot %= 10000;

  AdResultMap ads;
  AdZone2Creatives final_ads;
  string referer = getProperty("ref");
  //MCE_DEBUG("[UrlMaping] ref = " << referer);
  if (referer.empty() || referer.find("http://") == string::npos) {
    referer = getProperty("r");
    if (referer.empty() || referer.find("http://") == string::npos) {
    referer = GetParamFix("HTTP_REFERER");
      //MCE_DEBUG("[UrlMaping] HTTP_REFERER = " << referer);
    }
  }

  bool err_flag = false;

  bool hide = false;
  string isvip = getProperty("isvip");
  string hideads = getProperty("hideads");
  if(isvip.compare("true")==0 && hideads.compare("true")==0) {
    hide = true;
  }

  stringstream log_url;
  try {
    char sep = '&';
    if (referer.find_first_of('?') == string::npos) {
      sep = '?';
    }
    int refresh_source = getPropertyInt("refresh_source", 0);
    int refresh_idx = getPropertyInt("refresh_idx", 0);
    log_url << referer << sep << "refresh_source=" << refresh_source
        << "&refresh_idx=" << refresh_idx;
    
    stringstream stat_desc;
    stat_desc << _login_uid << " GetAds";
    StatFunc stat(stat_desc.str());
  } catch (Ice::Exception& e) {
    MCE_WARN("AdGetRequest::response error : " << e << " uid=" << _login_uid);
    err_flag = true;
  } catch (std::exception& e) {
    MCE_WARN("AdGetRequest::response : " << e.what() << " uid=" << _login_uid);
    err_flag = true;
  }

//  string emtag = "M";

      MCE_DEBUG("debug 001");
  try {
    ads = AdEngineBAdapter::instance().GetAds(serialized, log_url.str(),
        rotate_slot, hide);
    MCE_DEBUG("EngineB size=" << ads.size());
    AdGateI::instance().translate(ads,final_ads);
    MCE_DEBUG("EngineB size=" << final_ads.size());
//    emtag = "M";
  } catch (Ice::Exception& e) {
    MCE_WARN("AdEngineBAdapter::GetAds error : " << e << " uid=" << _login_uid);
    err_flag = true;
  } catch (std::exception& e) {
    MCE_WARN("AdEngineBAdapter::GetAds error : " << e.what() << " uid="
        << _login_uid);
    err_flag = true;
  }

      MCE_DEBUG("debug 002");
  bool tw_flag = false;
  string tag, photo;
  map<long, EngineTypes> self_zones; // 需要中小自助广告广告位id
  for(AdResultMap::iterator it =  ads.begin(); it != ads.end(); it++) {
    if(!it->second.empty() && (it->second.at(0).groupid == -1)) {
      //台湾分尾号流量切分
      //MCE_INFO("Get Ads from AdEngine/AdTw");
      MCE_DEBUG("debug 003");
      if(_login_uid%10 < 2 || _login_uid == 287341024) {
        self_zones[it->first] = TW;
        tw_flag = true;
      } else {
        self_zones[it->first] = ENGINE;
      }
    } else if(!it->second.empty() && (it->second.at(0).groupid == -2)) {
      //余量,不分给台湾
      self_zones[it->first] = ENGINE;
      tag = "rr_REMAIN_1";
    } else if(!it->second.empty() && (it->second.at(0).groupid == -3)) {
      //余量,不分给台湾
      self_zones[it->first] = ENGINE;
      tag = "rr_REMAIN_2";
      photo = "true";
      MCE_DEBUG("photo = true");
    }
  }

      MCE_DEBUG("debug 004");
  if (!self_zones.empty()) {
    try {
      AdResultMap e_ads_;
      AdZone2Creatives e_ads;
      MCE_DEBUG("debug 005");
      //台湾分尾号流量切分
      if((_login_uid%10 < 2 || _login_uid == 287341024) && tw_flag) {
      MCE_DEBUG("debug 006");
        MCE_DEBUG("[TW_DEBUG] AdGetRequest::response --> enter to request Tw");
        e_ads_ = AdTwAdapter::instance().GetAds(serialized, log_url.str(), rotate_slot);
        AdGateI::instance().translate(ads,final_ads);
      } else {
      MCE_DEBUG("debug 007");
        MCE_DEBUG("AdGetRequest::response --> from AdEngine rotate_slot = "
            << rotate_slot);
        UserAndAction ua;
        ua.id = profile.id();
        ua.stage = profile.stage();
        ua.gender = profile.gender();
        ua.age = profile.age();
        ua.school = profile.school();
        ua.userMajor = profile.major();
        ua.grade = profile.grade();
        ua.homeArea = profile.home_area();
        ua.currentArea = profile.current_area();
        ua.ip = profile.ip();
        ua.ipArea = profile.ip_area();
        ua.actionType = ActionType::PAGEVIEW;
        AdRequest ad_request;
        ad_request.userAndAction = ua;
        ad_request.referer = referer;
        //url_mapping
       // set<Ice::Long> zone_ids;
        for (map<long, EngineTypes>::iterator zit = self_zones.begin(); zit != self_zones.end(); zit++) {
          long z_key = (*zit).first;
           if( photo == "true" && z_key == 100000000072 ) {
              ad_request.zoneDict[z_key] = 2;
           }else{
              ad_request.zoneDict[z_key] = 0;
            }
              ad_request.attributes[boost::lexical_cast<string>(z_key)]=tag;
        }
 //       AdUrlMaping::instance().GetAdZone(referer, ua.stage, zone_ids);
        //AdCreativeCache::instance().GetZoneDict(zone_ids, ad_request.zoneDict);
        MCE_DEBUG("AdGetRequest::response --> enter to request JavaServer");
        e_ads_=AdEngineJAdapter::instance().Request(ad_request);
        AdGateI::instance().translate(e_ads_,e_ads);
        //e_ads = AdEngineUAdapter::instance().GetAdsByZone(serialized, log_url.str(), rotate_slot, _login_uid, tag);
        //e_ads_ = AdEngineUAdapter::instance().GetAds(serialized, log_url.str(), rotate_slot, _login_uid, tag, photo);
      }
      if (e_ads.empty()) {
        MCE_DEBUG("AdGetRequest::response --> from AdEngineJ empty ");
      } else {
        for(AdZone2Creatives::iterator xxit =  e_ads.begin(); xxit != e_ads.end(); xxit++) {
          MCE_DEBUG("AdGetRequest::response --> from AdEngineJ" << xxit->second.size());
        }
      }
      for (map<long, EngineTypes>::iterator zit = self_zones.begin(); zit != self_zones.end(); zit++) {
        AdZone2Creatives::iterator eit = e_ads.find(zit->first);
        if (eit != e_ads.end()) {
          //eads[zit->first] = eit->second;
          //在相册页面,如果广告位wb1成功展示自助,则去掉wb2位置的广告
          /*if(100000000072 == zit->first) {
            ads[100000000073] = AdInfoSeq();
          }*/
        } else {
          ads[zit->first] = AdInfoSeq();
        }
      }
      for(AdZone2Creatives::const_iterator ad_x_it = e_ads.begin() ; ad_x_it != e_ads.end() ; ad_x_it ++ ){
        final_ads[ad_x_it->first] = ad_x_it->second; 
        MCE_DEBUG("AdGetRequest::response --> from AdEngineJ "  << ad_x_it->first <<"  " <<ad_x_it->second.size());
         if( ad_x_it->second.size() > 0 ) {
          for( int vi =0 ; vi < ad_x_it->second.size() ;vi ++ ) {
            MCE_DEBUG("widgetis =   " << ad_x_it->second[vi].widgetid);
          } 
         }
      }
    } catch (Ice::Exception& e) {
      MCE_WARN("AdEngineUAdapter/AdTwAdapter::GetAds error : " << e << " uid=" << _login_uid);
      err_flag = true;
    } catch (std::exception& e) {
      MCE_WARN("AdEngineUAdapter/AdTwAdapter::GetAds error : " << e.what() << " uid="
          << _login_uid);
      err_flag = true;
    }
  }
  if (err_flag) {
    stringstream stat_desc;
    stat_desc << _login_uid << " PushDefault";
    StatFunc stat(stat_desc.str());
    AdCreativeCache::instance().PushDefault(_login_uid, profile.stage(), GetRemoteAddr(),
        referer, &ads);
    AdGateI::instance().translate(ads,final_ads);
  }

  stringstream ad_header;
  string ad_body;
  if (render_ == RT_HTML) {
    ad_header
        << "Content-type: text/html; charset=utf-8\r\nSet-Cookie: an_slot="
        << ++rotate_slot << "; path=/ebpn\r\n\r\n";
    AdCreativeCache::instance().Get(final_ads, &ad_body);
    MCE_INFO("final ad size : "<< final_ads.size());
  } else if (render_ == RT_JSON) {
    ad_header
        << "Content-type: application/x-javascript; charset=utf-8\r\nSet-Cookie: an_slot="
        << ++rotate_slot << "; path=/ebpn\r\n\r\n";
    stringstream stat_desc;
    stat_desc << _login_uid << " GetJson";
    StatFunc stat(stat_desc.str());
    AdCreativeCache::instance().GetJson(referer, getPropertyInt(
        "refresh_source", 0), getPropertyInt("refresh_idx", 0), self_zones, final_ads,
        &ad_body);
    MCE_INFO("final ad size(json) : "<< final_ads.size());
  }

  FCGX_PutS(ad_header.str().c_str(), _fcgi_out);
  FCGX_PutS(ad_body.c_str(), _fcgi_out);
  timeval end;
  gettimeofday(&end, NULL);
  AdGateI::instance().ping_sender_.Send("GetAds", 1000*(end.tv_sec-start.tv_sec)+(end.tv_usec-start.tv_usec)/1000);
  return true;
}
Пример #12
0
AdZone2Creatives AdMatchManagerI::GetAdsByZone(const string& userProfile, const string& append_para, int rotate_index,  const ::Ice::Current& current){
  AdResultMap ans;
  AdZone2Creatives res;
  UserProfile profile;
  UserProfileClient::instance().Deserialize(userProfile, &profile);
  if(!init_ok_){
    MCE_INFO("AdMatchNManagerI::GetAds() --> initing.......");
    return res;
  }
  CookieEmptyCheck(profile);

  MatchHandlerParamter para(profile, append_para);
  AdZoneDict zone_dict = AdZonePool::instance().GetAdZoneOrdered(para.referer_, profile, false);
  if(zone_dict.empty()){
    MCE_INFO("GetAdZoneOrdered() empty. referer=" << para.referer_);
    return res;
  }
  MCE_DEBUG("[MAIN_PROCESS] AdMatchNManagerI::GetAds --> AdZoneDict->size = " << zone_dict.size());
  
  FilterBindUser(zone_dict, ans, profile.id());

  string tag;
  Ice::Context::const_iterator i = current.ctx.find("tag");
  if (i != current.ctx.end() && !i->second.empty()) {
    tag = i->second;
  }

  if(!tag.empty()) {
    para.tag_ = tag;
  }
  i = current.ctx.find("photo");
  if (i != current.ctx.end() && i->second == "true") {
    para.photo_ = true;
  }

  bool hide_flag = false;
  for(AdZoneDict::iterator it = zone_dict.begin(); it != zone_dict.end(); ++it){
    para.adzone_ = it->second;
    para.style_ = AdStyleDispatcher::instance().Dispatch(para.adzone_->id(),para.userProfile_);
    MCE_DEBUG("after dispatch: user_id = " << para.userProfile_.id() << ", adzone_id = " <<para.adzone_->id() << ", style_id = " << para.style_);
    if(100000000073 == para.adzone_->id() && hide_flag) {
      continue;
    }
    int rotate_size = it->second->GetRotateSize();
    if (rotate_size) {
      para.rotate_index_ = rotate_index % rotate_size;
    }
    para.zone_selected_groups_.clear();

    for(size_t i = 0; i < ad_match_handler_list_.size(); ++i) {
      if (!ad_match_handler_list_[i]->handle(para, ans)) {
        //如果是相册页wb1(72)展示自助广告,则不展示wb2广告位(73)
        if((100000000072 == para.adzone_->id()) && (!ans[100000000072].empty())) {
          MCE_DEBUG("hide_flag = true");
          hide_flag = true;
        }
        break;
      }
    }
    AdInfoSeq ad_seq = ans[para.adzone_->id()];
    AdCreativeSeq ac_seq;
    int abs_pos =0 ;
    for(AdInfoSeq::const_iterator ad_it = ad_seq.begin() ; ad_it != ad_seq.end() ; ++ ad_it){
      AdCreativeInfo ac ;
      ac.creativeid = ad_it->creativeid;
      ac.groupid = ad_it->groupid;
      string atts = ad_it->text;
      vector<string> para_strs;
      boost::algorithm::split_regex( para_strs, atts,regex( "\\^C" ) ) ;
      ac.widgetid = boost::lexical_cast<Ice::Long>(para_strs[1]);
      ac.text = atts;
      if(ad_it->updateTime == -1) {
        ac.extra = "style_test";
      } else {
        ac.extra = "";
      }
      ac.position = ++abs_pos;
      ac_seq.push_back(ac);
    }
    res[para.adzone_->id()] = ac_seq;
  }
  
  for(AdZone2Creatives::const_iterator it = res.begin(); it != res.end(); ++it) {
    MCE_DEBUG("Ads : " << it->first << '/' << it->second.size());
    if( it->second.size() > 0 ) {
      for( int vi = 0 ; vi < it->second.size() ; vi ++ ) {
        MCE_DEBUG("widgetid = " << it->second[vi].widgetid);
      }
    }
  }
  return res;
}
Пример #13
0
AdResultMap AdMatchManagerI::GetAds(const string& userProfile, const string& append_para, int rotate_index, const Ice::Current& current){
  AdResultMap ans;
  UserProfile profile;
  UserProfileClient::instance().Deserialize(userProfile, &profile);
  if(!init_ok_){
    MCE_INFO("AdMatchNManagerI::GetAds() --> initing.......");
    return ans;
  }
  bool hide = false;

  CookieEmptyCheck(profile);

  MatchHandlerParamter para(profile, append_para);
  AdZoneDict zone_dict = AdZonePool::instance().GetAdZoneOrdered(para.referer_, profile, hide);
  if(zone_dict.empty()){
    MCE_INFO("GetAdZoneOrdered() empty. referer=" << para.referer_);
    return ans;
  }
  MCE_DEBUG("[MAIN_PROCESS] AdMatchNManagerI::GetAds --> AdZoneDict->size = " << zone_dict.size());
  FilterBindUser(zone_dict, ans, profile.id());

  string tag = "rr_0";
  Ice::Context::const_iterator i = current.ctx.find("tag");
  if (i != current.ctx.end() && !i->second.empty()) {
    tag = i->second;
  }
  i = current.ctx.find("photo");
  if (i != current.ctx.end() && i->second == "true") {
    para.photo_ = true;
  }

  if(!tag.empty()) {
    para.tag_ = tag;
  }

  bool hide_flag = false;
  for(AdZoneDict::iterator it = zone_dict.begin(); it != zone_dict.end(); ++it){
    para.adzone_ = it->second;
    para.style_ = AdStyleDispatcher::instance().Dispatch(para.adzone_->id(),para.userProfile_);
    if(100000000073 == para.adzone_->id() && hide_flag) {
      continue;
    }
    int rotate_size = it->second->GetRotateSize();
    if (rotate_size) {
      para.rotate_index_ = rotate_index % rotate_size;
    }
    para.zone_selected_groups_.clear();

    for(size_t i = 0; i < ad_match_handler_list_.size(); ++i) {
      if (!ad_match_handler_list_[i]->handle(para, ans)) {
        //如果是相册页wb1(72)展示自助广告,则不展示wb2广告位(73)
        if((100000000072 == para.adzone_->id()) && (!ans[100000000072].empty())) {
          MCE_DEBUG("hide_flag = true");
          hide_flag = true;
        }
        break;
      }
    }
  }
  for(AdResultMap::const_iterator it = ans.begin(); it != ans.end(); ++it) {
    MCE_DEBUG("Ads : " << it->first << '/' << it->second.size());
  }
  return ans;
}
Пример #14
0
AdResultMap AdMatchManagerI::GetAds(const string& userProfile, const string& referer, int rotate_index, const Ice::Current& current){

  MCE_INFO("AdMatchNManagerI::GetAds --> call from " << current.con->toString());
  ostringstream timelog;

  TimeStat ts;
  TimeStat subts;
  AdResultMap ans;
  UserProfile profile;
  ostringstream info;
  set<AdGroupPtr> selected;

  bool hide = false;
  Ice::Context::const_iterator i = current.ctx.find("hide");
  if (i != current.ctx.end() && i->second == "true") {
    hide = true;
  }

  bool get_ad_success = true;
  UserProfileClient::instance().Deserialize(userProfile, &profile);

  timelog << " after Deserialize time_cost = " << ts.getTime();

  if(!init_ok_){
    MCE_INFO("AdMatchNManagerI::GetAds --> initing.......");
    return ans;
  }

  LogHelper::instance().CookieEmptyCheck(profile);

  timelog << " after CookieEmptyCheck time_cost = " << ts.getTime();

  info << "uid = "<<profile.id()<<",age = " << profile.age() << ",gender = "<< profile.gender() <<
      ",stage = " << profile.stage() << ",grade = " << profile.grade() <<
      ",current_area = " << profile.current_area() << ",ip_area = " << profile.ip_area() << ",school =" << profile.school();
  //MCE_INFO("AdMatchNManagerI::GetAds -->~~~~~~~~~~~~~~~~~~~~~rotate_index =  " << rotate_index << "   " << info.str());

  uint64_t user_key = Translator::instance().GetIndex(profile);
  subts.reset();
  AdZoneDict zone_dict = AdZonePool::instance().GetAdZoneOrdered(referer, profile.stage(), hide);
  //MCE_DEBUG("[VIP_DEBUG] uid = " << profile.id() << ", hide = " << hide);

  timelog << " after GetAdZoneOrdered2 time_cost = " << ts.getTime();

  if(zone_dict.empty()){
    //MCE_WARN("AdMatchNManagerI::GetAds --> No Result For GetAdZoneOrdered referer = " << referer);
    return ans;
  }
  //MCE_INFO("AdMatchNManagerI::GetAds --> AdZoneDict->size = " << zone_dict.size());
  //MCE_INFO("AdMatchNManagerI::GetAds --> TIME_TEST GetAdZoneOrdered = " << subts.getTime());

  //////////////////////////////////////////////////////////
  FilterBindUser(zone_dict, ans, profile.id());

  timelog << " after FilterBindUser time_cost = " << ts.getTime();

  //////////////////////////////////////////////////////////
  for(AdZoneDict::iterator it = zone_dict.begin(); it != zone_dict.end(); ++it){
    //MCE_INFO("AdMatchNManagerI::GetAds --> process adzone : " << it->second->id());
    ostringstream zone_debug_log;
    set<AdGroupPtr> zone_selected;
    map<Ice::Long, int> group_costs;
    AdZonePtr zone = it->second;
    Ice::Long zone_id = it->second->id();
    zone_debug_log << "[ZONE_DEBUG] adzone_id = " << zone_id << ", ";
    int ad_count = it->second->ad_count();
    int rotate_size = it->second->GetRotateSize();
    int zone_rotate_index = 0;
    if(rotate_size){
      zone_rotate_index = rotate_index % rotate_size;
    }
    zone_debug_log << "zone_rotate_index = " << zone_rotate_index << ", ";
    //**MCE_INFO("AdMatchNManagerI::GetAds --> @@@@@@@@@@@@@@@@@ zone_id = " << zone_id << " ad_count = " << ad_count << " rotate_size = " << rotate_size << " rotate_index = " << rotate_index << " zone_rotate_index = " << zone_rotate_index);
    subts.reset();
    AdGroupPtr rotate_group_ptr = it->second->GetRotateGroups(zone_rotate_index, user_key);
    //MCE_INFO("AdMatchNManagerI::GetAds --> TIME_TEST GetRotateGroups = " << subts.getTime());

    //MCE_INFO("AdMatchNManagerI::GetAds --> AdZoneDict@ ad_count = " << ad_count << " zone_id = " << zone_id << " rotate_size = " << rotate_size);
    if(rotate_group_ptr){
      set<AdGroupPtr> rotate_set;
      rotate_set.insert(rotate_group_ptr);
      AdRanker::instance().Filter(rotate_set, selected);
      if(!rotate_set.empty()){
        zone_debug_log << "has rotate_group = " << rotate_group_ptr->group_id() << ", ";
        zone_selected.insert(rotate_group_ptr);
        //MCE_INFO("AdMatchNManagerI::GetAds ==> zone_id = " << zone_id << " ad_count = " << ad_count << " GET ROTATE SUCCESS, group_id = " << rotate_group_ptr->group_id() <<" zone_rotate_index = " << zone_rotate_index);
        ad_count--;
      }
      else{
        //**MCE_INFO("AdMatchNManagerI::GetAds ==>Get ROTATE ad from AdZone : " << zone_id << " zone_rotate_index = " << zone_rotate_index << " AFTER RANK FAILED !!!! adgroup_id = " << rotate_group_ptr->group_id() << " bid_unit_id = " << rotate_group_ptr->bid_unit_id() << " bid_unit_key = " << rotate_group_ptr->bid_unit_key() << " userkey = " << user_key);
      }
    } else {
      zone_debug_log << "has no rotate_group, ";
      if ((zone->member_type() == 0) && ((rotate_size - zone_rotate_index) <= zone->self_rotation_number())) {
        MCE_INFO("AdMatchNManagerI::GetAds --> need ad from AdEngine/Tw: uid = " << profile.id() << ", zone_id = " << zone->id() << ", rotate_index = " << zone_rotate_index);
        AdInfoSeq ad_info_seq;
        AdInfo ad_info;
        ad_info.groupid = -1;
        ad_info_seq.push_back(ad_info);
        ans[zone->id()] = ad_info_seq;
        ans[9999963] = AdInfoSeq(); // old code, to delete
        continue;
      }
    }
    timelog << " after GetRotateGroups time_cost = " << ts.getTime();
    //update selected
    selected.insert(zone_selected.begin(), zone_selected.end());
    if(ad_count > 0){
      int get_cpm_count= 0;
      subts.reset();
      set<AdGroupPtr> groups = DimIndexMatcher::instance().Get(it->second->id(), userProfile);
      //MCE_INFO("AdMatchNManagerI::GetAds --> TIME_TEST DimIndexMatcher::Get = " << subts.getTime());
      if(!groups.empty()){
        //MCE_INFO("AdMatchNManagerI::GetAds --> get  Rank  groups.size = " << groups.size() << " userkey = " << user_key << " selected.size() = " << selected.size() << " ad_count = " << ad_count);
        subts.reset();
        RankStructSeq rank_seq = AdRanker::instance().Rank(groups, user_key, selected, ad_count);
        //MCE_INFO("AdMatchNManagerI::GetAds --> TIME_TEST AdRanker::Rank = " << subts.getTime());
        for(RankStructSeq::const_iterator rank_it = rank_seq.begin(); rank_it != rank_seq.end(); ++rank_it){
          AdGroupPtr obj = AdGroupPool::instance().GetAdGroup((*rank_it)->gid);
          if(obj){
            get_cpm_count++;
            zone_selected.insert(obj);
            group_costs[(*rank_it)->gid] = (*rank_it)->cost;
            //MCE_INFO("AdMatchNManagerI::GetAds ==> zone_id = " << zone_id << " ad_count = " << ad_count << " GET CPM SUCCESS, group_id = " << (*rank_it)->gid << " cost = " << (*rank_it)->cost);

          }
        }
        ad_count -= get_cpm_count;
       //**MCE_INFO("AdMatchNManagerI::GetAds ==>Get CMP ad from AdZone : " << zone_id << " zone_rotate_index = " << zone_rotate_index << " success!  size = " << rank_seq.size());
      }
      timelog << " after DimIndexMatcher::Get time_cost = " << ts.getTime();
      if(ad_count > 0){
        //MCE_INFO("AdMatchNManagerI::GetAds --> Get Default Ad");
        //TODO default has only one;
        AdGroupPtr default_group_ptr = it->second->GetDefaultGroups();
        if(default_group_ptr){
          zone_debug_log << ", has default_group = " << default_group_ptr->group_id();
          //MCE_INFO("AdMatchNManagerI::GetAds ==> zone_id = " << zone_id <<" ad_count = " << ad_count << " Get DEFAULT SUCCESS, group_id = "<< default_group_ptr->group_id() << " zone_rotate_index = " << zone_rotate_index);
          zone_selected.insert(default_group_ptr);
        }
        else{
          zone_debug_log << ", has no default_group";
          get_ad_success = false;
          //MCE_INFO( "AdMatchNManagerI::GetAds ==> zone_id = " << zone_id << " NO ROTATE, NO CMP, NO DEFAULT");
        }
      }
    }
    timelog << " after GetDefaultGroups::Get time_cost = " << ts.getTime();
    //update selected
    selected.insert(zone_selected.begin(), zone_selected.end());
    //MCE_INFO("AdMatchNManagerI::GetAds --> zone_selected.size() = " << zone_selected.size() << " selected.size() = " << selected.size());

    AdInfoSeq ad_info_seq;
    PvLog(zone_selected, profile, user_key, ad_info_seq, referer, it->second, group_costs, rotate_index);
    timelog << " after PvLog time_cost = " << ts.getTime();
    ans[zone_id] = ad_info_seq;
  }
  ostringstream res_log;
  //MCE_INFO("AdMatchNManagerI::GetAds --> USE_TIME_LOG : " << timelog.str());
  res_log << "AdMatchNManagerI::GetAds -->~~~~~~~~~~~~~~~~~~~~~userid = " << profile.id() << " ans.size = " << ans.size() <<" TIME_TEST ALL END  time = " << ts.getTime() << " ";
  for(AdResultMap::iterator ansit = ans.begin(); ansit != ans.end(); ++ansit){
    res_log << "FINAL zone_id = " << ansit->first << " result.size() = " << ansit->second.size() << ", ";
  }
  //MCE_INFO(res_log.str());
  return ans;
}
Пример #15
0
AdResultMap AdMatchManagerI::GetAds(const string& userProfile, const string& append_para, int rotate_index, const Ice::Current& current){
  AdResultMap ans;
  UserProfile profile;
  UserProfileClient::instance().Deserialize(userProfile, &profile);
  if(!init_ok_){
    MCE_INFO("AdMatchNManagerI::GetAds() --> initing.......");
    return ans;
  }
  bool hide = false;
  Ice::Context::const_iterator i = current.ctx.find("hide");
  if (i != current.ctx.end() && i->second == "true") {
    hide = true;
  }

  CookieEmptyCheck(profile);

  MatchHandlerParamter para(profile, append_para);

  MCE_DEBUG("AdMatchNManagerI::GetAds() --> referer(para.referer_) = " << para.referer_ << ", append_para = " << append_para);
  AdZoneDict zone_dict = AdZonePool::instance().GetAdZoneOrdered(para.referer_, profile, hide);
  //AdZoneDict zone_dict = AdZonePool::instance().GetAdZoneOrdered(para.referer_, profile.stage());
  if(zone_dict.empty()){
    // MCE_INFO("GetAdZoneOrdered() empty. referer=" << para.referer_);
    return ans;
  }
  //for(AdZoneDict::iterator zit = zone_dict.begin(); zit != zone_dict.end(); ++zit) {
  //    MCE_DEBUG("user = "******", zone = " << zit->second->id());
  //}
  MCE_DEBUG("[MAIN_PROCESS] AdMatchNManagerI::GetAds --> AdZoneDict->size = " << zone_dict.size() << ", referer=" << para.referer_);
  FilterBindUser(zone_dict, ans, profile.id());
  MCE_DEBUG("[MAIN_PROCESS] AdMatchNManagerI::GetAds --> after FilterBindUser AdZoneDict->size = " << zone_dict.size() << ", referer=" << para.referer_);

  //bool hide_flag = false;
  //按优先级遍历广告位,priority越小,优先级越高
  for(AdZoneDict::iterator it = zone_dict.begin(); it != zone_dict.end(); ++it){
    para.adzone_ = it->second;
    /*if(100000000073 == para.adzone_->id() && hide_flag) {
      continue;
    }*/
    int rotate_size = it->second->GetRotateSize();
    if (rotate_size) {
      para.rotate_index_ = rotate_index % rotate_size;
    }
    para.zone_selected_groups_.clear();

    for(size_t i = 0; i < ad_match_handler_list_.size(); ++i) {
      if (!ad_match_handler_list_[i]->handle(para, ans)) {
        //如果是相册页wb1(72)展示自助广告,则不展示wb2广告位(73)
        /*if((100000000072 == para.adzone_->id()) && (!ans[100000000072].empty())) {
          hide_flag = true;
        }*/
        break;
      }
    }
  }
  MCE_DEBUG("[REMAIN] AdMatchNManagerI::GetAds() --> log size = " << para.pv_log_seq_.size() << " + " << para.default_log72_.size());
  try {
    if(!para.pv_log_seq_.empty() && !para.default_log72_.empty()) {
      para.pv_log_seq_.insert(para.pv_log_seq_.begin(), para.default_log72_.begin(), para.default_log72_.end());
      AdLogAdapter::instance().PvBySeq(para.pv_log_seq_);
    } else if(!para.pv_log_seq_.empty()) {
      AdLogAdapter::instance().PvBySeq(para.pv_log_seq_);
    } else if(!para.default_log72_.empty()) {
      AdLogAdapter::instance().PvBySeq(para.default_log72_);
    }
  } catch (Ice::Exception& e) {
    MCE_WARN("AdMatchManagerI::GetAds() --> AdLogAdapter.PvBySeq ERR line:"
        << __LINE__ << " err:" << e);
  } catch (std::exception& e) {
    MCE_WARN("AdMatchManagerI::GetAds() --> AdLogAdapter.PvBySeq ERR line:"
        << __LINE__ << " err:" << e.what());
  }

  MCE_DEBUG("[REMAIN] AdMatchNManagerI::GetAds() --> cpm_log size = " << para.cpm_pv_log_seq_.size() << " + " << para.cpm_default_log72_.size());
  try {
    if(!para.cpm_pv_log_seq_.empty() && !para.cpm_default_log72_.empty()) {
      para.cpm_pv_log_seq_.insert(para.cpm_pv_log_seq_.begin(), para.cpm_default_log72_.begin(), para.cpm_default_log72_.end());
      AdLogAdapter::instance().PvForCharge(para.cpm_pv_log_seq_);
    } else if(!para.cpm_pv_log_seq_.empty()) {
      AdLogAdapter::instance().PvForCharge(para.cpm_pv_log_seq_);
    } else if(!para.cpm_default_log72_.empty()) {
      AdLogAdapter::instance().PvForCharge(para.cpm_default_log72_);
    }
  } catch (Ice::Exception& e) {
    MCE_WARN("AdMatchManagerI::GetAds() --> AdLogAdapter.PvForCharge ERR line:"
        << __LINE__ << " err:" << e);
  } catch (std::exception& e) {
    MCE_WARN("AdMatchManagerI::GetAds() --> AdLogAdapter.PvForCharge ERR line:"
        << __LINE__ << " err:" << e.what());
  }
  return ans;
}
Пример #16
0
AdResultMap AdEngineUAdapter::GetAds(const string & user_profile, const string & referer, int rotate_index, bool env_test) {
    UserProfile profile;
    UserProfileClient::instance().Deserialize(user_profile, &profile);
    return getManager(GetServerIndex(profile.id(), env_test))->GetAds(user_profile, referer, rotate_index);
}
Пример #17
0
AdZone2Creatives AdMatchManagerI::GetAdsByZoneInfo(const string& userProfile, const string& append_para, int rotate_index, const ZoneInfoMap &zone_info_map, const ::Ice::Current& current){
  timeval start;
  gettimeofday(&start, NULL);
  AdResultMap ans;
  AdZone2Creatives res;
  UserProfile profile;
  UserProfileClient::instance().Deserialize(userProfile, &profile);
  if(!init_ok_){
    MCE_INFO("AdMatchNManagerI::GetAds() --> initing.......");
    return res;
  }
  CookieEmptyCheck(profile);

  if(profile.id() == 287726637 || profile.id() == 287726711) {
    unsigned int ip = ntohl(inet_addr("14.201.79.46"));
    profile.set_ip(ip);
    profile.set_ip_area("0001000000000000");
    MCE_DEBUG("Modify user ip" << ip << ",userid:" << profile.id());
  }

  MatchHandlerParamter para(profile, append_para);
  //AdZoneDict zone_dict = AdZonePool::instance().GetAdZoneOrdered(para.referer_, profile, false);
  AdZoneDict zone_dict = AdZonePool::instance().GetAdZoneOrdered(zone_info_map, profile);
  if(zone_dict.empty()){
    MCE_INFO("AdMatchNManagerI::GetAdsByZoneInfo GetAdZoneOrdered() empty. referer=" << para.referer_);
    return res;
  }
  MCE_INFO("[MAIN_PROCESS] AdMatchNManagerI::GetAdsByZoneInfo --> AdZoneDict->size = " << zone_dict.size()<<",uid = " << para.userProfile_.id());

  FilterBindUser(zone_dict, ans, profile.id());

  /*string tag;
  Ice::Context::const_iterator i = current.ctx.find("tag");
  if (i != current.ctx.end() && !i->second.empty()) {
    tag = i->second;
  }

  if(!tag.empty()) {
    para.tag_ = tag;
  }*/

  Ice::Context::const_iterator i = current.ctx.find("photo");
  if (i != current.ctx.end() && i->second == "true") {
    para.photo_ = true;
  }
  i = current.ctx.find("count");
  if (i != current.ctx.end() && !i->second.empty()) {
    try{
      para.count_ = boost::lexical_cast<int>(i->second);
    }catch(std::exception e) {
      MCE_WARN("AdMatchManagerI::GetAdsByZoneInfo--err:" << e.what());
    }catch(...) {
      MCE_WARN("AdMatchManagerI::GetAdsByZoneInfo--unknow err:" );
    } 
  }
  MCE_DEBUG("AdMatchManagerI::GetAdsByZoneInfo --> para.count_ = " << para.count_);

  bool hide_flag = false;
  for(AdZoneDict::iterator it = zone_dict.begin(); it != zone_dict.end(); ++it){
    para.adzone_ = it->second;
    para.style_ = AdStyleDispatcher::instance().Dispatch(para.adzone_->id(),para.userProfile_);
    MCE_DEBUG("after dispatch: user_id = " << para.userProfile_.id() << ", adzone_id = " <<para.adzone_->id() << ", style_id = " << para.style_);
    if(100000000073 == para.adzone_->id() && hide_flag) {
      continue;
    }
    int rotate_size = it->second->GetRotateSize();
    if (rotate_size) {
      para.rotate_index_ = rotate_index % rotate_size;
    }
    para.zone_selected_groups_.clear();


    ZoneInfoMap::const_iterator itz = zone_info_map.find(para.adzone_->id());
    if(itz != zone_info_map.end()) {
      para.tag_ = itz->second.tag;
    } else {
      para.tag_ = "";
    }

    for(size_t i = 0; i < ad_match_handler_list_.size(); ++i) {

      if (!ad_match_handler_list_[i]->handle(para, ans)) {
        //如果是相册页wb1(72)展示自助广告,则不展示wb2广告位(73)
        if((100000000072 == para.adzone_->id()) && (!ans[100000000072].empty())) {
          MCE_DEBUG("hide_flag = true");
          hide_flag = true;
        }
        break;
      }
    }
    AdInfoSeq ad_seq = ans[para.adzone_->id()];
    AdCreativeSeq ac_seq;
    int abs_pos =0 ;
    for(AdInfoSeq::const_iterator ad_it = ad_seq.begin() ; ad_it != ad_seq.end() ; ++ ad_it){
      AdCreativeInfo ac ;
      ac.creativeid = ad_it->creativeid;
      ac.groupid = ad_it->groupid;
      string atts = ad_it->text;
      vector<string> para_strs;
      boost::algorithm::split_regex( para_strs, atts,regex( "\\^C" ) ) ;
      ac.widgetid = boost::lexical_cast<Ice::Long>(para_strs[1]);
      ac.text = atts;
      if(ad_it->updateTime == -1) {
        ac.extra = "style_test";
      } else {
        ac.extra = "";
      }
      ac.position = ++abs_pos;
      ac_seq.push_back(ac);
    }
    res[para.adzone_->id()] = ac_seq;
  }

  for(AdZone2Creatives::const_iterator it = res.begin(); it != res.end(); ++it) {
    MCE_DEBUG("Ads : " << it->first << '/' << it->second.size());
    if( it->second.size() > 0 ) {
      for( int vi = 0 ; vi < it->second.size() ; vi ++ ) {
        MCE_DEBUG("widgetid = " << it->second[vi].widgetid);
      }
    }
  }
  timeval end;
  gettimeofday(&end, NULL);
  AdMatchManagerI::instance().ping_sender_.Send("GetAds", 1000*(end.tv_sec-start.tv_sec)+(end.tv_usec-start.tv_usec)/1000);
  return res;
}