use of uk.gov.gchq.gaffer.jobtracker.JobDetail in project gaffer-doc by gchq.
the class ExportToGafferResultCacheExample method exportAndGetJobDetails.
public JobDetail exportAndGetJobDetails() {
// ---------------------------------------------------------
final OperationChain<JobDetail> exportOpChain = new OperationChain.Builder().first(new GetAllElements()).then(new ExportToGafferResultCache<>()).then(new DiscardOutput()).then(new GetJobDetails()).build();
// ---------------------------------------------------------
jobDetail = runExample(exportOpChain, null);
return jobDetail;
}
use of uk.gov.gchq.gaffer.jobtracker.JobDetail in project gaffer-doc by gchq.
the class GetJobResultsExample method runExamples.
@Override
public void runExamples() {
try {
final OperationChain<JobDetail> opChain = new OperationChain.Builder().first(new GetAllElements()).then(new ExportToGafferResultCache<>()).then(new DiscardOutput()).then(new GetJobDetails()).build();
final JobDetail jobDetails = getGraph().execute(opChain, new User("user01"));
jobId = jobDetails.getJobId();
} catch (final OperationException e) {
throw new RuntimeException(e);
}
getJobResults();
}
use of uk.gov.gchq.gaffer.jobtracker.JobDetail in project Gaffer by gchq.
the class Store method addOrUpdateJobDetail.
private JobDetail addOrUpdateJobDetail(final OperationChain<?> operationChain, final Context context, final String msg, final JobStatus jobStatus) {
final JobDetail newJobDetail = new JobDetail(context.getJobId(), context.getUser(), operationChain, jobStatus, msg);
if (null != jobTracker) {
final JobDetail oldJobDetail = jobTracker.getJob(newJobDetail.getJobId(), context.getUser());
if (newJobDetail.getStatus().equals(JobStatus.SCHEDULED_PARENT)) {
newJobDetail.setRepeat(null);
newJobDetail.setSerialisedOperationChain(operationChain);
}
if (null == oldJobDetail) {
jobTracker.addOrUpdateJob(newJobDetail, context.getUser());
} else {
jobTracker.addOrUpdateJob(new JobDetail(oldJobDetail, newJobDetail), context.getUser());
}
}
return newJobDetail;
}
use of uk.gov.gchq.gaffer.jobtracker.JobDetail in project Gaffer by gchq.
the class GetAllJobDetailsHandlerTest method shouldGetAllJobDetailsByDelegatingToJobTracker.
@Test
public void shouldGetAllJobDetailsByDelegatingToJobTracker() throws OperationException {
// Given
final GetAllJobDetailsHandler handler = new GetAllJobDetailsHandler();
final GetAllJobDetails operation = mock(GetAllJobDetails.class);
final Store store = mock(Store.class);
final JobTracker jobTracker = mock(JobTracker.class);
final User user = mock(User.class);
final CloseableIterable<JobDetail> jobsDetails = mock(CloseableIterable.class);
given(store.getJobTracker()).willReturn(jobTracker);
given(jobTracker.getAllJobs(user)).willReturn(jobsDetails);
// When
final CloseableIterable<JobDetail> results = handler.doOperation(operation, new Context(user), store);
// Then
assertSame(jobsDetails, results);
}
use of uk.gov.gchq.gaffer.jobtracker.JobDetail in project Gaffer by gchq.
the class JobService method executeJob.
@Override
public JobDetail executeJob(final OperationChainDAO opChain) {
final Context context = userFactory.createContext();
preOperationHook(opChain, context);
try {
final JobDetail jobDetail = graphFactory.getGraph().executeJob(opChain, context);
LOGGER.info("Job started = {}", jobDetail);
return jobDetail;
} catch (final OperationException e) {
throw new RuntimeException("Error executing opChain: " + e.getMessage(), e);
} finally {
postOperationHook(opChain, context);
}
}
Aggregations