aboutsummaryrefslogtreecommitdiffstats
path: root/includes/jobqueue
diff options
context:
space:
mode:
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>2015-06-03 17:38:35 +0000
committerGerrit Code Review <gerrit@wikimedia.org>2015-06-03 17:38:35 +0000
commitc3f5ee0973fba27bab9a50f83eb637de72f7c659 (patch)
tree04577da2b3ba872db4b1b4acd24f83a9eac076a3 /includes/jobqueue
parent6fa489392815c7c0139a8a2df6447dfff24004ed (diff)
parent22734b3c0f0348804a9cbc72c5bc7a70179a02be (diff)
downloadmediawikicore-c3f5ee0973fba27bab9a50f83eb637de72f7c659.tar.gz
mediawikicore-c3f5ee0973fba27bab9a50f83eb637de72f7c659.zip
Merge "Let deduplicateRootJob() accept JobSpecification for consistency"
Diffstat (limited to 'includes/jobqueue')
-rw-r--r--includes/jobqueue/JobQueue.php8
-rw-r--r--includes/jobqueue/JobQueueDB.php4
-rw-r--r--includes/jobqueue/JobQueueFederated.php2
-rw-r--r--includes/jobqueue/JobQueueRedis.php4
-rw-r--r--includes/jobqueue/JobSpecification.php53
5 files changed, 39 insertions, 32 deletions
diff --git a/includes/jobqueue/JobQueue.php b/includes/jobqueue/JobQueue.php
index 73ca3a8eaa99..1a68489924ed 100644
--- a/includes/jobqueue/JobQueue.php
+++ b/includes/jobqueue/JobQueue.php
@@ -425,11 +425,11 @@ abstract class JobQueue {
*
* This does nothing for certain queue classes.
*
- * @param Job $job
+ * @param IJobSpecification $job
* @throws MWException
* @return bool
*/
- final public function deduplicateRootJob( Job $job ) {
+ final public function deduplicateRootJob( IJobSpecification $job ) {
if ( $job->getType() !== $this->type ) {
throw new MWException( "Got '{$job->getType()}' job; expected '{$this->type}'." );
}
@@ -440,11 +440,11 @@ abstract class JobQueue {
/**
* @see JobQueue::deduplicateRootJob()
- * @param Job $job
+ * @param IJobSpecification $job
* @throws MWException
* @return bool
*/
- protected function doDeduplicateRootJob( Job $job ) {
+ protected function doDeduplicateRootJob( IJobSpecification $job ) {
if ( !$job->hasRootJobParams() ) {
throw new MWException( "Cannot register root job; missing parameters." );
}
diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php
index 491092acb1e8..e094850c1c96 100644
--- a/includes/jobqueue/JobQueueDB.php
+++ b/includes/jobqueue/JobQueueDB.php
@@ -488,11 +488,11 @@ class JobQueueDB extends JobQueue {
/**
* @see JobQueue::doDeduplicateRootJob()
- * @param Job $job
+ * @param IJobSpecification $job
* @throws MWException
* @return bool
*/
- protected function doDeduplicateRootJob( Job $job ) {
+ protected function doDeduplicateRootJob( IJobSpecification $job ) {
$params = $job->getParams();
if ( !isset( $params['rootJobSignature'] ) ) {
throw new MWException( "Cannot register root job; missing 'rootJobSignature'." );
diff --git a/includes/jobqueue/JobQueueFederated.php b/includes/jobqueue/JobQueueFederated.php
index a35ab8494085..ecbb0317ae63 100644
--- a/includes/jobqueue/JobQueueFederated.php
+++ b/includes/jobqueue/JobQueueFederated.php
@@ -328,7 +328,7 @@ class JobQueueFederated extends JobQueue {
return false;
}
- protected function doDeduplicateRootJob( Job $job ) {
+ protected function doDeduplicateRootJob( IJobSpecification $job ) {
$params = $job->getRootJobParams();
$sigature = $params['rootJobSignature'];
$partition = $this->partitionRing->getLiveLocation( $sigature );
diff --git a/includes/jobqueue/JobQueueRedis.php b/includes/jobqueue/JobQueueRedis.php
index 2e20660118c1..ea94226fef38 100644
--- a/includes/jobqueue/JobQueueRedis.php
+++ b/includes/jobqueue/JobQueueRedis.php
@@ -402,12 +402,12 @@ LUA;
/**
* @see JobQueue::doDeduplicateRootJob()
- * @param Job $job
+ * @param IJobSpecification $job
* @return bool
* @throws JobQueueError
* @throws LogicException
*/
- protected function doDeduplicateRootJob( Job $job ) {
+ protected function doDeduplicateRootJob( IJobSpecification $job ) {
if ( !$job->hasRootJobParams() ) {
throw new LogicException( "Cannot register root job; missing parameters." );
}
diff --git a/includes/jobqueue/JobSpecification.php b/includes/jobqueue/JobSpecification.php
index 9ace1ba54e71..ecace3a3ee15 100644
--- a/includes/jobqueue/JobSpecification.php
+++ b/includes/jobqueue/JobSpecification.php
@@ -59,6 +59,20 @@ interface IJobSpecification {
public function getDeduplicationInfo();
/**
+ * @see JobQueue::deduplicateRootJob()
+ * @return array
+ * @since 1.26
+ */
+ public function getRootJobParams();
+
+ /**
+ * @see JobQueue::deduplicateRootJob()
+ * @return bool
+ * @since 1.22
+ */
+ public function hasRootJobParams();
+
+ /**
* @return Title Descriptive title (this can simply be informative)
*/
public function getTitle();
@@ -125,51 +139,28 @@ class JobSpecification implements IJobSpecification {
}
}
- /**
- * @return string
- */
public function getType() {
return $this->type;
}
- /**
- * @return Title
- */
public function getTitle() {
return $this->title;
}
- /**
- * @return array
- */
public function getParams() {
return $this->params;
}
- /**
- * @return int|null UNIX timestamp to delay running this job until, otherwise null
- */
public function getReleaseTimestamp() {
return isset( $this->params['jobReleaseTimestamp'] )
? wfTimestampOrNull( TS_UNIX, $this->params['jobReleaseTimestamp'] )
: null;
}
- /**
- * @return bool Whether only one of each identical set of jobs should be run
- */
public function ignoreDuplicates() {
return !empty( $this->opts['removeDuplicates'] );
}
- /**
- * Subclasses may need to override this to make duplication detection work.
- * The resulting map conveys everything that makes the job unique. This is
- * only checked if ignoreDuplicates() returns true, meaning that duplicate
- * jobs are supposed to be ignored.
- *
- * @return array Map of key/values
- */
public function getDeduplicationInfo() {
$info = array(
'type' => $this->getType(),
@@ -188,6 +179,22 @@ class JobSpecification implements IJobSpecification {
return $info;
}
+ public function getRootJobParams() {
+ return array(
+ 'rootJobSignature' => isset( $this->params['rootJobSignature'] )
+ ? $this->params['rootJobSignature']
+ : null,
+ 'rootJobTimestamp' => isset( $this->params['rootJobTimestamp'] )
+ ? $this->params['rootJobTimestamp']
+ : null
+ );
+ }
+
+ public function hasRootJobParams() {
+ return isset( $this->params['rootJobSignature'] )
+ && isset( $this->params['rootJobTimestamp'] );
+ }
+
/**
* @return array Field/value map that can immediately be serialized
* @since 1.25