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