use of uk.gov.gchq.gaffer.store.StoreException in project Gaffer by gchq.
the class ProxyStore method doPost.
protected <OUTPUT> OUTPUT doPost(final URL url, final String jsonBody, final TypeReference<OUTPUT> clazz, final Context context) throws StoreException {
final Builder request = createRequest(jsonBody, url, context);
final Response response;
try {
response = request.post(Entity.json(jsonBody));
} catch (final Exception e) {
throw new StoreException("Failed to execute post via " + "the Gaffer URL " + url.toExternalForm(), e);
}
return handleResponse(response, clazz);
}
use of uk.gov.gchq.gaffer.store.StoreException in project Gaffer by gchq.
the class ProxyStore method executeOpChainViaUrl.
protected <OUTPUT> OUTPUT executeOpChainViaUrl(final OperationChain<OUTPUT> operationChain, final Context context) throws OperationException {
final String opChainJson;
try {
opChainJson = new String(jsonSerialiser.serialise(operationChain), CommonConstants.UTF_8);
} catch (final UnsupportedEncodingException | SerialisationException e) {
throw new OperationException("Unable to serialise operation chain into JSON.", e);
}
final URL url = getProperties().getGafferUrl("graph/doOperation");
try {
return doPost(url, opChainJson, operationChain.getOutputTypeReference(), context);
} catch (final StoreException e) {
throw new OperationException(e.getMessage(), e);
}
}
use of uk.gov.gchq.gaffer.store.StoreException in project Gaffer by gchq.
the class AbstractGetRDDHandler method addIterators.
public void addIterators(final AccumuloStore accumuloStore, final Configuration conf, final User user, final OP operation) throws OperationException {
try {
final GraphFilters derivedOperation;
if (operation instanceof GetRDDOfAllElements) {
// Create dummy GetAllElements operation as some of the methods in
// AccumuloStore test if the operation is a GetAllElements operation
// and if so set some options. We need those options if operation
// is returning all the elements.
derivedOperation = getGetAllElements(operation);
} else {
derivedOperation = operation;
}
// Update configuration with instance name, table name, zookeepers, and with view
accumuloStore.updateConfiguration(conf, derivedOperation, user);
// Add iterators based on operation-specific (i.e. not view related) options
final IteratorSetting queryTimeAggregator = accumuloStore.getKeyPackage().getIteratorFactory().getQueryTimeAggregatorIteratorSetting(operation.getView(), accumuloStore);
if (null != queryTimeAggregator) {
InputConfigurator.addIterator(AccumuloInputFormat.class, conf, queryTimeAggregator);
}
final IteratorSetting propertyFilter = accumuloStore.getKeyPackage().getIteratorFactory().getElementPropertyRangeQueryFilter(derivedOperation);
if (null != propertyFilter) {
InputConfigurator.addIterator(AccumuloInputFormat.class, conf, propertyFilter);
}
} catch (final StoreException | IteratorSettingException e) {
throw new OperationException("Failed to update configuration", e);
}
}
use of uk.gov.gchq.gaffer.store.StoreException in project Gaffer by gchq.
the class AccumuloIDBetweenSetsRetrieverTest method shouldDealWithOutgoingEdgesOnlyOption.
/**
* Tests that the options to set outgoing edges or incoming edges only options work correctly.
*
* @param store the Store instance
*/
private void shouldDealWithOutgoingEdgesOnlyOption(final AccumuloStore store) {
try {
/*
Create table
(this method creates the table, removes the versioning iterator, and adds the SetOfStatisticsCombiner iterator,
and sets the age off iterator to age data off after it is more than ageOffTimeInMilliseconds milliseconds old).
*/
final Set<Element> data = new HashSet<>();
data.add(AccumuloTestData.EDGE_A1_B1);
data.add(AccumuloTestData.EDGE_B2_A2);
addElements(data, store, new User());
// Query for edges between {A1} and {B1}, with outgoing edges only. Should get the edge A1>B1.
final GetElementsBetweenSets opA1B1 = new GetElementsBetweenSets.Builder().input(AccumuloTestData.SEED_A1_SET).inputB(AccumuloTestData.SEED_B1_SET).view(edgeOnlyView).build();
opA1B1.setIncludeIncomingOutGoing(IncludeIncomingOutgoingType.OUTGOING);
final Set<Element> a1B1OutgoingEdgeResults = returnElementsFromOperation(store, opA1B1, new User(), false);
assertThat(a1B1OutgoingEdgeResults).contains(AccumuloTestData.EDGE_A1_B1);
// Query for edges between {A1} and {B1}, with incoming edges only. Should get nothing.
opA1B1.setIncludeIncomingOutGoing(IncludeIncomingOutgoingType.INCOMING);
final Set<Element> a1B1EdgeIncomingResults = returnElementsFromOperation(store, opA1B1, new User(), false);
assertThat(a1B1EdgeIncomingResults).isEmpty();
// Query for edges between {A2} and {B2}, with incoming edges only. Should get the edge B2->A2.
final GetElementsBetweenSets opA2B2 = new GetElementsBetweenSets.Builder().input(AccumuloTestData.SEED_A2_SET).inputB(AccumuloTestData.SEED_B2_SET).view(edgeOnlyView).build();
opA2B2.setIncludeIncomingOutGoing(IncludeIncomingOutgoingType.INCOMING);
final Set<Element> a2B2EdgeIncomingResults = returnElementsFromOperation(store, opA2B2, new User(), false);
assertThat(a2B2EdgeIncomingResults).contains(AccumuloTestData.EDGE_B2_A2);
// Query for edges between {A2} and {B2}, with outgoing edges only. Should get nothing.
opA2B2.setIncludeIncomingOutGoing(IncludeIncomingOutgoingType.OUTGOING);
final Set<Element> a2B2EdgeOutgoingResults = returnElementsFromOperation(store, opA2B2, new User(), false);
assertThat(a2B2EdgeOutgoingResults).isEmpty();
} catch (final StoreException e) {
fail("Failed to set up graph in Accumulo with exception: " + e);
}
}
use of uk.gov.gchq.gaffer.store.StoreException in project Gaffer by gchq.
the class AccumuloIDBetweenSetsRetrieverTest method shouldDealWithDirectedEdgesOnlyOption.
private void shouldDealWithDirectedEdgesOnlyOption(final boolean loadIntoMemory, final AccumuloStore store) {
try {
final Set<Element> data = new HashSet<>();
data.add(AccumuloTestData.EDGE_A_B_1);
data.add(AccumuloTestData.EDGE_A_B_2);
addElements(data, store, new User());
// Set undirected edges only option, and query for edges between {A} and {B} - should get EDGE_B2_A2
final GetElementsBetweenSets op = new GetElementsBetweenSets.Builder().input(AccumuloTestData.SEED_A_SET).inputB(AccumuloTestData.SEED_B_SET).view(edgeOnlyView).build();
op.setDirectedType(DirectedType.UNDIRECTED);
final Set<Element> results = returnElementsFromOperation(store, op, new User(), loadIntoMemory);
assertThat(results).contains(AccumuloTestData.EDGE_A_B_2);
op.setDirectedType(DirectedType.DIRECTED);
final Set<Element> secondResults = returnElementsFromOperation(store, op, new User(), loadIntoMemory);
assertThat(secondResults).contains(AccumuloTestData.EDGE_A_B_1);
// Turn off directed / undirected edges only option and check get both EDGE_A1_B1 and EDGE_B2_A2
op.setDirectedType(DirectedType.EITHER);
final Set<Element> thirdResults = returnElementsFromOperation(store, op, new User(), loadIntoMemory);
assertThat(thirdResults).contains(AccumuloTestData.EDGE_A_B_2);
} catch (final StoreException e) {
fail("Failed to set up graph in Accumulo with exception: " + e);
}
}
Aggregations