Search in sources :

Example 11 with StoreException

use of uk.gov.gchq.gaffer.store.StoreException in project Gaffer by gchq.

the class AccumuloIDWithinSetRetrieverTest method setupGraph.

private static void setupGraph(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).
        TableUtils.createTable(store);
        final Set<Element> data = new HashSet<>();
        // Create edges A0 -> A1, A0 -> A2, ..., A0 -> A99. Also create an Entity for each.
        final Entity entity = new Entity(TestGroups.ENTITY);
        entity.setVertex("A0");
        entity.putProperty(AccumuloPropertyNames.COUNT, 10000);
        data.add(entity);
        for (int i = 1; i < 100; i++) {
            data.add(new Edge.Builder().group(TestGroups.EDGE).source("A0").dest("A" + i).directed(true).property(AccumuloPropertyNames.COLUMN_QUALIFIER, 1).property(AccumuloPropertyNames.COUNT, i).build());
            data.add(new Entity.Builder().group(TestGroups.ENTITY).vertex("A" + i).property(AccumuloPropertyNames.COUNT, i).build());
        }
        data.add(AccumuloTestData.EDGE_C_D_DIRECTED);
        data.add(AccumuloTestData.EDGE_C_D_UNDIRECTED);
        addElements(data, store, new User());
    } catch (final TableExistsException | StoreException e) {
        fail("Failed to set up graph in Accumulo with exception: " + e);
    }
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) User(uk.gov.gchq.gaffer.user.User) Element(uk.gov.gchq.gaffer.data.element.Element) TableExistsException(org.apache.accumulo.core.client.TableExistsException) HashSet(java.util.HashSet) StoreException(uk.gov.gchq.gaffer.store.StoreException)

Example 12 with StoreException

use of uk.gov.gchq.gaffer.store.StoreException in project Gaffer by gchq.

the class TableUtilsTest method shouldFailTableValidationWhenMissingAggregatorIterator.

@Test
public void shouldFailTableValidationWhenMissingAggregatorIterator() 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.AGGREGATOR_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 13 with StoreException

use of uk.gov.gchq.gaffer.store.StoreException in project Gaffer by gchq.

the class TableUtils method dropTable.

public static void dropTable(final Connection connection, final TableName tableName) throws StoreException {
    try {
        final Admin admin = connection.getAdmin();
        if (admin.tableExists(tableName)) {
            LOGGER.info("Dropping table: {}", tableName.getNameAsString());
            if (admin.isTableEnabled(tableName)) {
                admin.disableTable(tableName);
            }
            admin.deleteTable(tableName);
        }
    } catch (final IOException e) {
        throw new StoreException("Failed to drop table " + tableName, e);
    }
}
Also used : IOException(java.io.IOException) Admin(org.apache.hadoop.hbase.client.Admin) StoreException(uk.gov.gchq.gaffer.store.StoreException)

Example 14 with StoreException

use of uk.gov.gchq.gaffer.store.StoreException in project Gaffer by gchq.

the class TableUtils method validateTable.

private static void validateTable(final TableName tableName, final Admin admin) throws StoreException {
    final ValidationResult validationResult = new ValidationResult();
    final HTableDescriptor descriptor;
    try {
        descriptor = admin.getTableDescriptor(tableName);
    } catch (final IOException e) {
        throw new StoreException("Unable to look up the table coprocessors", e);
    }
    final HColumnDescriptor col = descriptor.getFamily(HBaseStoreConstants.getColFam());
    if (null == col) {
        validationResult.addError("The Gaffer element 'e' column family does not exist");
    } else if (Integer.MAX_VALUE != col.getMaxVersions()) {
        validationResult.addError("The maximum number of versions should be set to " + Integer.MAX_VALUE);
    }
    if (!descriptor.hasCoprocessor(GafferCoprocessor.class.getName())) {
        validationResult.addError("Missing coprocessor: " + GafferCoprocessor.class.getName());
    }
    if (!validationResult.isValid()) {
        throw new StoreException("Your table " + tableName + " is configured incorrectly. " + validationResult.getErrorString() + "\nEither delete the table and let Gaffer create it for you or fix it manually using the HBase shell or the Gaffer TableUtils utility.");
    }
}
Also used : HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) IOException(java.io.IOException) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) StoreException(uk.gov.gchq.gaffer.store.StoreException)

Example 15 with StoreException

use of uk.gov.gchq.gaffer.store.StoreException in project Gaffer by gchq.

the class MiniHBaseStore method preInitialise.

@SuppressFBWarnings({ "DE_MIGHT_IGNORE", "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD" })
@Override
public void preInitialise(final String graphId, final Schema schema, final StoreProperties properties) throws StoreException {
    setProperties(properties);
    if (null == utility) {
        try {
            final Configuration conf = setupConf();
            utility = new HBaseTestingUtility(conf);
            utility.startMiniCluster();
            utility.waitTableEnabled(VisibilityConstants.LABELS_TABLE_NAME.getName(), 50000);
            conf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, CommonConfigurationKeysPublic.FS_DEFAULT_NAME_DEFAULT);
            addLabels(getMiniHBaseVisibilities());
        } catch (final Exception e) {
            throw new StoreException(e);
        }
    }
    super.preInitialise(graphId, schema, getProperties());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) HBaseTestingUtility(org.apache.hadoop.hbase.HBaseTestingUtility) StoreException(uk.gov.gchq.gaffer.store.StoreException) IOException(java.io.IOException) StoreException(uk.gov.gchq.gaffer.store.StoreException) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

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