Search in sources :

Example 46 with StoreException

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");
}
Also used : TestUtils.getParquetStoreProperties(uk.gov.gchq.gaffer.parquetstore.testutils.TestUtils.getParquetStoreProperties) StoreException(uk.gov.gchq.gaffer.store.StoreException) Test(org.junit.jupiter.api.Test)

Example 47 with StoreException

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);
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) OperationException(uk.gov.gchq.gaffer.operation.OperationException) StoreException(uk.gov.gchq.gaffer.store.StoreException)

Example 48 with StoreException

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);
    }
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) User(uk.gov.gchq.gaffer.user.User) Element(uk.gov.gchq.gaffer.data.element.Element) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElementsWithinSet(uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsWithinSet) HashSet(java.util.HashSet) StoreException(uk.gov.gchq.gaffer.store.StoreException)

Example 49 with StoreException

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);
}
Also used : StringConcat(uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat) AccumuloRuntimeException(uk.gov.gchq.gaffer.accumulostore.key.AccumuloRuntimeException) Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) Schema(uk.gov.gchq.gaffer.store.schema.Schema) MiniAccumuloStore(uk.gov.gchq.gaffer.accumulostore.MiniAccumuloStore) SingleUseMiniAccumuloStore(uk.gov.gchq.gaffer.accumulostore.SingleUseMiniAccumuloStore) AccumuloStore(uk.gov.gchq.gaffer.accumulostore.AccumuloStore) SingleUseMiniAccumuloStore(uk.gov.gchq.gaffer.accumulostore.SingleUseMiniAccumuloStore) StoreException(uk.gov.gchq.gaffer.store.StoreException) Test(org.junit.jupiter.api.Test)

Example 50 with StoreException

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);
    }
}
Also used : SerialisationException(uk.gov.gchq.gaffer.exception.SerialisationException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) OperationException(uk.gov.gchq.gaffer.operation.OperationException) URL(java.net.URL) OperationChainDAO(uk.gov.gchq.gaffer.operation.OperationChainDAO) StoreException(uk.gov.gchq.gaffer.store.StoreException)

Aggregations

StoreException (uk.gov.gchq.gaffer.store.StoreException)70 OperationException (uk.gov.gchq.gaffer.operation.OperationException)26 IOException (java.io.IOException)21 Path (org.apache.hadoop.fs.Path)11 Schema (uk.gov.gchq.gaffer.store.schema.Schema)11 HashSet (java.util.HashSet)10 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)10 Element (uk.gov.gchq.gaffer.data.element.Element)10 UnsupportedEncodingException (java.io.UnsupportedEncodingException)9 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)9 IteratorSettingException (uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException)9 SerialisationException (uk.gov.gchq.gaffer.exception.SerialisationException)9 ArrayList (java.util.ArrayList)8 AccumuloException (org.apache.accumulo.core.client.AccumuloException)8 Configuration (org.apache.hadoop.conf.Configuration)8 Test (org.junit.jupiter.api.Test)8 User (uk.gov.gchq.gaffer.user.User)8 Set (java.util.Set)6 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)6 FileSystem (org.apache.hadoop.fs.FileSystem)6