Search in sources :

Example 1 with JobTracker

use of uk.gov.gchq.gaffer.jobtracker.JobTracker in project Gaffer by gchq.

the class Store method createJobTracker.

protected JobTracker createJobTracker(final StoreProperties properties) {
    final String jobTrackerClass = properties.getJobTrackerClass();
    if (null != jobTrackerClass) {
        try {
            final JobTracker newJobTracker = Class.forName(jobTrackerClass).asSubclass(JobTracker.class).newInstance();
            newJobTracker.initialise(properties.getJobTrackerConfigPath());
            return newJobTracker;
        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
            throw new IllegalArgumentException("Could not create job tracker with class: " + jobTrackerClass, e);
        }
    }
    return null;
}
Also used : JobTracker(uk.gov.gchq.gaffer.jobtracker.JobTracker)

Example 2 with JobTracker

use of uk.gov.gchq.gaffer.jobtracker.JobTracker 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 3 with JobTracker

use of uk.gov.gchq.gaffer.jobtracker.JobTracker in project Gaffer by gchq.

the class GetJobDetailsHandlerTest method shouldGetJobDetailsByDelegatingToJobTrackerWithContextJobId.

@Test
public void shouldGetJobDetailsByDelegatingToJobTrackerWithContextJobId() throws OperationException {
    // Given
    final GetJobDetailsHandler handler = new GetJobDetailsHandler();
    final GetJobDetails operation = new GetJobDetails();
    final Store store = mock(Store.class);
    final JobTracker jobTracker = mock(JobTracker.class);
    final User user = mock(User.class);
    final JobDetail jobsDetail = mock(JobDetail.class);
    final Context context = new Context.Builder().user(user).build();
    final String jobId = context.getJobId();
    given(store.getJobTracker()).willReturn(jobTracker);
    given(jobTracker.getJob(jobId, user)).willReturn(jobsDetail);
    // When
    final JobDetail result = handler.doOperation(operation, context, store);
    // Then
    assertSame(jobsDetail, result);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) GetJobDetails(uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails) 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 4 with JobTracker

use of uk.gov.gchq.gaffer.jobtracker.JobTracker in project Gaffer by gchq.

the class StoreTest method setup.

@BeforeEach
public void setup() {
    System.clearProperty(JSONSerialiser.JSON_SERIALISER_CLASS_KEY);
    System.clearProperty(JSONSerialiser.JSON_SERIALISER_MODULES);
    JSONSerialiser.update();
    schemaOptimiser = mock(SchemaOptimiser.class);
    operationChainValidator = mock(OperationChainValidator.class);
    store = new StoreImpl();
    given(operationChainValidator.validate(any(OperationChain.class), any(User.class), any(Store.class))).willReturn(new ValidationResult());
    addElementsHandler = mock(OperationHandler.class);
    getElementsHandler = mock(OutputOperationHandler.class);
    getAllElementsHandler = mock(OutputOperationHandler.class);
    getAdjacentIdsHandler = mock(OutputOperationHandler.class);
    validateHandler = mock(OperationHandler.class);
    exportToGafferResultCacheHandler = mock(OperationHandler.class);
    getGafferResultCacheExportHandler = mock(OperationHandler.class);
    jobTracker = mock(JobTracker.class);
    schema = new Schema.Builder().edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source("string").destination("string").directed("true").property(TestPropertyNames.PROP_1, "string").property(TestPropertyNames.PROP_2, "string").build()).edge(TestGroups.EDGE_2, new SchemaEdgeDefinition.Builder().source("string").destination("string").directed("true").property(TestPropertyNames.PROP_1, "string").property(TestPropertyNames.PROP_2, "string").build()).entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().vertex("string").property(TestPropertyNames.PROP_1, "string").property(TestPropertyNames.PROP_2, "string").build()).entity(TestGroups.ENTITY_2, new SchemaEntityDefinition.Builder().vertex("string").property(TestPropertyNames.PROP_1, "string").property(TestPropertyNames.PROP_2, "string").build()).type("string", new TypeDefinition.Builder().clazz(String.class).serialiser(new StringSerialiser()).aggregateFunction(new StringConcat()).build()).type("true", Boolean.class).build();
}
Also used : StringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser) StringToStringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.tostring.StringToStringSerialiser) StringConcat(uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat) User(uk.gov.gchq.gaffer.user.User) JobTracker(uk.gov.gchq.gaffer.jobtracker.JobTracker) OutputOperationHandler(uk.gov.gchq.gaffer.store.operation.handler.OutputOperationHandler) SchemaEntityDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition) OperationChainValidator(uk.gov.gchq.gaffer.store.operation.OperationChainValidator) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) SchemaOptimiser(uk.gov.gchq.gaffer.store.schema.SchemaOptimiser) ValidateOperationChain(uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) SchemaEdgeDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition) OutputOperationHandler(uk.gov.gchq.gaffer.store.operation.handler.OutputOperationHandler) OperationHandler(uk.gov.gchq.gaffer.store.operation.handler.OperationHandler) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with JobTracker

use of uk.gov.gchq.gaffer.jobtracker.JobTracker in project Gaffer by gchq.

the class StoreTest method shouldGetJobTracker.

@Test
public void shouldGetJobTracker() throws StoreException {
    // Given
    final StoreProperties properties = mock(StoreProperties.class);
    given(properties.getJobExecutorThreadCount()).willReturn(1);
    given(properties.getJobTrackerEnabled()).willReturn(true);
    final Store store = new StoreImpl();
    final Schema schema = new Schema();
    store.initialise("graphId", schema, properties);
    // When
    final JobTracker resultJobTracker = store.getJobTracker();
    // Then
    assertSame(jobTracker, resultJobTracker);
}
Also used : Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema) JobTracker(uk.gov.gchq.gaffer.jobtracker.JobTracker) Test(org.junit.jupiter.api.Test)

Aggregations

JobTracker (uk.gov.gchq.gaffer.jobtracker.JobTracker)7 Test (org.junit.jupiter.api.Test)5 User (uk.gov.gchq.gaffer.user.User)5 Context (uk.gov.gchq.gaffer.store.Context)4 Store (uk.gov.gchq.gaffer.store.Store)4 JobDetail (uk.gov.gchq.gaffer.jobtracker.JobDetail)3 GetJobDetails (uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails)2 BeforeEach (org.junit.jupiter.api.BeforeEach)1 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)1 ValidateOperationChain (uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain)1 CancelScheduledJob (uk.gov.gchq.gaffer.operation.impl.job.CancelScheduledJob)1 GetAllJobDetails (uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails)1 StringSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser)1 StringToStringSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.tostring.StringToStringSerialiser)1 GetSchema (uk.gov.gchq.gaffer.store.operation.GetSchema)1 OperationChainValidator (uk.gov.gchq.gaffer.store.operation.OperationChainValidator)1 OperationHandler (uk.gov.gchq.gaffer.store.operation.handler.OperationHandler)1 OutputOperationHandler (uk.gov.gchq.gaffer.store.operation.handler.OutputOperationHandler)1 Schema (uk.gov.gchq.gaffer.store.schema.Schema)1 SchemaEdgeDefinition (uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition)1