use of uk.gov.gchq.gaffer.operation.OperationException in project Gaffer by gchq.
the class JobService method executeJob.
@Override
public JobDetail executeJob(final OperationChain opChain) {
final User user = userFactory.createUser();
preOperationHook(opChain, user);
try {
final JobDetail jobDetail = graphFactory.getGraph().executeJob(opChain, user);
LOGGER.info("Job started = " + jobDetail);
return jobDetail;
} catch (OperationException e) {
throw new RuntimeException("Error executing opChain", e);
} finally {
postOperationHook(opChain, user);
}
}
use of uk.gov.gchq.gaffer.operation.OperationException in project Gaffer by gchq.
the class OperationService method _execute.
protected <OUTPUT> OUTPUT _execute(final OperationChain<OUTPUT> opChain) {
final User user = userFactory.createUser();
preOperationHook(opChain, user);
try {
return graphFactory.getGraph().execute(opChain, user);
} catch (OperationException e) {
throw new RuntimeException("Error executing opChain", e);
} finally {
postOperationHook(opChain, user);
}
}
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;
}
Aggregations