Search in sources :

Example 26 with OperationException

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

Example 27 with OperationException

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);
    }
}
Also used : User(uk.gov.gchq.gaffer.user.User) OperationException(uk.gov.gchq.gaffer.operation.OperationException)

Example 28 with OperationException

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;
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream) OperationException(uk.gov.gchq.gaffer.operation.OperationException)

Example 29 with OperationException

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);
}
Also used : ImportAccumuloKeyValueFiles(uk.gov.gchq.gaffer.accumulostore.operation.hdfs.operation.ImportAccumuloKeyValueFiles) AccumuloKeyRangePartitioner(uk.gov.gchq.gaffer.sparkaccumulo.operation.utils.AccumuloKeyRangePartitioner) OperationException(uk.gov.gchq.gaffer.operation.OperationException)

Example 30 with OperationException

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;
}
Also used : ExtendedNamedOperation(uk.gov.gchq.gaffer.named.operation.ExtendedNamedOperation) CacheOperationFailedException(uk.gov.gchq.gaffer.named.operation.cache.CacheOperationFailedException) OperationException(uk.gov.gchq.gaffer.operation.OperationException)

Aggregations

OperationException (uk.gov.gchq.gaffer.operation.OperationException)38 User (uk.gov.gchq.gaffer.user.User)9 StoreException (uk.gov.gchq.gaffer.store.StoreException)7 Element (uk.gov.gchq.gaffer.data.element.Element)6 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Configuration (org.apache.hadoop.conf.Configuration)4 FileSystem (org.apache.hadoop.fs.FileSystem)4 Path (org.apache.hadoop.fs.Path)4 Test (org.junit.Test)4 Graph (uk.gov.gchq.gaffer.graph.Graph)4 SparkConf (org.apache.spark.SparkConf)3 IteratorSettingException (uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException)3 Edge (uk.gov.gchq.gaffer.data.element.Edge)3 JobDetail (uk.gov.gchq.gaffer.jobtracker.JobDetail)3 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)3 BufferedWriter (java.io.BufferedWriter)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 DataInputStream (java.io.DataInputStream)2 OutputStreamWriter (java.io.OutputStreamWriter)2