use of uk.gov.gchq.gaffer.jobtracker.JobDetail in project Gaffer by gchq.
the class Graph method executeJob.
/**
* Performs the given operation chain job on the store.
* If the operation does not have a view then the graph view is used.
* NOTE the operationChain may be modified/optimised by the store.
*
* @param operationChain the operation chain to be executed.
* @param user the user executing the job.
* @return the job details
* @throws OperationException thrown if the job fails to run.
*/
public JobDetail executeJob(final OperationChain<?> operationChain, final User user) throws OperationException {
updateOperationChainView(operationChain);
for (final GraphHook graphHook : graphHooks) {
graphHook.preExecute(operationChain, user);
}
JobDetail result = store.executeJob(operationChain, user);
for (final GraphHook graphHook : graphHooks) {
result = graphHook.postExecute(result, operationChain, user);
}
return result;
}
use of uk.gov.gchq.gaffer.jobtracker.JobDetail in project Gaffer by gchq.
the class JcsJobTrackerIT method shouldAddJobIdToJobTrackerWhenExecute.
@Test
public void shouldAddJobIdToJobTrackerWhenExecute() throws OperationException, IOException, InterruptedException {
// Given
final OperationChain<JobDetail> opChain = new OperationChain.Builder().first(new GetAllEdges()).then(new GetJobDetails()).build();
final User user = new User("user01");
// When
final JobDetail jobDetails = graph.execute(opChain, user);
final String jobId = jobDetails.getJobId();
final JobDetail expectedJobDetail = new JobDetail(jobId, user.getUserId(), opChain, JobStatus.RUNNING, null);
expectedJobDetail.setStartTime(jobDetails.getStartTime());
expectedJobDetail.setEndTime(jobDetails.getEndTime());
// Then
assertEquals(expectedJobDetail, jobDetails);
}
use of uk.gov.gchq.gaffer.jobtracker.JobDetail in project Gaffer by gchq.
the class JcsJobTrackerIT method shouldAddJobIdToJobTrackerWhenExecuteJob.
@Test
public void shouldAddJobIdToJobTrackerWhenExecuteJob() throws OperationException, IOException, InterruptedException {
// Given
final OperationChain<CloseableIterable<Edge>> opChain = new OperationChain<>(new GetAllEdges());
final User user = new User("user01");
// When
JobDetail jobDetails = graph.executeJob(opChain, user);
final String jobId = jobDetails.getJobId();
final JobDetail expectedJobDetail = new JobDetail(jobId, user.getUserId(), opChain, JobStatus.FINISHED, null);
expectedJobDetail.setStartTime(jobDetails.getStartTime());
int count = 0;
while (JobStatus.RUNNING == jobDetails.getStatus() && ++count < 20) {
Thread.sleep(100);
jobDetails = graph.execute(new GetJobDetails.Builder().jobId(jobId).build(), user);
}
expectedJobDetail.setEndTime(jobDetails.getEndTime());
// Then
assertEquals(expectedJobDetail, jobDetails);
}
use of uk.gov.gchq.gaffer.jobtracker.JobDetail in project Gaffer by gchq.
the class ExportToGafferResultCacheExample method exportAndGetJobDetails.
public JobDetail exportAndGetJobDetails() {
// ---------------------------------------------------------
final OperationChain<JobDetail> exportOpChain = new OperationChain.Builder().first(new GetAllEdges()).then(new ExportToGafferResultCache()).then(new GetJobDetails()).build();
// ---------------------------------------------------------
jobDetail = runExample(exportOpChain);
return jobDetail;
}
use of uk.gov.gchq.gaffer.jobtracker.JobDetail in project Gaffer by gchq.
the class GetGafferResultCacheExportExample method exportAndGetJobDetails.
public JobDetail exportAndGetJobDetails() {
// ---------------------------------------------------------
final OperationChain<JobDetail> exportOpChain = new OperationChain.Builder().first(new GetAllEdges()).then(new ExportToGafferResultCache()).then(new GetJobDetails()).build();
// ---------------------------------------------------------
jobDetail = runExample(exportOpChain);
return jobDetail;
}
Aggregations