Search in sources :

Example 11 with OperationException

use of uk.gov.gchq.gaffer.operation.OperationException in project Gaffer by gchq.

the class AbstractGetRDDHandler method addRanges.

public <ELEMENT_SEED extends ElementSeed> void addRanges(final AccumuloStore accumuloStore, final Configuration conf, final GetSparkRDDOperation<ELEMENT_SEED, ?> operation) throws OperationException {
    final List<Range> ranges = new ArrayList<>();
    for (final ELEMENT_SEED entitySeed : operation.getSeeds()) {
        try {
            ranges.addAll(accumuloStore.getKeyPackage().getRangeFactory().getRange(entitySeed, operation));
        } catch (final RangeFactoryException e) {
            throw new OperationException("Failed to add ranges to configuration", e);
        }
    }
    InputConfigurator.setRanges(AccumuloInputFormat.class, conf, ranges);
}
Also used : ArrayList(java.util.ArrayList) Range(org.apache.accumulo.core.data.Range) OperationException(uk.gov.gchq.gaffer.operation.OperationException) RangeFactoryException(uk.gov.gchq.gaffer.accumulostore.key.exception.RangeFactoryException)

Example 12 with OperationException

use of uk.gov.gchq.gaffer.operation.OperationException in project Gaffer by gchq.

the class GetAdjacentEntitySeedsHandler method doOperation.

public CloseableIterable<EntitySeed> doOperation(final GetAdjacentEntitySeeds operation, final User user, final AccumuloStore store) throws OperationException {
    operation.addOption(AccumuloStoreConstants.OPERATION_RETURN_MATCHED_SEEDS_AS_EDGE_SOURCE, "true");
    final AccumuloRetriever<?> edgeRetriever;
    try {
        operation.setIncludeEntities(false);
        if (IncludeEdgeType.NONE == operation.getIncludeEdges()) {
            operation.setIncludeEdges(IncludeEdgeType.ALL);
        }
        final IteratorSettingFactory iteratorFactory = store.getKeyPackage().getIteratorFactory();
        edgeRetriever = new AccumuloSingleIDRetriever(store, operation, user, iteratorFactory.getElementPreAggregationFilterIteratorSetting(operation.getView(), store), iteratorFactory.getElementPostAggregationFilterIteratorSetting(operation.getView(), store), iteratorFactory.getEdgeEntityDirectionFilterIteratorSetting(operation), iteratorFactory.getQueryTimeAggregatorIteratorSetting(operation.getView(), store));
    } catch (IteratorSettingException | StoreException e) {
        throw new OperationException(e.getMessage(), e);
    }
    return new ExtractDestinationEntitySeed(edgeRetriever);
}
Also used : IteratorSettingFactory(uk.gov.gchq.gaffer.accumulostore.key.IteratorSettingFactory) IteratorSettingException(uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException) AccumuloSingleIDRetriever(uk.gov.gchq.gaffer.accumulostore.retriever.impl.AccumuloSingleIDRetriever) OperationException(uk.gov.gchq.gaffer.operation.OperationException) StoreException(uk.gov.gchq.gaffer.store.StoreException)

Example 13 with OperationException

use of uk.gov.gchq.gaffer.operation.OperationException in project Gaffer by gchq.

the class AddElementsFromHdfsHandler method fetchElements.

private void fetchElements(final AddElementsFromHdfs operation, final AccumuloStore store) throws OperationException {
    final FetchElementsFromHdfsTool fetchTool = new FetchElementsFromHdfsTool(operation, store);
    final int response;
    try {
        LOGGER.info("Running FetchElementsFromHdfsTool job");
        response = ToolRunner.run(fetchTool, new String[0]);
        LOGGER.info("Finished running FetchElementsFromHdfsTool job");
    } catch (final Exception e) {
        LOGGER.error("Failed to fetch elements from HDFS: {}", e.getMessage());
        throw new OperationException("Failed to fetch elements from HDFS", e);
    }
    if (FetchElementsFromHdfsTool.SUCCESS_RESPONSE != response) {
        LOGGER.error("Failed to fetch elements from HDFS. Response code was {}", response);
        throw new OperationException("Failed to fetch elements from HDFS. Response code was: " + response);
    }
}
Also used : FetchElementsFromHdfsTool(uk.gov.gchq.gaffer.accumulostore.operation.hdfs.handler.job.tool.FetchElementsFromHdfsTool) OperationException(uk.gov.gchq.gaffer.operation.OperationException) OperationException(uk.gov.gchq.gaffer.operation.OperationException)

Example 14 with OperationException

use of uk.gov.gchq.gaffer.operation.OperationException in project Gaffer by gchq.

the class OperationExample method runExampleNoResult.

protected void runExampleNoResult(final Operation<?, Void> operation) {
    log("#### " + getMethodNameAsSentence(1) + "\n");
    printJava(JavaSourceUtil.getRawJavaSnippet(getClass(), "example/example-graph", " " + getMethodName(1) + "() {", String.format("---%n"), "// ----"));
    printAsJson(operation);
    printOperationClass(operation);
    try {
        getGraph().execute(operation, new User("user01"));
    } catch (OperationException e) {
        throw new RuntimeException(e);
    }
    log(METHOD_DIVIDER);
}
Also used : User(uk.gov.gchq.gaffer.user.User) OperationException(uk.gov.gchq.gaffer.operation.OperationException)

Example 15 with OperationException

use of uk.gov.gchq.gaffer.operation.OperationException in project Gaffer by gchq.

the class AccumuloRangeIDRetrieverTest method setupGraph.

private static void setupGraph(final AccumuloStore store, int numEntries) {
    final List<Element> elements = new ArrayList<>();
    for (int i = 0; i < numEntries; i++) {
        final Edge edge = new Edge(TestGroups.EDGE);
        String s = "" + i;
        while (s.length() < 4) {
            s = "0" + s;
        }
        edge.setSource(s);
        edge.setDestination("B");
        edge.setDirected(false);
        elements.add(edge);
    }
    try {
        final User user = new User();
        store.execute(new AddElements(elements), user);
    } catch (OperationException e) {
        fail("Couldn't add element: " + e);
    }
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) User(uk.gov.gchq.gaffer.user.User) Element(uk.gov.gchq.gaffer.data.element.Element) ArrayList(java.util.ArrayList) Edge(uk.gov.gchq.gaffer.data.element.Edge) 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