*
* @param Job|array $jobs A single job or an array of Jobs
* @param int $flags Bitfield (supports JobQueue::QOS_ATOMIC)
- * @return bool Returns false on failure
+ * @return void
* @throws JobQueueError
*/
final public function push( $jobs, $flags = 0 ) {
- return $this->batchPush( is_array( $jobs ) ? $jobs : array( $jobs ), $flags );
+ $this->batchPush( is_array( $jobs ) ? $jobs : array( $jobs ), $flags );
}
/**
*
* @param array $jobs List of Jobs
* @param int $flags Bitfield (supports JobQueue::QOS_ATOMIC)
+ * @return void
* @throws MWException
- * @return bool Returns false on failure
*/
final public function batchPush( array $jobs, $flags = 0 ) {
if ( !count( $jobs ) ) {
}
wfProfileIn( __METHOD__ );
- $ok = $this->doBatchPush( $jobs, $flags );
+ $this->doBatchPush( $jobs, $flags );
wfProfileOut( __METHOD__ );
-
- return $ok;
}
/**
* @see JobQueue::batchPush()
* @param array $jobs
* @param $flags
- * @return bool
*/
abstract protected function doBatchPush( array $jobs, $flags );
* Outside callers should use JobQueueGroup::ack() instead of this function.
*
* @param Job $job
+ * @return void
* @throws MWException
- * @return bool
*/
final public function ack( Job $job ) {
if ( $job->getType() !== $this->type ) {
throw new MWException( "Got '{$job->getType()}' job; expected '{$this->type}'." );
}
wfProfileIn( __METHOD__ );
- $ok = $this->doAck( $job );
+ $this->doAck( $job );
wfProfileOut( __METHOD__ );
-
- return $ok;
}
/**
* @see JobQueue::ack()
* @param Job $job
- * @return bool
*/
abstract protected function doAck( Job $job );
/**
* Deleted all unclaimed and delayed jobs from the queue
*
- * @return bool Success
* @throws JobQueueError
* @since 1.22
+ * @return void
*/
final public function delete() {
wfProfileIn( __METHOD__ );
- $res = $this->doDelete();
+ $this->doDelete();
wfProfileOut( __METHOD__ );
-
- return $res;
}
/**
* @see JobQueue::delete()
* @throws MWException
- * @return bool Success
*/
protected function doDelete() {
throw new MWException( "This method is not implemented." );
/** @var JobQueue $queue */
$queue = $this->partitionQueues[$partition];
try {
- $ok = $queue->doBatchPush( $jobBatch, $flags | self::QOS_ATOMIC );
+ $ok = true;
+ $queue->doBatchPush( $jobBatch, $flags | self::QOS_ATOMIC );
} catch ( JobQueueError $e ) {
$ok = false;
MWExceptionHandler::logException( $e );
$partition = ArrayUtils::pickRandom( $partitionRing->getLocationWeights() );
$queue = $this->partitionQueues[$partition];
try {
- $ok = $queue->doBatchPush( $jobBatch, $flags | self::QOS_ATOMIC );
+ $ok = true;
+ $queue->doBatchPush( $jobBatch, $flags | self::QOS_ATOMIC );
} catch ( JobQueueError $e ) {
$ok = false;
MWExceptionHandler::logException( $e );
$this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" );
$this->assertEquals( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" );
- $this->assertTrue( $queue->push( $this->newJob() ), "Push worked ($desc)" );
- $this->assertTrue( $queue->batchPush( array( $this->newJob() ) ), "Push worked ($desc)" );
+ $this->assertNull( $queue->push( $this->newJob() ), "Push worked ($desc)" );
+ $this->assertNull( $queue->batchPush( array( $this->newJob() ) ), "Push worked ($desc)" );
$this->assertFalse( $queue->isEmpty(), "Queue is not empty ($desc)" );
$queue->flushCaches();
$this->assertEquals( 0, $queue->getAcquiredCount(), "Active job count ($desc)" );
- $this->assertTrue( $queue->batchPush( array( $this->newJob(), $this->newJob() ) ),
+ $this->assertNull( $queue->batchPush( array( $this->newJob(), $this->newJob() ) ),
"Push worked ($desc)" );
$this->assertFalse( $queue->isEmpty(), "Queue is not empty ($desc)" );
$this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" );
$this->assertEquals( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" );
- $this->assertTrue(
+ $this->assertNull(
$queue->batchPush(
array( $this->newDedupedJob(), $this->newDedupedJob(), $this->newDedupedJob() )
),
$this->assertEquals( 1, $queue->getSize(), "Queue size is correct ($desc)" );
$this->assertEquals( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" );
- $this->assertTrue(
+ $this->assertNull(
$queue->batchPush(
array( $this->newDedupedJob(), $this->newDedupedJob(), $this->newDedupedJob() )
),
$id = wfRandomString( 32 );
$root1 = Job::newRootJobParams( "nulljobspam:$id" ); // task ID/timestamp
for ( $i = 0; $i < 5; ++$i ) {
- $this->assertTrue( $queue->push( $this->newJob( 0, $root1 ) ), "Push worked ($desc)" );
+ $this->assertNull( $queue->push( $this->newJob( 0, $root1 ) ), "Push worked ($desc)" );
}
$queue->deduplicateRootJob( $this->newJob( 0, $root1 ) );
sleep( 1 ); // roo job timestamp will increase
$this->assertNotEquals( $root1['rootJobTimestamp'], $root2['rootJobTimestamp'],
"Root job signatures have different timestamps." );
for ( $i = 0; $i < 5; ++$i ) {
- $this->assertTrue( $queue->push( $this->newJob( 0, $root2 ) ), "Push worked ($desc)" );
+ $this->assertNull( $queue->push( $this->newJob( 0, $root2 ) ), "Push worked ($desc)" );
}
$queue->deduplicateRootJob( $this->newJob( 0, $root2 ) );
$this->assertEquals( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" );
for ( $i = 0; $i < 10; ++$i ) {
- $this->assertTrue( $queue->push( $this->newJob( $i ) ), "Push worked ($desc)" );
+ $this->assertNull( $queue->push( $this->newJob( $i ) ), "Push worked ($desc)" );
}
for ( $i = 0; $i < 10; ++$i ) {