コード例 #1
0
ファイル: populateFromLog.php プロジェクト: richhl/kalturaCE
 } catch (Exception $e) {
     KalturaLog::err($e->getMessage());
     sleep(5);
     continue;
 }
 foreach ($sphinxLogs as $sphinxLog) {
     $dc = $sphinxLog->getDc();
     KalturaLog::log('Sphinx log id ' . $sphinxLog->getId() . " dc [{$dc}] Memory: [" . memory_get_usage() . "]");
     if (isset($lastLogs[$dc])) {
         $serverLastLog = $lastLogs[$dc];
         if ($serverLastLog->getLastLogId() >= $sphinxLog->getId()) {
             KalturaLog::debug('Last log id [' . $serverLastLog->getLastLogId() . "] dc [{$dc}] is larger than id [" . $sphinxLog->getId() . "]");
             continue;
         }
     } else {
         $serverLastLog = new SphinxLogServer();
         $serverLastLog->setServer($sphinxServer);
         $serverLastLog->setDc($dc);
         $lastLogs[$dc] = $serverLastLog;
     }
     try {
         $sql = $sphinxLog->getSql();
         $affected = $sphinxCon->exec($sql);
         if (!$affected) {
             $errorInfo = $sphinxCon->errorInfo();
             //				if(!preg_match('/^duplicate id/', $errorInfo[2]))
             //					die("No affected records [" . $sphinxCon->errorCode() . "]\n" . print_r($sphinxCon->errorInfo(), true));
         }
         $serverLastLog->setLastLogId($sphinxLog->getId());
         $serverLastLog->save(myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_SPHINX_LOG));
     } catch (Exception $e) {
コード例 #2
0
ファイル: populateFromLog.php プロジェクト: DBezemer/server
     $sphinxCon = DbManager::createSphinxConnection($sphinxServer, $sphinxPort);
 } catch (Exception $e) {
     KalturaLog::err($e->getMessage());
     sleep(5);
     continue;
 }
 foreach ($sphinxLogs as $sphinxLog) {
     /* @var $sphinxLog SphinxLog */
     $dc = $sphinxLog->getDc();
     $executedServerId = $sphinxLog->getExecutedServerId();
     $sphinxLogId = $sphinxLog->getId();
     $serverLastLog = null;
     if (isset($lastLogs[$dc])) {
         $serverLastLog = $lastLogs[$dc];
     } else {
         $serverLastLog = new SphinxLogServer();
         $serverLastLog->setServer($sphinxServer);
         $serverLastLog->setDc($dc);
         $lastLogs[$dc] = $serverLastLog;
     }
     $handledRecords[$dc][] = $sphinxLogId;
     KalturaLog::log("Sphinx log id {$sphinxLogId} dc [{$dc}] executed server id [{$executedServerId}] Memory: [" . memory_get_usage() . "]");
     try {
         if ($skipExecutedUpdates && $executedServerId == $serverLastLog->getId()) {
             KalturaLog::log("Sphinx server is initiated and the command already ran synchronously on this machine. Skipping");
         } else {
             $sql = $sphinxLog->getSql();
             $affected = $sphinxCon->exec($sql);
             if (!$affected) {
                 $errorInfo = $sphinxCon->errorInfo();
             }
コード例 #3
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      SphinxLogServer $value A SphinxLogServer object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(SphinxLogServer $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
コード例 #4
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      SphinxLogServer $value A SphinxLogServer object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(SphinxLogServer $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) {
             self::$instances[$key] = $obj;
             kMemoryManager::registerPeer('SphinxLogServerPeer');
         }
     }
 }