use of uk.gov.gchq.gaffer.data.elementdefinition.exception.SchemaException in project Gaffer by gchq.
the class DefaultGraphFactory method createGraphBuilder.
@Override
public Graph.Builder createGraphBuilder() {
final String storePropertiesPath = System.getProperty(SystemProperty.STORE_PROPERTIES_PATH);
if (null == storePropertiesPath) {
throw new SchemaException("The path to the Store Properties was not found in system properties for key: " + SystemProperty.STORE_PROPERTIES_PATH);
}
final StoreProperties storeProperties = StoreProperties.loadStoreProperties(storePropertiesPath);
// Disable any operations required
storeProperties.addOperationDeclarationPaths("disableOperations.json");
final Graph.Builder builder = new Graph.Builder();
builder.storeProperties(storeProperties);
final String graphConfigPath = System.getProperty(SystemProperty.GRAPH_CONFIG_PATH);
if (null != graphConfigPath) {
builder.config(Paths.get(graphConfigPath));
}
for (final Path path : getSchemaPaths()) {
builder.addSchema(path);
}
final String graphId = System.getProperty(SystemProperty.GRAPH_ID);
if (null != graphId) {
builder.graphId(graphId);
}
String graphLibraryClassName = System.getProperty(SystemProperty.GRAPH_LIBRARY_CLASS);
if (null != graphLibraryClassName) {
GraphLibrary library;
try {
library = Class.forName(graphLibraryClassName).asSubclass(GraphLibrary.class).newInstance();
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) {
throw new RuntimeException("Error creating GraphLibrary class", e);
}
library.initialise(System.getProperty(SystemProperty.GRAPH_LIBRARY_CONFIG));
builder.library(library);
}
final String graphHooksPath = System.getProperty(SystemProperty.GRAPH_HOOKS_PATH);
if (null != graphHooksPath) {
builder.addHooks(Paths.get(graphHooksPath));
}
return builder;
}
use of uk.gov.gchq.gaffer.data.elementdefinition.exception.SchemaException in project Gaffer by gchq.
the class CoreKeyGroupByCombiner method init.
@Override
public void init(final SortedKeyValueIterator<Key, Value> source, final Map<String, String> options, final IteratorEnvironment env) throws IOException {
super.init(source, options, env);
try {
schema = Schema.fromJson(options.get(AccumuloStoreConstants.SCHEMA).getBytes(CommonConstants.UTF_8));
} catch (final UnsupportedEncodingException e) {
throw new SchemaException("Unable to deserialise the schema", e);
}
LOGGER.debug("Initialising CoreKeyGroupByCombiner with schema {}", schema);
try {
view = View.fromJson(options.get(AccumuloStoreConstants.VIEW).getBytes(CommonConstants.UTF_8));
} catch (final UnsupportedEncodingException e) {
throw new SchemaException("Unable to deserialise the view", e);
}
LOGGER.debug("Initialising CoreKeyGroupByCombiner with view {}", view);
final String elementConverterClass = options.get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS);
try {
elementConverter = Class.forName(elementConverterClass).asSubclass(AccumuloElementConverter.class).getConstructor(Schema.class).newInstance(schema);
LOGGER.debug("Creating AccumuloElementConverter of class {}", elementConverterClass);
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
throw new AggregationException("Failed to create element converter of the class name provided (" + elementConverterClass + ")", e);
}
final String encodedColumns = options.get(COLUMNS_OPTION);
if (StringUtils.isNotEmpty(encodedColumns)) {
aggregatedGroups = new ColumnSet(Lists.newArrayList(Splitter.on(",").split(encodedColumns)));
LOGGER.debug("Setting aggregatedGroups to {}", aggregatedGroups);
}
}
use of uk.gov.gchq.gaffer.data.elementdefinition.exception.SchemaException in project Gaffer by gchq.
the class SampleDataForSplitPointsMapper method setup.
@Override
protected void setup(final Context context) {
super.setup(context);
proportionToSample = context.getConfiguration().getFloat(AccumuloSampleDataForSplitPointsJobFactory.PROPORTION_TO_SAMPLE, 0.001f);
final Schema schema;
try {
schema = Schema.fromJson(context.getConfiguration().get(AccumuloSampleDataForSplitPointsJobFactory.SCHEMA).getBytes(CommonConstants.UTF_8));
} catch (final UnsupportedEncodingException e) {
throw new SchemaException("Unable to deserialise Store Schema from JSON", e);
}
try {
elementConverter = Class.forName(context.getConfiguration().get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS)).asSubclass(AccumuloElementConverter.class).getConstructor(Schema.class).newInstance(schema);
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
throw new IllegalArgumentException("Element converter could not be created: " + context.getConfiguration().get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS), e);
}
}
use of uk.gov.gchq.gaffer.data.elementdefinition.exception.SchemaException in project Gaffer by gchq.
the class AggregatorIterator method init.
@Override
public void init(final SortedKeyValueIterator<Key, Value> source, final Map<String, String> options, final IteratorEnvironment env) throws IOException {
super.init(source, options, env);
try {
schema = Schema.fromJson(options.get(AccumuloStoreConstants.SCHEMA).getBytes(CommonConstants.UTF_8));
} catch (final UnsupportedEncodingException e) {
throw new SchemaException("Unable to deserialise the schema from json", e);
}
LOGGER.debug("Initialising AggregatorIterator with schema {}", schema);
final String elementConverterClass = options.get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS);
try {
elementConverter = Class.forName(elementConverterClass).asSubclass(AccumuloElementConverter.class).getConstructor(Schema.class).newInstance(schema);
LOGGER.debug("Creating AccumuloElementConverter of class {}", elementConverterClass);
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
throw new AggregationException("Failed to create element converter of the class name provided (" + elementConverterClass + ")", e);
}
}
Aggregations