Search in sources :

Example 1 with JobDetail

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;
}
Also used : JobDetail(uk.gov.gchq.gaffer.jobtracker.JobDetail) GraphHook(uk.gov.gchq.gaffer.graph.hook.GraphHook)

Example 2 with JobDetail

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);
}
Also used : GetJobDetails(uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails) JobDetail(uk.gov.gchq.gaffer.jobtracker.JobDetail) User(uk.gov.gchq.gaffer.user.User) GetAllEdges(uk.gov.gchq.gaffer.operation.impl.get.GetAllEdges) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) Test(org.junit.Test)

Example 3 with JobDetail

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);
}
Also used : JobDetail(uk.gov.gchq.gaffer.jobtracker.JobDetail) User(uk.gov.gchq.gaffer.user.User) GetAllEdges(uk.gov.gchq.gaffer.operation.impl.get.GetAllEdges) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) Test(org.junit.Test)

Example 4 with JobDetail

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;
}
Also used : GetJobDetails(uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails) JobDetail(uk.gov.gchq.gaffer.jobtracker.JobDetail) GetAllEdges(uk.gov.gchq.gaffer.operation.impl.get.GetAllEdges) ExportToGafferResultCache(uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache)

Example 5 with 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;
}
Also used : GetJobDetails(uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails) JobDetail(uk.gov.gchq.gaffer.jobtracker.JobDetail) GetAllEdges(uk.gov.gchq.gaffer.operation.impl.get.GetAllEdges) ExportToGafferResultCache(uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache)

Aggregations

JobDetail (uk.gov.gchq.gaffer.jobtracker.JobDetail)42 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)22 Test (org.junit.jupiter.api.Test)14 GetJobDetails (uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails)14 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)11 User (uk.gov.gchq.gaffer.user.User)11 ExportToGafferResultCache (uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache)10 Context (uk.gov.gchq.gaffer.store.Context)8 DiscardOutput (uk.gov.gchq.gaffer.operation.impl.DiscardOutput)7 Job (uk.gov.gchq.gaffer.jobtracker.Job)6 OperationException (uk.gov.gchq.gaffer.operation.OperationException)6 GetAllEdges (uk.gov.gchq.gaffer.operation.impl.get.GetAllEdges)6 GetAllJobDetails (uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails)6 Schema (uk.gov.gchq.gaffer.store.schema.Schema)6 List (java.util.List)5 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)5 Repeat (uk.gov.gchq.gaffer.jobtracker.Repeat)5 Operation (uk.gov.gchq.gaffer.operation.Operation)5 ValidateOperationChain (uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain)5 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)5