@@ -108,6 +108,11 @@ |
||
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
111 | + /** |
|
112 | + * @param integer|null $time |
|
113 | + * @param string $method |
|
114 | + * @param integer $priority |
|
115 | + */ |
|
111 | 116 | protected function assertJob(Job $job, $time, $method, $priority = null) |
112 | 117 | { |
113 | 118 | $this->assertNotEmpty($job->getId(), 'Job should have an id'); |
@@ -31,8 +31,8 @@ |
||
31 | 31 | ->end() |
32 | 32 | ->arrayNode('beanstalkd') |
33 | 33 | ->children() |
34 | - ->scalarNode('host')->end() |
|
35 | - ->scalarNode('tube')->end() |
|
34 | + ->scalarNode('host')->end() |
|
35 | + ->scalarNode('tube')->end() |
|
36 | 36 | ->end() |
37 | 37 | ->end() |
38 | 38 | ->arrayNode('rabbit_mq') |
@@ -64,7 +64,7 @@ |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | - * @param array $matches |
|
67 | + * @param string[] $matches |
|
68 | 68 | * @param OutputInterface $output |
69 | 69 | * |
70 | 70 | * @return int |
@@ -83,6 +83,9 @@ discard block |
||
83 | 83 | ->setDescription('Start up a job in queue'); |
84 | 84 | } |
85 | 85 | |
86 | + /** |
|
87 | + * @param double $start |
|
88 | + */ |
|
86 | 89 | protected function runJobById($start, $jobId) |
87 | 90 | { |
88 | 91 | $this->runStart($start); |
@@ -106,6 +109,10 @@ discard block |
||
106 | 109 | return; |
107 | 110 | } |
108 | 111 | |
112 | + /** |
|
113 | + * @param string $varName |
|
114 | + * @param integer $pow |
|
115 | + */ |
|
109 | 116 | private function validateIntNull($varName, $var, $pow) |
110 | 117 | { |
111 | 118 | if (null === $var) { |
@@ -122,6 +129,9 @@ discard block |
||
122 | 129 | return intval($var); |
123 | 130 | } |
124 | 131 | |
132 | + /** |
|
133 | + * @param string $level |
|
134 | + */ |
|
125 | 135 | public function log($level, $msg, array $context = []) |
126 | 136 | { |
127 | 137 | if ($this->logger) { |
@@ -178,6 +188,12 @@ discard block |
||
178 | 188 | return $this->runLoop($start, $workerName, $methodName, $nanoSleep, $maxCount, $duration); |
179 | 189 | } |
180 | 190 | |
191 | + /** |
|
192 | + * @param double $start |
|
193 | + * @param null|integer $nanoSleep |
|
194 | + * @param null|integer $maxCount |
|
195 | + * @param null|integer $duration |
|
196 | + */ |
|
181 | 197 | protected function runLoop($start, $workerName, $methodName, $nanoSleep, $maxCount, $duration) |
182 | 198 | { |
183 | 199 | $container = $this->getContainer(); |
@@ -172,7 +172,7 @@ |
||
172 | 172 | set_time_limit($processTimeout); // Set timeout on the process |
173 | 173 | |
174 | 174 | if ($jobId = $input->getOption('id')) { |
175 | - return $this->runJobById($start, $jobId); // Run a single job |
|
175 | + return $this->runJobById($start, $jobId); // Run a single job |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | return $this->runLoop($start, $workerName, $methodName, $nanoSleep, $maxCount, $duration); |
@@ -22,6 +22,12 @@ discard block |
||
22 | 22 | protected $runClass; |
23 | 23 | protected $runArchiveClass; |
24 | 24 | |
25 | + /** |
|
26 | + * @param string $objectName |
|
27 | + * @param string $archiveObjectName |
|
28 | + * @param string $runClass |
|
29 | + * @param string $runArchiveClass |
|
30 | + */ |
|
25 | 31 | public function __construct(ObjectManager $objectManager, |
26 | 32 | $objectName, |
27 | 33 | $archiveObjectName, |
@@ -83,6 +89,9 @@ discard block |
||
83 | 89 | return $this->getObjectManager()->getRepository($this->getObjectName()); |
84 | 90 | } |
85 | 91 | |
92 | + /** |
|
93 | + * @param string $objectName |
|
94 | + */ |
|
86 | 95 | abstract protected function countJobsByStatus($objectName, $status, $workerName = null, $method = null); |
87 | 96 | |
88 | 97 | public function resetErroneousJobs($workerName = null, $method = null) |
@@ -181,6 +190,10 @@ discard block |
||
181 | 190 | return $countProcessed; |
182 | 191 | } |
183 | 192 | |
193 | + /** |
|
194 | + * @param string $workerName |
|
195 | + * @param string $method |
|
196 | + */ |
|
184 | 197 | public function pruneStalledJobs($workerName = null, $method = null) |
185 | 198 | { |
186 | 199 | $stalledJobs = $this->getStalledJobs($workerName, $method); |
@@ -246,8 +259,15 @@ discard block |
||
246 | 259 | return $job; |
247 | 260 | } |
248 | 261 | |
262 | + /** |
|
263 | + * @param string $objectName |
|
264 | + */ |
|
249 | 265 | abstract protected function stopIdGenerator($objectName); |
250 | 266 | |
267 | + /** |
|
268 | + * @param integer $limit |
|
269 | + * @param integer $offset |
|
270 | + */ |
|
251 | 271 | private function resetJobsByCriterion( |
252 | 272 | $criterion, |
253 | 273 | $limit, |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | $countProcessed = 0; |
168 | 168 | for ($i = 0, $count = count($stalledJobs); $i < $count; $i += static::FETCH_COUNT) { |
169 | - for ($j = $i, $max = $i + static::FETCH_COUNT; $j < $max && $j < $count; ++$j ) { |
|
169 | + for ($j = $i, $max = $i + static::FETCH_COUNT; $j < $max && $j < $count; ++$j) { |
|
170 | 170 | $job = $stalledJobs[$j]; |
171 | 171 | /* Job $job */ |
172 | 172 | $job->setStatus(Job::STATUS_NEW); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | |
189 | 189 | $countProcessed = 0; |
190 | 190 | for ($i = 0, $count = count($stalledJobs); $i < $count; $i += static::FETCH_COUNT) { |
191 | - for ($j = $i, $max = $i + static::FETCH_COUNT; $j < $max && $j < $count; ++$j ) { |
|
191 | + for ($j = $i, $max = $i + static::FETCH_COUNT; $j < $max && $j < $count; ++$j) { |
|
192 | 192 | $job = $stalledJobs[$j]; |
193 | 193 | $objectManager->remove($job); |
194 | 194 | ++$countProcessed; |
@@ -31,6 +31,9 @@ discard block |
||
31 | 31 | return $query->count(); |
32 | 32 | } |
33 | 33 | |
34 | + /** |
|
35 | + * @param string $objectName |
|
36 | + */ |
|
34 | 37 | public function stopIdGenerator($objectName) |
35 | 38 | { |
36 | 39 | $objectManager = $this->getObjectManager(); |
@@ -40,6 +43,10 @@ discard block |
||
40 | 43 | $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE); |
41 | 44 | } |
42 | 45 | |
46 | + /** |
|
47 | + * @param string $workerName |
|
48 | + * @param string $method |
|
49 | + */ |
|
43 | 50 | public function pruneErroneousJobs($workerName = null, $method = null) |
44 | 51 | { |
45 | 52 | /** @var DocumentManager $objectManager */ |
@@ -67,6 +74,8 @@ discard block |
||
67 | 74 | |
68 | 75 | /** |
69 | 76 | * Prunes expired jobs. |
77 | + * @param string $workerName |
|
78 | + * @param string $method |
|
70 | 79 | */ |
71 | 80 | public function pruneExpiredJobs($workerName = null, $method = null) |
72 | 81 | { |
@@ -148,6 +157,7 @@ discard block |
||
148 | 157 | |
149 | 158 | /** |
150 | 159 | * Get Status Jobs. |
160 | + * @param string $documentName |
|
151 | 161 | */ |
152 | 162 | protected function getStatusByDocument($documentName) |
153 | 163 | { |
@@ -54,6 +54,10 @@ discard block |
||
54 | 54 | return $count; |
55 | 55 | } |
56 | 56 | |
57 | + /** |
|
58 | + * @param string $workerName |
|
59 | + * @param string $method |
|
60 | + */ |
|
57 | 61 | public function pruneErroneousJobs($workerName = null, $method = null) |
58 | 62 | { |
59 | 63 | /** @var EntityManager $objectManager */ |
@@ -76,6 +80,10 @@ discard block |
||
76 | 80 | return $query->execute(); |
77 | 81 | } |
78 | 82 | |
83 | + /** |
|
84 | + * @param string $workerName |
|
85 | + * @param string $method |
|
86 | + */ |
|
79 | 87 | public function pruneExpiredJobs($workerName = null, $method = null) |
80 | 88 | { |
81 | 89 | /** @var EntityManager $objectManager */ |
@@ -181,6 +189,9 @@ discard block |
||
181 | 189 | return $finalResult; |
182 | 190 | } |
183 | 191 | |
192 | + /** |
|
193 | + * @param string $entityName |
|
194 | + */ |
|
184 | 195 | protected function getStatusByEntityName($entityName, array &$result) |
185 | 196 | { |
186 | 197 | /** @var EntityManager $objectManager */ |
@@ -207,7 +218,7 @@ discard block |
||
207 | 218 | * @param string $methodName |
208 | 219 | * @param bool $prioritize |
209 | 220 | * |
210 | - * @return \Dtc\QueueBundle\Model\Job|null |
|
221 | + * @return Job|null |
|
211 | 222 | */ |
212 | 223 | public function getJob($workerName = null, $methodName = null, $prioritize = true, $runId = null) |
213 | 224 | { |
@@ -130,7 +130,7 @@ |
||
130 | 130 | if ($method) { |
131 | 131 | $qb->where($qb->expr()->andX( |
132 | 132 | $qb->expr()->eq('j.workerName', ':workerName'), |
133 | - $qb->expr()->eq('j.method', ':method') |
|
133 | + $qb->expr()->eq('j.method', ':method') |
|
134 | 134 | )) |
135 | 135 | ->setParameter(':method', $method); |
136 | 136 | } else { |
@@ -29,11 +29,26 @@ discard block |
||
29 | 29 | $this->pid = getmypid(); |
30 | 30 | } |
31 | 31 | |
32 | + /** |
|
33 | + * @param string $exchange |
|
34 | + * @param string $type |
|
35 | + * @param boolean $passive |
|
36 | + * @param boolean $durable |
|
37 | + * @param boolean $autoDelete |
|
38 | + */ |
|
32 | 39 | public function setExchangeArgs($exchange, $type, $passive, $durable, $autoDelete) |
33 | 40 | { |
34 | 41 | $this->exchangeArgs = func_get_args(); |
35 | 42 | } |
36 | 43 | |
44 | + /** |
|
45 | + * @param string $queue |
|
46 | + * @param boolean $passive |
|
47 | + * @param boolean $durable |
|
48 | + * @param boolean $exclusive |
|
49 | + * @param boolean $autoDelete |
|
50 | + * @param integer $maxPriority |
|
51 | + */ |
|
37 | 52 | public function setQueueArgs($queue, $passive, $durable, $exclusive, $autoDelete, $maxPriority) |
38 | 53 | { |
39 | 54 | $arguments = func_get_args(); |
@@ -106,6 +121,9 @@ discard block |
||
106 | 121 | return $job; |
107 | 122 | } |
108 | 123 | |
124 | + /** |
|
125 | + * @param string $workerName |
|
126 | + */ |
|
109 | 127 | public function getJob($workerName = null, $methodName = null, $prioritize = true, $runId = null) |
110 | 128 | { |
111 | 129 | if ($methodName) { |
@@ -136,6 +136,9 @@ |
||
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | + /** |
|
140 | + * @param string $method |
|
141 | + */ |
|
139 | 142 | protected function expectingException($method) |
140 | 143 | { |
141 | 144 | try { |
@@ -156,7 +156,7 @@ |
||
156 | 156 | |
157 | 157 | $start = microtime(true); |
158 | 158 | $jobsTotal = 100; // have to trim this down as Travis is slow. |
159 | - self::$jobManager->enableSorting = false; // Ignore priority |
|
159 | + self::$jobManager->enableSorting = false; // Ignore priority |
|
160 | 160 | |
161 | 161 | for ($i = 0; $i < $jobsTotal; ++$i) { |
162 | 162 | $startLater = microtime(true); |