use of uk.gov.gchq.gaffer.operation.OperationException in project Gaffer by gchq.
the class GetAllJobDetailsHandlerTest method shouldThrowExceptionIfJobTrackerIsNotConfigured.
@Test
public void shouldThrowExceptionIfJobTrackerIsNotConfigured() {
// Given
final GetAllJobDetailsHandler handler = new GetAllJobDetailsHandler();
final GetAllJobDetails operation = mock(GetAllJobDetails.class);
final Store store = mock(Store.class);
final User user = mock(User.class);
given(store.getJobTracker()).willReturn(null);
// When / Then
try {
handler.doOperation(operation, new Context(user), store);
fail("Exception expected");
} catch (final OperationException e) {
assertNotNull(e.getMessage());
}
}
use of uk.gov.gchq.gaffer.operation.OperationException in project Gaffer by gchq.
the class AbstractGetRDDHandler method getConfiguration.
protected Configuration getConfiguration(final GetOperation<?, ?> operation) throws OperationException {
final Configuration conf = new Configuration();
final String serialisedConf = operation.getOption(AbstractGetRDDHandler.HADOOP_CONFIGURATION_KEY);
if (serialisedConf != null) {
try {
final ByteArrayInputStream bais = new ByteArrayInputStream(serialisedConf.getBytes(CommonConstants.UTF_8));
conf.readFields(new DataInputStream(bais));
} catch (final IOException e) {
throw new OperationException("Exception decoding Configuration from options", e);
}
}
return conf;
}
use of uk.gov.gchq.gaffer.operation.OperationException in project Gaffer by gchq.
the class AbstractImportKeyValuePairRDDToAccumuloHandler method doOperation.
public void doOperation(final T operation, final Context context, final AccumuloStore store) throws OperationException {
final String outputPath = getOutputPath(operation);
if (null == outputPath || outputPath.isEmpty()) {
throw new OperationException("Option outputPath must be set for this option to be run against the accumulostore");
}
final String failurePath = getFailurePath(operation);
if (null == failurePath || failurePath.isEmpty()) {
throw new OperationException("Option failurePath must be set for this option to be run against the accumulostore");
}
prepareKeyValues(operation, new AccumuloKeyRangePartitioner(store));
final ImportAccumuloKeyValueFiles importAccumuloKeyValueFiles = new ImportAccumuloKeyValueFiles.Builder().inputPath(outputPath).failurePath(failurePath).build();
store._execute(new OperationChain<>(importAccumuloKeyValueFiles), context);
}
use of uk.gov.gchq.gaffer.operation.OperationException in project Gaffer by gchq.
the class AddNamedOperationHandler method doOperation.
/**
* Adds a NamedOperation to a cache which must be specified in the operation declarations file. An
* ExtendedNamedOperation is built using the fields on the AddNamedOperation. The operation name and operation chain
* fields must be set and cannot be left empty, or the build() method will fail and a runtime exception will be
* thrown. The handler then adds/overwrites the NamedOperation according toa an overwrite flag.
* @param operation the {@link uk.gov.gchq.gaffer.operation.Operation} to be executed
* @param context the operation chain context, containing the user who executed the operation
* @param store the {@link Store} the operation should be run on
* @return null (since the output is void)
* @throws OperationException if the operation on the cache fails
*/
@Override
public Void doOperation(final AddNamedOperation operation, final Context context, final Store store) throws OperationException {
try {
if (cache == null) {
throw new OperationException("Cache should be initialised in " + "resources/NamedOperationsDeclarations.json and referenced in store.properties");
}
validate(context.getUser(), operation.getOperationName(), operation.getOperationChain(), cache);
ExtendedNamedOperation extendedNamedOperation = new ExtendedNamedOperation.Builder().operationChain(operation.getOperationChain()).operationName(operation.getOperationName()).creatorId(context.getUser().getUserId()).readers(operation.getReadAccessRoles()).writers(operation.getWriteAccessRoles()).description(operation.getDescription()).build();
cache.addNamedOperation(extendedNamedOperation, operation.isOverwriteFlag(), context.getUser());
} catch (CacheOperationFailedException e) {
throw new OperationException(e.getMessage(), e);
}
return null;
}
use of uk.gov.gchq.gaffer.operation.OperationException in project Gaffer by gchq.
the class GetJobResultsExample method runExamples.
@Override
public void runExamples() {
try {
final OperationChain<JobDetail> opChain = new OperationChain.Builder().first(new GetAllEdges()).then(new ExportToGafferResultCache()).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();
}
Aggregations