本文整理汇总了PHP中Mage_Index_Model_Process::isLocked方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Index_Model_Process::isLocked方法的具体用法?PHP Mage_Index_Model_Process::isLocked怎么用?PHP Mage_Index_Model_Process::isLocked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Index_Model_Process
的用法示例。
在下文中一共展示了Mage_Index_Model_Process::isLocked方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
public function start($count = 0)
{
if (!$count) {
$this->limit = Mage::getStoreConfig('kirchbergerknorr/factfindersync/queue');
} else {
$this->limit = $count;
}
if ($this->indexProcess->isLocked()) {
$this->log("Another %s process is running! Aborted", self::PROCESS_ID);
return false;
}
// Set an exclusive lock.
$this->indexProcess->lockAndBlock();
$this->log("========================================");
$timeStart = microtime(true);
$this->log("Started FactFinderSync");
$this->insertNewProducts();
$this->updateImportedProducts();
$timeEnd = microtime(true);
$time = $timeEnd - $timeStart;
$this->log("Finished FactFinderSync limit %s in %s seconds", $this->limit, $time);
// Remove the lock.
$this->indexProcess->unlock();
return true;
}
示例2: testIsLocked
/**
* @dataProvider isLockedDataProvider
* @param bool $needUnlock
*/
public function testIsLocked($needUnlock)
{
$this->_processFile = $this->getMock('Mage_Index_Model_Process_File', array('isProcessLocked'));
$this->_processFile->expects($this->once())->method('isProcessLocked')->with($needUnlock)->will($this->returnArgument(0));
$this->_prepareIndexProcess();
$this->assertEquals($needUnlock, $this->_indexProcess->isLocked($needUnlock));
}
示例3: _changeProcessKeyStatus
/**
* Check if the event will be processed and disable/enable keys in index tables
*
* @param mixed|Mage_Index_Model_Process $process
* @param bool $enable
* @return bool
*/
protected function _changeProcessKeyStatus($process, $enable = true)
{
$event = $this->_currentEvent;
if ($process instanceof Mage_Index_Model_Process && $process->getMode() !== Mage_Index_Model_Process::MODE_MANUAL && !$process->isLocked() && (is_null($event) || $event instanceof Mage_Index_Model_Event && $process->matchEvent($event) || is_array($event) && $process->matchEntityAndType($event[0], $event[1]))) {
if ($enable) {
$process->enableIndexerKeys();
} else {
$process->disableIndexerKeys();
}
return true;
}
return false;
}
示例4: int
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category Mehulchaudhari
* @package Mehulchaudhari_FeedsGenerator
* @author Mehul Chaudhari
* @copyright Copyright (c) 2014 ; ;
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/** @var $installer Mage_Eav_Model_Entity_Setup */
const PROCESS_ID = 'google_taxonomy';
$indexProcess = new Mage_Index_Model_Process();
$indexProcess->setId(PROCESS_ID);
if (!$indexProcess->isLocked()) {
$indexProcess->lockAndBlock();
$installer = $this;
$installer->startSetup();
// Create (or re-create) the table containing all of the Google taxonomy information. This is a list
// of available taxonomy values.
$installer->run("\n DROP TABLE IF EXISTS {$this->getTable('feedsgenerator_taxonomy')};\n CREATE TABLE {$this->getTable('feedsgenerator_taxonomy')} (\n `taxonomy_id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t `store_lang` varchar(255) NOT NULL,\n `taxonomy_name` varchar(255) NOT NULL,\n PRIMARY KEY (`taxonomy_id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n ");
// Fill the taxonomy table with values provided by Google. Values are inserted in batches of
// 1000 to increase processing speed.
$connection = $installer->getConnection();
$Datail = Mage::getModel('feedsgenerator/googleproducts_taxonomy')->getDataDetail();
foreach ($Datail as $lang => $taxonomy) {
$data = array();
foreach ($taxonomy as $i => $t) {
$data[] = array($lang, $t);
}
示例5: run
/**
* Run the Task
*
* IF ANY Job we run fails, due to another processes being run we should
* gracefully exit and wait our next go!
*
* Also change auto sync to just create a job, and run a single job Queue!
*/
public function run()
{
if ($this->_config()->isLogEnabled()) {
$this->_config()->dbLog("Cron [Triggered]");
}
/**
* This doesn't exist in 1.3.2!
*/
$indexProcess = new Mage_Index_Model_Process();
$indexProcess->setId(self::LOCK_INDEX_ID);
if ($indexProcess->isLocked()) {
// Check how old the lock is - unlock after 1hr
if ($this->_lockIsOld(self::LOCK_INDEX_ID)) {
$indexProcess->unlock();
} else {
$this->_config()->log('MAILUP: cron already running or locked');
return false;
}
}
$indexProcess->lockAndBlock();
try {
require_once dirname(__FILE__) . '/../Helper/Data.php';
$db_read = Mage::getSingleton('core/resource')->getConnection('core_read');
$db_write = Mage::getSingleton('core/resource')->getConnection('core_write');
$syncTableName = Mage::getSingleton('core/resource')->getTableName('mailup/sync');
$jobsTableName = Mage::getSingleton('core/resource')->getTableName('mailup/job');
$lastsync = gmdate("Y-m-d H:i:s");
// reading customers (jobid == 0, their updates)
$customer_entity_table_name = Mage::getSingleton('core/resource')->getTableName('customer_entity');
/**
* Now Handle Jobs we need to Sync, and all customers attached to each job
*/
foreach (Mage::getModel('mailup/job')->fetchQueuedOrStartedJobsCollection() as $jobModel) {
/* @var $jobModel MailUp_MailUpSync_Model_Job */
$job = $jobModel->getData();
$storeId = isset($job['store_id']) ? $job['store_id'] : NULL;
// If job is auto-sync and cron is not enabled for the job's site, skip the job
if ($jobModel->isAutoSync() && !$this->_config()->isCronExportEnabled($storeId)) {
$this->_config()->dbLog("Auto-Task skipped as auto-sync disabled for site", $job["id"], $storeId);
continue;
}
$stmt = $db_write->query("UPDATE {$jobsTableName}\n SET status='started', start_datetime='" . gmdate("Y-m-d H:i:s") . "'\n WHERE id={$job["id"]}");
$customers = array();
$job['mailupNewGroup'] = 0;
$job['mailupIdList'] = Mage::getStoreConfig('mailup_newsletter/mailup/list', $storeId);
$job["mailupGroupId"] = $job["mailupgroupid"];
$job["send_optin_email_to_new_subscribers"] = $job["send_optin"];
// If group is 0 and there is a default group, set group to this group
$defaultGroupId = Mage::getStoreConfig('mailup_newsletter/mailup/default_group');
if ($job["mailupGroupId"] == 0 && $defaultGroupId !== null) {
$job["mailupGroupId"] = $defaultGroupId;
}
$tmp = Mage::getSingleton('mailup/source_lists');
$tmp = $tmp->toOptionArray($storeId);
// pass store id!
foreach ($tmp as $t) {
if ($t["value"] == $job['mailupIdList']) {
$job['mailupListGUID'] = $t["guid"];
$job["groups"] = $t["groups"];
break;
}
}
unset($tmp);
unset($t);
$stmt = $db_read->query("\n SELECT ms.*, ce.email\n FROM {$syncTableName} ms\n JOIN {$customer_entity_table_name} ce\n ON (ms.customer_id = ce.entity_id)\n WHERE ms.needs_sync=1\n AND ms.entity='customer'\n AND job_id={$job["id"]}");
while ($row = $stmt->fetch()) {
$customers[] = $row["customer_id"];
}
/**
* Send the Data!
*/
$returnCode = MailUp_MailUpSync_Helper_Data::generateAndSendCustomers($customers, $job, $storeId);
/**
* Check return OK
*/
if ($returnCode === 0) {
$customerCount = count($customers);
$db_write->query("\n UPDATE {$syncTableName} SET needs_sync=0, last_sync='{$lastsync}'\n WHERE job_id = {$job["id"]}\n AND entity='customer'");
$this->_config()->dbLog("Job Task [update] [Synced] [customer count:{$customerCount}]", $job["id"], $storeId);
// finishing the job also
$db_write->query("\n UPDATE {$jobsTableName} SET status='finished', finish_datetime='" . gmdate("Y-m-d H:i:s") . "'\n WHERE id={$job["id"]}");
$this->_config()->dbLog("Jobs [Update] [Complete] [{$job["id"]}]", $job["id"], $storeId);
} else {
$stmt = $db_write->query("UPDATE {$jobsTableName} SET status='queued' WHERE id={$job["id"]}");
if ($this->_config()->isLogEnabled()) {
$this->_config()->dbLog(sprintf("generateAndSendCustomers [ReturnCode] [ERROR] [%d]", $returnCode), $job["id"], $storeId);
}
}
}
} catch (Exception $e) {
// In case of otherwise uncaught error, unlock and re-throw
$indexProcess->unlock();
//.........这里部分代码省略.........
示例6: isLocked
/**
* Check if process is locked
*
* @return bool
*/
public function isLocked()
{
if (false === $this->getLockInstance()) {
return parent::isLocked();
}
return $this->getLockInstance()->isLocked();
}