コード例 #1
0
ファイル: PartnerLoadPeer.php プロジェクト: DBezemer/server
 /**
  * This function queies the batch job lock table and calculates for each partnerID and job type
  * its partner load and weigthed partner load. it returns the information as a Map where : 
  * key - partnerId#jobType#jobSubType
  * value - partnerLoad
  */
 public static function getPartnerLoads()
 {
     $dcId = kDataCenterMgr::getCurrentDcId();
     $c = new Criteria();
     $c->add(BatchJobLockPeer::WORKER_ID, null, Criteria::ISNOTNULL);
     $c->add(BatchJobLockPeer::DC, $dcId);
     $c->addGroupByColumn(BatchJobLockPeer::PARTNER_ID);
     $c->addGroupByColumn(BatchJobLockPeer::JOB_TYPE);
     $c->addGroupByColumn(BatchJobLockPeer::JOB_SUB_TYPE);
     $c->addSelectColumn(BatchJobLockPeer::COUNT);
     foreach ($c->getGroupByColumns() as $column) {
         $c->addSelectColumn($column);
     }
     $stmt = BatchJobLockPeer::doSelectStmt($c);
     $partnerLoads = array();
     $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
     foreach ($rows as $row) {
         $partnerId = $row['PARTNER_ID'];
         $jobType = $row['JOB_TYPE'];
         $jobSubType = $row['JOB_SUB_TYPE'];
         if (is_null($jobSubType)) {
             $jobSubType = 0;
         }
         $jobCount = $row[BatchJobLockPeer::COUNT];
         $priorityFactor = PartnerPeer::getPartnerPriorityFactor($partnerId);
         $key = $partnerId . "#" . $jobType . "#" . $jobSubType;
         $partnerLoad = new PartnerLoad();
         $partnerLoad->setPartnerId($partnerId);
         $partnerLoad->setJobType($jobType);
         $partnerLoad->setJobSubType($jobSubType);
         $partnerLoad->setDc($dcId);
         $partnerLoad->setPartnerLoad($jobCount);
         $partnerLoad->setWeightedPartnerLoad($jobCount * $priorityFactor);
         $partnerLoads[$key] = $partnerLoad;
     }
     return $partnerLoads;
 }
コード例 #2
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      PartnerLoad $value A PartnerLoad object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(PartnerLoad $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = serialize(array((string) $obj->getJobType(), (string) $obj->getJobSubType(), (string) $obj->getPartnerId(), (string) $obj->getDc()));
         }
         if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) {
             self::$instances[$key] = $obj;
             kMemoryManager::registerPeer('PartnerLoadPeer');
         }
     }
 }