コード例 #1
0
ファイル: Lock.php プロジェクト: okite11/frames21
 /**
  * Get lock singleton instance
  *
  * @return Mage_Index_Model_Lock
  */
 public static function getInstance()
 {
     if (!self::$_instance instanceof self) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
コード例 #2
0
ファイル: Process.php プロジェクト: quyip8818/Mag
 /**
  * Returns Lock object.
  *
  * @return Mage_Index_Model_Lock|null
  */
 protected function _getLockInstance()
 {
     if (is_null($this->_lockInstance)) {
         $this->_lockInstance = Mage_Index_Model_Lock::getInstance();
     }
     return $this->_lockInstance;
 }
コード例 #3
0
 /**
  * Run full re-index for all invalidated indexes
  * Refresh all active indexes by changeLog
  *
  * @param Mage_Cron_Model_Schedule $schedule
  * @throws Exception
  * @return Enterprise_Index_Model_Observer
  */
 public function refreshIndex(Mage_Cron_Model_Schedule $schedule)
 {
     /** @var $helper Enterprise_Index_Helper_Data */
     $helper = Mage::helper('enterprise_index');
     /** @var $lock Mage_Index_Model_Lock */
     $lock = Mage_Index_Model_Lock::getInstance();
     if ($lock->setLock(self::REINDEX_FULL_LOCK, true)) {
         /**
          * Workaround for fatals and memory crashes: Invalidating indexers that are in progress
          * Successful lock setting is considered that no other full reindex processes are running
          */
         $this->_invalidateInProgressIndexers();
         $client = Mage::getModel('enterprise_mview/client');
         try {
             //full re-index
             $inactiveIndexes = $this->_getInactiveIndexersByPriority();
             $rebuiltIndexes = array();
             foreach ($inactiveIndexes as $inactiveIndexer) {
                 $tableName = (string) $inactiveIndexer->index_table;
                 $actionName = (string) $inactiveIndexer->action_model->all;
                 $client->init($tableName);
                 if ($actionName) {
                     $client->execute($actionName);
                     $rebuiltIndexes[] = $tableName;
                 }
             }
             //re-index by changelog
             $indexers = $helper->getIndexers(true);
             foreach ($indexers as $indexerName => $indexerData) {
                 $indexTable = (string) $indexerData->index_table;
                 $actionName = (string) $indexerData->action_model->changelog;
                 $client->init($indexTable);
                 if (isset($actionName) && !in_array($indexTable, $rebuiltIndexes)) {
                     $client->execute($actionName);
                 }
             }
         } catch (Exception $e) {
             $lock->releaseLock(self::REINDEX_FULL_LOCK, true);
             throw $e;
         }
         $lock->releaseLock(self::REINDEX_FULL_LOCK, true);
     } else {
         throw new Enterprise_Index_Exception("Can't lock indexer process.");
     }
     return $this;
 }