Search in sources :

Example 6 with JobDetail

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

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

Example 8 with JobDetail

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

Example 9 with JobDetail

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);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) GetAllJobDetails(uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails) JobDetail(uk.gov.gchq.gaffer.jobtracker.JobDetail) User(uk.gov.gchq.gaffer.user.User) JobTracker(uk.gov.gchq.gaffer.jobtracker.JobTracker) Store(uk.gov.gchq.gaffer.store.Store) Test(org.junit.jupiter.api.Test)

Example 10 with JobDetail

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);
    }
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) JobDetail(uk.gov.gchq.gaffer.jobtracker.JobDetail) OperationException(uk.gov.gchq.gaffer.operation.OperationException)

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