public function processRecord(array $record) { if ($this->job) { $record['job'] = $this->job->getLogData(); } return $record; }
/** * @param JobInterface $job * @return string jobId */ public function update(JobInterface $job) { $job->validate(); $params = ['index' => $job->getIndex(), 'type' => $job->getType(), 'id' => $job->getId(), 'body' => ['doc' => $job->getData()]]; $response = null; $i = 0; while ($i < 5) { try { $response = $this->client->update($params); break; } catch (ServerErrorResponseException $e) { // ES server error, try again $this->log('error', 'Elastic server error response', ['attemptNo' => $i, 'jobId' => $job->getId(), 'exception' => $e]); } sleep(1 + intval(pow(2, $i) / 2)); $i++; } //@todo: remove sleep in next (major) release sleep(1); $i = 0; while ($i < 5) { $resJob = $this->get($job->getId()); if ($resJob != null && $resJob->getVersion() >= $response['_version']) { return $response['_id']; } sleep(1 + intval(pow(2, $i) / 2)); $i++; } throw new ApplicationException("Unable to find job after update", null, ['job' => $job->getData(), 'elasticResponse' => $response]); }
private function assertJob(JobInterface $job, $resJob) { $this->assertEquals($job->getId(), $resJob['id']); $this->assertEquals($job->getRunId(), $resJob['runId']); $this->assertEquals($job->getLockName(), $resJob['lockName']); $this->assertEquals($job->getProject()['id'], $resJob['project']['id']); $this->assertEquals($job->getProject()['name'], $resJob['project']['name']); $this->assertEquals($job->getToken()['id'], $resJob['token']['id']); $this->assertEquals($job->getToken()['description'], $resJob['token']['description']); $this->assertEquals($job->getToken()['token'], $resJob['token']['token']); $this->assertEquals($job->getComponent(), $resJob['component']); $this->assertEquals($job->getStatus(), $resJob['status']); $this->assertEquals($job->getParams(), $resJob['params']); $this->assertEquals(substr_count($job->getRunId(), '.'), $resJob['nestingLevel']); $this->assertArrayHasKey('terminatedBy', $resJob); $this->assertArrayHasKey('error', $resJob); $this->assertArrayHasKey('errorNote', $resJob); }