use of uk.gov.gchq.gaffer.jobtracker.JobDetail in project Gaffer by gchq.
the class JobServiceV2IT method shouldNotKeepScheduledJobsRunningAfterRestartWhenUsingInMemoryCache.
@Test
public void shouldNotKeepScheduledJobsRunningAfterRestartWhenUsingInMemoryCache() throws IOException {
// Given - schedule Job
final Repeat repeat = new Repeat(1, 2, TimeUnit.SECONDS);
Job job = new Job(repeat, new OperationChain.Builder().first(new GetAllElements()).build());
final Response scheduleResponse = client.scheduleJob(job);
String parentJobId = scheduleResponse.readEntity(new GenericType<JobDetail>() {
}).getJobId();
// When - get all JobDetails
final Response allJobDetailsResponse = client.executeOperation(new GetAllJobDetails());
List<JobDetail> allJobDetails = allJobDetailsResponse.readEntity(new GenericType<List<JobDetail>>() {
});
// then - assert parent is of Scheduled parent
assertEquals(JobStatus.SCHEDULED_PARENT, allJobDetails.stream().filter(jobDetail -> jobDetail.getJobId().equals(parentJobId)).findFirst().get().getStatus());
// Restart server to check Job still scheduled
client.stopServer();
client.reinitialiseGraph();
// When - get all JobDetails
final Response allJobDetailsResponse2 = client.executeOperation(new GetAllJobDetails());
List<JobDetail> allJobDetails2 = allJobDetailsResponse2.readEntity(new GenericType<List<JobDetail>>() {
});
// Then - assert parent job id is not present
assertTrue(allJobDetails2.stream().noneMatch(jobDetail -> jobDetail.getJobId().equals(parentJobId)));
}
use of uk.gov.gchq.gaffer.jobtracker.JobDetail in project Gaffer by gchq.
the class JobController method startJob.
@Override
public ResponseEntity<JobDetail> startJob(@RequestBody final Operation operation) throws OperationException {
JobDetail jobDetail = graphFactory.getGraph().executeJob(OperationChain.wrap(operation), userFactory.createContext());
URI jobUri = ServletUriComponentsBuilder.fromCurrentRequest().pathSegment(jobDetail.getJobId()).build().toUri();
return ResponseEntity.created(jobUri).header(GAFFER_MEDIA_TYPE_HEADER, GAFFER_MEDIA_TYPE).header(JOB_ID_HEADER, jobDetail.getJobId()).body(jobDetail);
}
Aggregations