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