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;
}
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);
}
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);
}
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();
}
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);
}
Aggregations