/** * @see JobQueue::deduplicateRootJob() * @param IJobSpecification $job * @throws MWException * @return bool */ protected function doDeduplicateRootJob(IJobSpecification $job) { if (!$job->hasRootJobParams()) { throw new MWException("Cannot register root job; missing parameters."); } $params = $job->getRootJobParams(); $key = $this->getRootJobCacheKey($params['rootJobSignature']); // Callers should call batchInsert() and then this function so that if the insert // fails, the de-duplication registration will be aborted. Since the insert is // deferred till "transaction idle", do the same here, so that the ordering is // maintained. Having only the de-duplication registration succeed would cause // jobs to become no-ops without any actual jobs that made them redundant. $timestamp = $this->dupCache->get($key); // current last timestamp of this job if ($timestamp && $timestamp >= $params['rootJobTimestamp']) { return true; // a newer version of this root job was enqueued } // Update the timestamp of the last root job started at the location... return $this->dupCache->set($key, $params['rootJobTimestamp'], JobQueueDB::ROOTJOB_TTL); }
/** * @see JobQueue::doDeduplicateRootJob() * @param IJobSpecification $job * @return bool * @throws JobQueueError * @throws LogicException */ protected function doDeduplicateRootJob(IJobSpecification $job) { if (!$job->hasRootJobParams()) { throw new LogicException("Cannot register root job; missing parameters."); } $params = $job->getRootJobParams(); $key = $this->getRootJobCacheKey($params['rootJobSignature']); $conn = $this->getConnection(); try { $timestamp = $conn->get($key); // current last timestamp of this job if ($timestamp && $timestamp >= $params['rootJobTimestamp']) { return true; // a newer version of this root job was enqueued } // Update the timestamp of the last root job started at the location... return $conn->set($key, $params['rootJobTimestamp'], self::ROOTJOB_TTL); // 2 weeks } catch (RedisException $e) { $this->throwRedisException($conn, $e); } }
protected function doDeduplicateRootJob(IJobSpecification $job) { $params = $job->getRootJobParams(); $sigature = $params['rootJobSignature']; $partition = $this->partitionRing->getLiveLocation($sigature); try { return $this->partitionQueues[$partition]->doDeduplicateRootJob($job); } catch (JobQueueError $e) { if ($this->partitionRing->ejectFromLiveRing($partition, 5)) { $partition = $this->partitionRing->getLiveLocation($sigature); return $this->partitionQueues[$partition]->doDeduplicateRootJob($job); } } return false; }