use of uk.gov.gchq.gaffer.store.StoreException in project Gaffer by gchq.
the class ParquetStoreTest method shouldFailSettingSnapshotWhenSnapshotNotExists.
@Test
public void shouldFailSettingSnapshotWhenSnapshotNotExists(@TempDir java.nio.file.Path tempDir) throws IOException {
// Given
final ParquetStoreProperties properties = getParquetStoreProperties(tempDir);
ParquetStore store = (ParquetStore) ParquetStore.createStore("G", TestUtils.gafferSchema("schemaUsingStringVertexType"), properties);
// When / Then
try {
store.setLatestSnapshot(12345L);
} catch (StoreException e) {
// Expected
assertThat(e.getMessage()).contains("does not exist");
return;
}
fail("StoreException should have been thrown as folder already exists");
}
use of uk.gov.gchq.gaffer.store.StoreException in project Gaffer by gchq.
the class AccumuloKeyRangePartitioner method getSplits.
public static synchronized String[] getSplits(final AccumuloStore store) throws OperationException {
final Connector connector;
try {
connector = store.getConnection();
} catch (final StoreException e) {
throw new OperationException("Failed to create accumulo connection", e);
}
final String table = store.getTableName();
try {
return connector.tableOperations().listSplits(table).stream().sorted().map(Text::toString).toArray(String[]::new);
} catch (final TableNotFoundException | AccumuloSecurityException | AccumuloException e) {
throw new OperationException("Failed to get accumulo split points from table " + table, e);
}
}
use of uk.gov.gchq.gaffer.store.StoreException in project Gaffer by gchq.
the class AccumuloIDWithinSetRetrieverTest method shouldDealWithOutgoingEdgesOnlyOption.
private void shouldDealWithOutgoingEdgesOnlyOption(final AccumuloStore store) {
try {
// Set outgoing edges only option, and query for the set {C,D}.
final Set<EntityId> seeds = new HashSet<>();
seeds.add(new EntitySeed("C"));
seeds.add(new EntitySeed("D"));
final Set<Element> expectedResults = new HashSet<>();
expectedResults.add(AccumuloTestData.EDGE_C_D_DIRECTED);
expectedResults.add(AccumuloTestData.EDGE_C_D_UNDIRECTED);
final GetElementsWithinSet op = new GetElementsWithinSet.Builder().view(defaultView).input(seeds).build();
final Set<Element> results = returnElementsFromOperation(store, op, new User(), true);
assertEquals(expectedResults, results);
} 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 TableUtilsTest method shouldFailTableValidationWhenMissingValidatorIterator.
@Test
public void shouldFailTableValidationWhenMissingValidatorIterator() throws Exception {
final AccumuloStore store = new SingleUseMiniAccumuloStore();
final Schema schema = new Schema.Builder().type(TestTypes.ID_STRING, new TypeDefinition.Builder().aggregateFunction(new StringConcat()).validateFunctions(new Exists()).clazz(String.class).build()).type(TestTypes.DIRECTED_TRUE, Boolean.class).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source(TestTypes.ID_STRING).destination(TestTypes.ID_STRING).directed(TestTypes.DIRECTED_TRUE).build()).build();
store.initialise(GRAPH_ID, schema, PROPERTIES);
final Runnable invalidateTable = () -> {
try {
AddUpdateTableIterator.removeIterator(store, AccumuloStoreConstants.VALIDATOR_ITERATOR_NAME);
} catch (final StoreException e) {
throw new RuntimeException(e);
}
};
shouldFailTableValidationWhenTableInvalid(store, invalidateTable);
}
use of uk.gov.gchq.gaffer.store.StoreException in project Gaffer by gchq.
the class ProxyStore method executeOpChainViaUrl.
public <O> O executeOpChainViaUrl(final OperationChain<O> opChain, final Context context) throws OperationException {
final String opChainJson;
try {
opChainJson = new String(JSONSerialiser.serialise(opChain), 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/operations/execute");
try {
final ResponseDeserialiser<O> responseDeserialiser = getResponseDeserialiserFor(opChain.getOutputTypeReference());
return doPost(url, opChainJson, responseDeserialiser, context);
} catch (final StoreException e) {
throw new OperationException(e.getMessage(), e);
}
}
Aggregations