本文整理汇总了PHP中JobQueueGroup类的典型用法代码示例。如果您正苦于以下问题:PHP JobQueueGroup类的具体用法?PHP JobQueueGroup怎么用?PHP JobQueueGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JobQueueGroup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: execute
function execute()
{
$totalOnly = $this->hasOption('totalonly');
$pendingDBs = JobQueueAggregator::singleton()->getAllReadyWikiQueues();
$sizeByWiki = array();
// (wiki => type => count) map
foreach ($pendingDBs as $type => $wikis) {
foreach ($wikis as $wiki) {
$sizeByWiki[$wiki][$type] = JobQueueGroup::singleton($wiki)->get($type)->getSize();
}
}
if ($this->hasOption('grouponly')) {
$this->output(FormatJSON::encode($sizeByWiki, true) . "\n");
} else {
$total = 0;
foreach ($sizeByWiki as $wiki => $counts) {
$count = array_sum($counts);
if ($count > 0) {
if (!$totalOnly) {
$this->output("{$wiki} {$count}\n");
}
$total += $count;
}
}
if (!$this->hasOption('nototal')) {
$this->output("Total {$total}\n");
}
}
}
开发者ID:reviforks,项目名称:MirahezeMagic,代码行数:29,代码来源:getJobQueueLengths.php
示例2: runJobs
private function runJobs()
{
JobQueueGroup::destroySingletons();
$jobs = new RunJobs();
$jobs->loadParamsAndArgs(null, ['quiet' => true], null);
$jobs->execute();
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:7,代码来源:CategoryMembershipChangeJobTest.php
示例3: run
function run()
{
global $wgUpdateRowsPerJob;
// Job to update all (or a range of) backlink pages for a page
if (!empty($this->params['recursive'])) {
// Carry over information for de-duplication
$extraParams = $this->getRootJobParams();
// Avoid slave lag when fetching templates.
// When the outermost job is run, we know that the caller that enqueued it must have
// committed the relevant changes to the DB by now. At that point, record the master
// position and pass it along as the job recursively breaks into smaller range jobs.
// Hopefully, when leaf jobs are popped, the slaves will have reached that position.
if (isset($this->params['masterPos'])) {
$extraParams['masterPos'] = $this->params['masterPos'];
} elseif (wfGetLB()->getServerCount() > 1) {
$extraParams['masterPos'] = wfGetLB()->getMasterPos();
} else {
$extraParams['masterPos'] = false;
}
// Convert this into no more than $wgUpdateRowsPerJob RefreshLinks per-title
// jobs and possibly a recursive RefreshLinks job for the rest of the backlinks
$jobs = BacklinkJobUtils::partitionBacklinkJob($this, $wgUpdateRowsPerJob, 1, array('params' => $extraParams));
JobQueueGroup::singleton()->push($jobs);
// Job to update link tables for a set of titles
} elseif (isset($this->params['pages'])) {
foreach ($this->params['pages'] as $pageId => $nsAndKey) {
list($ns, $dbKey) = $nsAndKey;
$this->runForTitle(Title::makeTitleSafe($ns, $dbKey));
}
// Job to update link tables for a given title
} else {
$this->runForTitle($this->title);
}
return true;
}
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:35,代码来源:RefreshLinksJob.php
示例4: execute
public function execute()
{
$group = JobQueueGroup::singleton();
if ($this->hasOption('list')) {
foreach ($group->getQueueTypes() as $type) {
$queue = $group->get($type);
foreach ($queue->getAllQueuedJobs() as $job) {
$this->output($job->toString() . " status=unclaimed\n");
}
foreach ($queue->getAllDelayedJobs() as $job) {
$this->output($job->toString() . " status=delayed\n");
}
}
} elseif ($this->hasOption('group')) {
foreach ($group->getQueueTypes() as $type) {
$queue = $group->get($type);
$delayed = $queue->getDelayedCount();
$pending = $queue->getSize();
$claimed = $queue->getAcquiredCount();
$abandoned = $queue->getAbandonedCount();
$active = max(0, $claimed - $abandoned);
if ($pending + $claimed + $delayed > 0) {
$this->output("{$type}: {$pending} queued; " . "{$claimed} claimed ({$active} active, {$abandoned} abandoned); " . "{$delayed} delayed\n");
}
}
} else {
$count = 0;
foreach ($group->getQueueTypes() as $type) {
$count += $group->get($type)->getSize();
}
$this->output("{$count}\n");
}
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:33,代码来源:showJobs.php
示例5: fixRedirects
/**
* Insert jobs into the job queue to fix redirects to the given title
* @param string $reason the reason for the fix, see message "double-redirect-fixed-<reason>"
* @param $redirTitle Title: the title which has changed, redirects pointing to this title are fixed
* @param bool $destTitle Not used
*/
public static function fixRedirects( $reason, $redirTitle, $destTitle = false ) {
# Need to use the master to get the redirect table updated in the same transaction
$dbw = wfGetDB( DB_MASTER );
$res = $dbw->select(
array( 'redirect', 'page' ),
array( 'page_namespace', 'page_title' ),
array(
'page_id = rd_from',
'rd_namespace' => $redirTitle->getNamespace(),
'rd_title' => $redirTitle->getDBkey()
), __METHOD__ );
if ( !$res->numRows() ) {
return;
}
$jobs = array();
foreach ( $res as $row ) {
$title = Title::makeTitle( $row->page_namespace, $row->page_title );
if ( !$title ) {
continue;
}
$jobs[] = new self( $title, array(
'reason' => $reason,
'redirTitle' => $redirTitle->getPrefixedDBkey() ) );
# Avoid excessive memory usage
if ( count( $jobs ) > 10000 ) {
JobQueueGroup::singleton()->push( $jobs );
$jobs = array();
}
}
JobQueueGroup::singleton()->push( $jobs );
}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:38,代码来源:DoubleRedirectJob.php
示例6: doUpdate
/**
* Purges the list of URLs passed to the constructor.
*/
public function doUpdate()
{
global $wgCdnReboundPurgeDelay;
self::purge($this->urls);
if ($wgCdnReboundPurgeDelay > 0) {
JobQueueGroup::singleton()->lazyPush(new CdnPurgeJob(Title::makeTitle(NS_SPECIAL, 'Badtitle/' . __CLASS__), array('urls' => $this->urls, 'jobReleaseTimestamp' => time() + $wgCdnReboundPurgeDelay)));
}
}
开发者ID:OrBin,项目名称:mediawiki,代码行数:11,代码来源:CdnCacheUpdate.php
示例7: insert
/**
* Usually this job is fast enough to be executed immediately,
* in which case having it go through jobqueue only causes problems
* in installations with errant job queue processing.
* @override
*/
public function insert()
{
global $wgTranslateDelayedMessageIndexRebuild;
if ($wgTranslateDelayedMessageIndexRebuild) {
JobQueueGroup::singleton()->push($this);
} else {
$this->run();
}
}
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:15,代码来源:MessageIndexRebuildJob.php
示例8: testInsertDelayed
public function testInsertDelayed()
{
global $wgTranslateDelayedMessageIndexRebuild;
$wgTranslateDelayedMessageIndexRebuild = true;
MessageIndexRebuildJob::newJob()->insert();
$job = JobQueueGroup::singleton()->get('MessageIndexRebuildJob')->pop();
$this->assertInstanceOf('MessageIndexRebuildJob', $job, 'There is a job in the JobQueue');
$this->assertTrue($job->run(), 'Job is executed succesfully');
}
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:9,代码来源:MessageIndexRebuildJobTest.php
示例9: run
public function run()
{
foreach ($this->params['jobsByWiki'] as $wiki => $jobMaps) {
$jobSpecs = array();
foreach ($jobMaps as $jobMap) {
$jobSpecs[] = JobSpecification::newFromArray($jobMap);
}
JobQueueGroup::singleton($wiki)->push($jobSpecs);
}
return true;
}
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:11,代码来源:EnqueueJob.php
示例10: execute
public function execute()
{
global $wgTitle;
if ($this->hasOption('procs')) {
$procs = intval($this->getOption('procs'));
if ($procs < 1 || $procs > 1000) {
$this->error("Invalid argument to --procs", true);
}
$fc = new ForkController($procs);
if ($fc->start() != 'child') {
exit(0);
}
}
$maxJobs = $this->getOption('maxjobs', false);
$maxTime = $this->getOption('maxtime', false);
$startTime = time();
$type = $this->getOption('type', false);
$wgTitle = Title::newFromText('RunJobs.php');
$dbw = wfGetDB(DB_MASTER);
$n = 0;
$group = JobQueueGroup::singleton();
do {
$job = $type === false ? $group->pop() : $group->get($type)->pop();
// job from a single queue
if ($job) {
// found a job
// Perform the job (logging success/failure and runtime)...
$t = microtime(true);
$this->runJobsLog($job->toString() . " STARTING");
$status = $job->run();
$group->ack($job);
// done
$t = microtime(true) - $t;
$timeMs = intval($t * 1000);
if (!$status) {
$this->runJobsLog($job->toString() . " t={$timeMs} error={$job->error}");
} else {
$this->runJobsLog($job->toString() . " t={$timeMs} good");
}
// Break out if we hit the job count or wall time limits...
if ($maxJobs && ++$n >= $maxJobs) {
break;
}
if ($maxTime && time() - $startTime > $maxTime) {
break;
}
// Don't let any slaves/backups fall behind...
$group->get($type)->waitForBackups();
}
} while ($job);
// stop when there are no jobs
}
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:52,代码来源:runJobs.php
示例11: run
public function run()
{
if ($this->params['usleep'] > 0) {
usleep($this->params['usleep']);
}
if ($this->params['lives'] > 1) {
$params = $this->params;
$params['lives']--;
$job = new self($this->title, $params);
JobQueueGroup::singleton()->push($job);
}
return true;
}
开发者ID:paladox,项目名称:mediawiki,代码行数:13,代码来源:NullJob.php
示例12: run
/**
* Queue some more jobs!
*
* @return bool
*/
public function run()
{
$data = $this->params['data'];
$pages = $this->params['pages'];
$jobsByTarget = array();
foreach ($pages as $page) {
$title = Title::newFromText($page['title']);
$jobsByTarget[$page['wiki']][] = new MassMessageJob($title, $data);
}
foreach ($jobsByTarget as $wiki => $jobs) {
JobQueueGroup::singleton($wiki)->push($jobs);
}
return true;
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:19,代码来源:MassMessageSubmitJob.php
示例13: doUpdate
public function doUpdate()
{
$job = new HTMLCacheUpdateJob($this->mTitle, array('table' => $this->mTable, 'recursive' => true) + Job::newRootJobParams("htmlCacheUpdate:{$this->mTable}:{$this->mTitle->getPrefixedText()}"));
$count = $this->mTitle->getBacklinkCache()->getNumLinks($this->mTable, 100);
if ($count >= 100) {
// many backlinks
JobQueueGroup::singleton()->lazyPush($job);
} else {
// few backlinks ($count might be off even if 0)
$dbw = wfGetDB(DB_MASTER);
$dbw->onTransactionIdle(function () use($job) {
$job->run();
// just do the purge query now
});
}
}
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:16,代码来源:HTMLCacheUpdate.php
示例14: run
/**
* Run a refreshLinks2 job
* @return boolean success
*/
function run()
{
global $wgUpdateRowsPerJob;
$linkCache = LinkCache::singleton();
$linkCache->clear();
if (is_null($this->title)) {
$this->error = "refreshLinks2: Invalid title";
return false;
}
// Back compat for pre-r94435 jobs
$table = isset($this->params['table']) ? $this->params['table'] : 'templatelinks';
// Avoid slave lag when fetching templates.
// When the outermost job is run, we know that the caller that enqueued it must have
// committed the relevant changes to the DB by now. At that point, record the master
// position and pass it along as the job recursively breaks into smaller range jobs.
// Hopefully, when leaf jobs are popped, the slaves will have reached that position.
if (isset($this->params['masterPos'])) {
$masterPos = $this->params['masterPos'];
} elseif (wfGetLB()->getServerCount() > 1) {
$masterPos = wfGetLB()->getMasterPos();
} else {
$masterPos = false;
}
$tbc = $this->title->getBacklinkCache();
$jobs = array();
// jobs to insert
if (isset($this->params['start']) && isset($this->params['end'])) {
# This is a partition job to trigger the insertion of leaf jobs...
$jobs = array_merge($jobs, $this->getSingleTitleJobs($table, $masterPos));
} else {
# This is a base job to trigger the insertion of partitioned jobs...
if ($tbc->getNumLinks($table, $wgUpdateRowsPerJob + 1) <= $wgUpdateRowsPerJob) {
# Just directly insert the single per-title jobs
$jobs = array_merge($jobs, $this->getSingleTitleJobs($table, $masterPos));
} else {
# Insert the partition jobs to make per-title jobs
foreach ($tbc->partition($table, $wgUpdateRowsPerJob) as $batch) {
list($start, $end) = $batch;
$jobs[] = new RefreshLinksJob2($this->title, array('table' => $table, 'start' => $start, 'end' => $end, 'masterPos' => $masterPos) + $this->getRootJobParams());
}
}
}
if (count($jobs)) {
JobQueueGroup::singleton()->push($jobs);
}
return true;
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:51,代码来源:RefreshLinksJob2.php
示例15: testTemplateCategories
function testTemplateCategories()
{
$title = Title::newFromText("Categorized from template");
$page = WikiPage::factory($title);
$user = new User();
$user->mRights = array('createpage', 'edit', 'purge');
$page->doEditContent(new WikitextContent('{{Categorising template}}'), 'Create a page with a template', 0, false, $user);
$this->assertEquals(array(), $title->getParentCategories());
$template = WikiPage::factory(Title::newFromText('Template:Categorising template'));
$template->doEditContent(new WikitextContent('[[Category:Solved bugs]]'), 'Add a category through a template', 0, false, $user);
// Run the job queue
JobQueueGroup::destroySingletons();
$jobs = new RunJobs();
$jobs->loadParamsAndArgs(null, array('quiet' => true), null);
$jobs->execute();
$this->assertEquals(array('Category:Solved_bugs' => $title->getPrefixedText()), $title->getParentCategories());
}
开发者ID:mangowi,项目名称:mediawiki,代码行数:17,代码来源:TemplateCategoriesTest.php
示例16: execute
/**
* Show the special page
*
* @param $params Mixed: parameter(s) passed to the page or null
*/
public function execute($params)
{
$out = $this->getOutput();
$request = $this->getRequest();
$user = $this->getUser();
// If the user doesn't have the required 'SendToFollowers' permission, display an error
if (!$user->isAllowed('SendToFollowers')) {
$out->permissionRequired('SendToFollowers');
return;
}
// Set the page title, robot policies, etc.
$this->setHeaders();
// This feature is available only to logged-in users.
if (!$user->isLoggedIn()) {
$out->setPageTitle($this->msg('boardblastlogintitle')->plain());
$out->addWikiMsg('boardblastlogintext');
return '';
}
// Is the database locked?
if (wfReadOnly()) {
$out->readOnlyPage();
return false;
}
// Blocked through Special:Block? No access for you!
if ($user->isBlocked()) {
$out->blockedPage(false);
return false;
}
// Add CSS & JS
$out->addModuleStyles('ext.socialprofile.userboard.boardblast.css');
$out->addModules('ext.socialprofile.userboard.boardblast.js');
$output = '';
if ($request->wasPosted()) {
$out->setPageTitle($this->msg('messagesenttitle')->plain());
$message = $request->getVal('message');
$user_ids_to = explode(',', $request->getVal('ids'));
$jobParams = array('user_ids_to' => $user_ids_to, 'message' => $message, 'sender' => $user->getId());
$job = new BoardBlastJobs($this->getTitle(), $jobParams);
JobQueueGroup::singleton()->push($job);
$output .= $this->msg('messagesentsuccess')->plain();
} else {
$out->setPageTitle($this->msg('boardblasttitle')->plain());
$output .= $this->displayForm();
}
$out->addHTML($output);
}
开发者ID:Reasno,项目名称:SocialProfile,代码行数:51,代码来源:SpecialSendToFollowers.php
示例17: doUpdate
public function doUpdate()
{
global $wgMaxBacklinksInvalidate;
wfProfileIn(__METHOD__);
$job = new HTMLCacheUpdateJob($this->mTitle, array('table' => $this->mTable) + Job::newRootJobParams("htmlCacheUpdate:{$this->mTable}:{$this->mTitle->getPrefixedText()}"));
$count = $this->mTitle->getBacklinkCache()->getNumLinks($this->mTable, 200);
if ($wgMaxBacklinksInvalidate !== false && $count > $wgMaxBacklinksInvalidate) {
wfDebug("Skipped HTML cache invalidation of {$this->mTitle->getPrefixedText()}.");
} elseif ($count >= 200) {
// many backlinks
JobQueueGroup::singleton()->push($job);
JobQueueGroup::singleton()->deduplicateRootJob($job);
} else {
// few backlinks ($count might be off even if 0)
$job->run();
// just do the purge query now
}
wfProfileOut(__METHOD__);
}
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:19,代码来源:HTMLCacheUpdate.php
示例18: execute
public function execute()
{
$typeFilter = $this->getOption('type', '');
$stateFilter = $this->getOption('status', '');
$stateLimit = (double) $this->getOption('limit', INF);
$group = JobQueueGroup::singleton();
$filteredTypes = $typeFilter ? array($typeFilter) : $group->getQueueTypes();
$filteredStates = $stateFilter ? array_intersect_key(self::$stateMethods, array($stateFilter => 1)) : self::$stateMethods;
if ($this->hasOption('list')) {
$count = 0;
foreach ($filteredTypes as $type) {
$queue = $group->get($type);
foreach ($filteredStates as $state => $method) {
foreach ($queue->{$method}() as $job) {
/** @var Job $job */
$this->output($job->toString() . " status={$state}\n");
if (++$count >= $stateLimit) {
return;
}
}
}
}
} elseif ($this->hasOption('group')) {
foreach ($filteredTypes as $type) {
$queue = $group->get($type);
$delayed = $queue->getDelayedCount();
$pending = $queue->getSize();
$claimed = $queue->getAcquiredCount();
$abandoned = $queue->getAbandonedCount();
$active = max(0, $claimed - $abandoned);
if ($pending + $claimed + $delayed + $abandoned > 0) {
$this->output("{$type}: {$pending} queued; " . "{$claimed} claimed ({$active} active, {$abandoned} abandoned); " . "{$delayed} delayed\n");
}
}
} else {
$count = 0;
foreach ($filteredTypes as $type) {
$count += $group->get($type)->getSize();
}
$this->output("{$count}\n");
}
}
开发者ID:admonkey,项目名称:mediawiki,代码行数:42,代码来源:showJobs.php
示例19: execute
public function execute()
{
$group = JobQueueGroup::singleton();
if ($this->hasOption('group')) {
foreach ($group->getQueueTypes() as $type) {
$queue = $group->get($type);
$pending = $queue->getSize();
$claimed = $queue->getAcquiredCount();
if ($pending + $claimed > 0) {
$this->output("{$type}: {$pending} queued; {$claimed} acquired\n");
}
}
} else {
$count = 0;
foreach ($group->getQueueTypes() as $type) {
$count += $group->get($type)->getSize();
}
$this->output("{$count}\n");
}
}
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:20,代码来源:showJobs.php
示例20: run
function run()
{
global $wgUpdateRowsPerJob, $wgUpdateRowsPerQuery;
static $expected = array('recursive', 'pages');
// new jobs have one of these
$oldRangeJob = false;
if (!array_intersect(array_keys($this->params), $expected)) {
// B/C for older job params formats that lack these fields:
// a) base jobs with just ("table") and b) range jobs with ("table","start","end")
if (isset($this->params['start']) && isset($this->params['end'])) {
$oldRangeJob = true;
} else {
$this->params['recursive'] = true;
// base job
}
}
// Job to purge all (or a range of) backlink pages for a page
if (!empty($this->params['recursive'])) {
// Convert this into no more than $wgUpdateRowsPerJob HTMLCacheUpdateJob per-title
// jobs and possibly a recursive HTMLCacheUpdateJob job for the rest of the backlinks
$jobs = BacklinkJobUtils::partitionBacklinkJob($this, $wgUpdateRowsPerJob, $wgUpdateRowsPerQuery, array('params' => $this->getRootJobParams()));
JobQueueGroup::singleton()->push($jobs);
// Job to purge pages for for a set of titles
} elseif (isset($this->params['pages'])) {
$this->invalidateTitles($this->params['pages']);
// B/C for job to purge a range of backlink pages for a given page
} elseif ($oldRangeJob) {
$titleArray = $this->title->getBacklinkCache()->getLinks($this->params['table'], $this->params['start'], $this->params['end']);
$pages = array();
// same format BacklinkJobUtils uses
foreach ($titleArray as $tl) {
$pages[$tl->getArticleId()] = array($tl->getNamespace(), $tl->getDbKey());
}
$jobs = array();
foreach (array_chunk($pages, $wgUpdateRowsPerJob) as $pageChunk) {
$jobs[] = new HTMLCacheUpdateJob($this->title, array('table' => $this->params['table'], 'pages' => $pageChunk) + $this->getRootJobParams());
}
JobQueueGroup::singleton()->push($jobs);
}
return true;
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:41,代码来源:HTMLCacheUpdateJob.php
注:本文中的JobQueueGroup类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论