Search in sources :

Example 1 with NoGraphLibrary

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

the class Store method addCoreOpHandlers.

private void addCoreOpHandlers() {
    // Add elements
    addOperationHandler(AddElements.class, getAddElementsHandler());
    // Get Elements
    addOperationHandler(GetElements.class, (OperationHandler) getGetElementsHandler());
    // Get Adjacent
    addOperationHandler(GetAdjacentIds.class, (OperationHandler) getAdjacentIdsHandler());
    // Get All Elements
    addOperationHandler(GetAllElements.class, (OperationHandler) getGetAllElementsHandler());
    // Export
    addOperationHandler(ExportToSet.class, new ExportToSetHandler());
    addOperationHandler(GetSetExport.class, new GetSetExportHandler());
    addOperationHandler(GetExports.class, new GetExportsHandler());
    // Jobs
    if (null != getJobTracker()) {
        addOperationHandler(GetJobDetails.class, new GetJobDetailsHandler());
        addOperationHandler(GetAllJobDetails.class, new GetAllJobDetailsHandler());
        addOperationHandler(GetJobResults.class, new GetJobResultsHandler());
    }
    // Output
    addOperationHandler(ToArray.class, new ToArrayHandler<>());
    addOperationHandler(ToEntitySeeds.class, new ToEntitySeedsHandler());
    addOperationHandler(ToList.class, new ToListHandler<>());
    addOperationHandler(ToMap.class, new ToMapHandler());
    addOperationHandler(ToCsv.class, new ToCsvHandler());
    addOperationHandler(ToSet.class, new ToSetHandler<>());
    addOperationHandler(ToStream.class, new ToStreamHandler<>());
    addOperationHandler(ToVertices.class, new ToVerticesHandler());
    if (null != CacheServiceLoader.getService()) {
        // Named operation
        addOperationHandler(NamedOperation.class, new NamedOperationHandler());
        addOperationHandler(AddNamedOperation.class, new AddNamedOperationHandler());
        addOperationHandler(GetAllNamedOperations.class, new GetAllNamedOperationsHandler());
        addOperationHandler(DeleteNamedOperation.class, new DeleteNamedOperationHandler());
        // Named view
        addOperationHandler(AddNamedView.class, new AddNamedViewHandler());
        addOperationHandler(GetAllNamedViews.class, new GetAllNamedViewsHandler());
        addOperationHandler(DeleteNamedView.class, new DeleteNamedViewHandler());
    }
    // ElementComparison
    addOperationHandler(Max.class, new MaxHandler());
    addOperationHandler(Min.class, new MinHandler());
    addOperationHandler(Sort.class, new SortHandler());
    // OperationChain
    addOperationHandler(OperationChain.class, getOperationChainHandler());
    addOperationHandler(OperationChainDAO.class, getOperationChainHandler());
    // OperationChain validation
    addOperationHandler(ValidateOperationChain.class, new ValidateOperationChainHandler());
    // Walk tracking
    addOperationHandler(GetWalks.class, new GetWalksHandler());
    // Other
    addOperationHandler(GenerateElements.class, new GenerateElementsHandler<>());
    addOperationHandler(GenerateObjects.class, new GenerateObjectsHandler<>());
    addOperationHandler(Validate.class, new ValidateHandler());
    addOperationHandler(Count.class, new CountHandler());
    addOperationHandler(CountGroups.class, new CountGroupsHandler());
    addOperationHandler(Limit.class, new LimitHandler());
    addOperationHandler(DiscardOutput.class, new DiscardOutputHandler());
    addOperationHandler(GetSchema.class, new GetSchemaHandler());
    addOperationHandler(uk.gov.gchq.gaffer.operation.impl.Map.class, new MapHandler());
    addOperationHandler(If.class, new IfHandler());
    addOperationHandler(While.class, new WhileHandler());
    addOperationHandler(ForEach.class, new ForEachHandler());
    addOperationHandler(ToSingletonList.class, new ToSingletonListHandler());
    addOperationHandler(Reduce.class, new ReduceHandler());
    addOperationHandler(Join.class, new JoinHandler());
    addOperationHandler(CancelScheduledJob.class, new CancelScheduledJobHandler());
    // Context variables
    addOperationHandler(SetVariable.class, new SetVariableHandler());
    addOperationHandler(GetVariable.class, new GetVariableHandler());
    addOperationHandler(GetVariables.class, new GetVariablesHandler());
    // Function
    addOperationHandler(Filter.class, new FilterHandler());
    addOperationHandler(Transform.class, new TransformHandler());
    addOperationHandler(Aggregate.class, new AggregateHandler());
    // GraphLibrary Adds
    if (null != getGraphLibrary() && !(getGraphLibrary() instanceof NoGraphLibrary)) {
        addOperationHandler(AddSchemaToLibrary.class, new AddSchemaToLibraryHandler());
        addOperationHandler(AddStorePropertiesToLibrary.class, new AddStorePropertiesToLibraryHandler());
    }
    addOperationHandler(GetTraits.class, new GetTraitsHandler());
}
Also used : ValidateOperationChainHandler(uk.gov.gchq.gaffer.store.operation.handler.ValidateOperationChainHandler) ExportToSetHandler(uk.gov.gchq.gaffer.store.operation.handler.export.set.ExportToSetHandler) DeleteNamedOperationHandler(uk.gov.gchq.gaffer.store.operation.handler.named.DeleteNamedOperationHandler) AggregateHandler(uk.gov.gchq.gaffer.store.operation.handler.function.AggregateHandler) CancelScheduledJobHandler(uk.gov.gchq.gaffer.store.operation.handler.job.CancelScheduledJobHandler) GetVariableHandler(uk.gov.gchq.gaffer.store.operation.handler.GetVariableHandler) ToVerticesHandler(uk.gov.gchq.gaffer.store.operation.handler.output.ToVerticesHandler) AddNamedOperationHandler(uk.gov.gchq.gaffer.store.operation.handler.named.AddNamedOperationHandler) DeleteNamedOperationHandler(uk.gov.gchq.gaffer.store.operation.handler.named.DeleteNamedOperationHandler) NamedOperationHandler(uk.gov.gchq.gaffer.store.operation.handler.named.NamedOperationHandler) ReduceHandler(uk.gov.gchq.gaffer.store.operation.handler.ReduceHandler) CountGroupsHandler(uk.gov.gchq.gaffer.store.operation.handler.CountGroupsHandler) FilterHandler(uk.gov.gchq.gaffer.store.operation.handler.function.FilterHandler) GetSetExportHandler(uk.gov.gchq.gaffer.store.operation.handler.export.set.GetSetExportHandler) SortHandler(uk.gov.gchq.gaffer.store.operation.handler.compare.SortHandler) AddStorePropertiesToLibraryHandler(uk.gov.gchq.gaffer.store.operation.handler.AddStorePropertiesToLibraryHandler) GetJobResultsHandler(uk.gov.gchq.gaffer.store.operation.handler.job.GetJobResultsHandler) DiscardOutputHandler(uk.gov.gchq.gaffer.store.operation.handler.DiscardOutputHandler) LimitHandler(uk.gov.gchq.gaffer.store.operation.handler.LimitHandler) GetVariablesHandler(uk.gov.gchq.gaffer.store.operation.handler.GetVariablesHandler) ToEntitySeedsHandler(uk.gov.gchq.gaffer.store.operation.handler.output.ToEntitySeedsHandler) ToMapHandler(uk.gov.gchq.gaffer.store.operation.handler.output.ToMapHandler) SetVariableHandler(uk.gov.gchq.gaffer.store.operation.handler.SetVariableHandler) NoGraphLibrary(uk.gov.gchq.gaffer.store.library.NoGraphLibrary) TransformHandler(uk.gov.gchq.gaffer.store.operation.handler.function.TransformHandler) MinHandler(uk.gov.gchq.gaffer.store.operation.handler.compare.MinHandler) GetJobDetailsHandler(uk.gov.gchq.gaffer.store.operation.handler.job.GetJobDetailsHandler) WhileHandler(uk.gov.gchq.gaffer.store.operation.handler.WhileHandler) AddNamedViewHandler(uk.gov.gchq.gaffer.store.operation.handler.named.AddNamedViewHandler) GetTraitsHandler(uk.gov.gchq.gaffer.store.operation.handler.GetTraitsHandler) ValidateHandler(uk.gov.gchq.gaffer.store.operation.handler.ValidateHandler) GetSchemaHandler(uk.gov.gchq.gaffer.store.operation.handler.GetSchemaHandler) ForEachHandler(uk.gov.gchq.gaffer.store.operation.handler.ForEachHandler) ToSingletonListHandler(uk.gov.gchq.gaffer.store.operation.handler.output.ToSingletonListHandler) GetAllJobDetailsHandler(uk.gov.gchq.gaffer.store.operation.handler.job.GetAllJobDetailsHandler) GetAllNamedViewsHandler(uk.gov.gchq.gaffer.store.operation.handler.named.GetAllNamedViewsHandler) MapHandler(uk.gov.gchq.gaffer.store.operation.handler.MapHandler) ToMapHandler(uk.gov.gchq.gaffer.store.operation.handler.output.ToMapHandler) ToCsvHandler(uk.gov.gchq.gaffer.store.operation.handler.output.ToCsvHandler) GetExportsHandler(uk.gov.gchq.gaffer.store.operation.handler.export.GetExportsHandler) JoinHandler(uk.gov.gchq.gaffer.store.operation.handler.join.JoinHandler) AddSchemaToLibraryHandler(uk.gov.gchq.gaffer.store.operation.handler.AddSchemaToLibraryHandler) DeleteNamedViewHandler(uk.gov.gchq.gaffer.store.operation.handler.named.DeleteNamedViewHandler) MaxHandler(uk.gov.gchq.gaffer.store.operation.handler.compare.MaxHandler) IfHandler(uk.gov.gchq.gaffer.store.operation.handler.IfHandler) GetWalksHandler(uk.gov.gchq.gaffer.store.operation.handler.GetWalksHandler) GetAllNamedOperationsHandler(uk.gov.gchq.gaffer.store.operation.handler.named.GetAllNamedOperationsHandler) CountHandler(uk.gov.gchq.gaffer.store.operation.handler.CountHandler) AddNamedOperationHandler(uk.gov.gchq.gaffer.store.operation.handler.named.AddNamedOperationHandler)

Example 2 with NoGraphLibrary

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

the class AddSchemaToLibraryHandlerTest method shouldNotSupportAddToGraphLibraryII.

@Test
public void shouldNotSupportAddToGraphLibraryII() throws Exception {
    // given
    store.setGraphLibrary(new NoGraphLibrary());
    // when
    store.initialise(TEST_STORE_ID, new Schema(), new StoreProperties());
    // then
    assertFalse(store.isSupported(AddSchemaToLibrary.class));
}
Also used : NoGraphLibrary(uk.gov.gchq.gaffer.store.library.NoGraphLibrary) Schema(uk.gov.gchq.gaffer.store.schema.Schema) AddSchemaToLibrary(uk.gov.gchq.gaffer.store.operation.add.AddSchemaToLibrary) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) Test(org.junit.jupiter.api.Test)

Example 3 with NoGraphLibrary

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

the class AddStorePropertiesToLibraryHandlerTest method shouldNotSupportAddToGraphLibraryII.

@Test
public void shouldNotSupportAddToGraphLibraryII() throws Exception {
    store.setGraphLibrary(new NoGraphLibrary());
    store.initialise(TEST_STORE_ID, new Schema(), new StoreProperties());
    assertFalse(store.isSupported(AddSchemaToLibrary.class));
}
Also used : NoGraphLibrary(uk.gov.gchq.gaffer.store.library.NoGraphLibrary) Schema(uk.gov.gchq.gaffer.store.schema.Schema) AddSchemaToLibrary(uk.gov.gchq.gaffer.store.operation.add.AddSchemaToLibrary) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) Test(org.junit.jupiter.api.Test)

Example 4 with NoGraphLibrary

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

the class AddUpdateTableIterator method main.

/**
 * Utility for creating and updating an Accumulo table.
 * Accumulo tables are automatically created when the Gaffer Accumulo store
 * is initialised when an instance of Graph is created.
 * <p>
 * Running this with an existing table will remove the existing iterators
 * and recreate them with the provided schema.
 * </p>
 * <p>
 * A FileGraphLibrary path must be specified as an argument.  If no path is set NoGraphLibrary will be used.
 * </p>
 * <p>
 * Usage: java -cp accumulo-store-[version]-utility.jar uk.gov.gchq.gaffer.accumulostore.utils.AddUpdateTableIterator [graphId] [pathToSchemaDirectory] [pathToStoreProperties] [pathToFileGraphLibrary]
 * </p>
 *
 * @param args [graphId] [schema directory path] [store properties path] [ file graph library path]
 * @throws Exception if the tables fails to be created/updated
 */
public static void main(final String[] args) throws Exception {
    if (args.length < NUM_REQUIRED_ARGS) {
        System.err.println("Wrong number of arguments. \nUsage: " + "<graphId> " + "<comma separated schema paths> <store properties path> " + "<" + ADD_KEY + "," + REMOVE_KEY + " or " + UPDATE_KEY + "> " + "<file graph library path>");
        System.exit(1);
    }
    final AccumuloProperties storeProps = AccumuloProperties.loadStoreProperties(getAccumuloPropertiesPath(args));
    if (null == storeProps) {
        throw new IllegalArgumentException("Store properties are required to create a store");
    }
    final Schema schema = Schema.fromJson(getSchemaPaths(args));
    GraphLibrary library;
    if (null == getFileGraphLibraryPathString(args)) {
        library = new NoGraphLibrary();
    } else {
        library = new FileGraphLibrary(getFileGraphLibraryPathString(args));
    }
    library.addOrUpdate(getGraphId(args), schema, storeProps);
    final String storeClass = storeProps.getStoreClass();
    if (null == storeClass) {
        throw new IllegalArgumentException("The Store class name was not found in the store properties for key: " + StoreProperties.STORE_CLASS);
    }
    final AccumuloStore store;
    try {
        store = Class.forName(storeClass).asSubclass(AccumuloStore.class).newInstance();
    } catch (final InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        throw new IllegalArgumentException("Could not create store of type: " + storeClass, e);
    }
    try {
        store.preInitialise(getGraphId(args), schema, storeProps);
    } catch (final StoreException e) {
        throw new IllegalArgumentException("Could not initialise the store with provided arguments.", e);
    }
    if (!store.getConnection().tableOperations().exists(store.getTableName())) {
        TableUtils.createTable(store);
    }
    final String modifyKey = getModifyKey(args);
    switch(modifyKey) {
        case UPDATE_KEY:
            for (final String iterator : ITERATORS) {
                updateIterator(store, iterator);
            }
            break;
        case ADD_KEY:
            for (final String iterator : ITERATORS) {
                addIterator(store, iterator);
            }
            break;
        case REMOVE_KEY:
            for (final String iterator : ITERATORS) {
                removeIterator(store, iterator);
            }
            break;
        default:
            throw new IllegalArgumentException("Supplied add or update key (" + modifyKey + ") was not valid, it must either be " + ADD_KEY + "," + REMOVE_KEY + " or " + UPDATE_KEY + ".");
    }
}
Also used : AccumuloProperties(uk.gov.gchq.gaffer.accumulostore.AccumuloProperties) Schema(uk.gov.gchq.gaffer.store.schema.Schema) StoreException(uk.gov.gchq.gaffer.store.StoreException) NoGraphLibrary(uk.gov.gchq.gaffer.store.library.NoGraphLibrary) FileGraphLibrary(uk.gov.gchq.gaffer.store.library.FileGraphLibrary) GraphLibrary(uk.gov.gchq.gaffer.store.library.GraphLibrary) NoGraphLibrary(uk.gov.gchq.gaffer.store.library.NoGraphLibrary) FileGraphLibrary(uk.gov.gchq.gaffer.store.library.FileGraphLibrary) AccumuloStore(uk.gov.gchq.gaffer.accumulostore.AccumuloStore)

Example 5 with NoGraphLibrary

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

the class TableUtils method main.

/**
 * Utility for creating and updating an HBase table.
 * See the HBase Store README for more information on what changes to your schema you are allowed to make.
 * HBase tables are automatically created when the Gaffer HBase store is initialised when an instance of Graph is created.
 * <p>
 * Running this with an existing table will remove the existing Gaffer Coprocessor and recreate it.
 * </p>
 * <p>
 * A FileGraphLibrary path must be specified as an argument.  If no path is set NoGraphLibrary will be used.
 * </p>
 * <p>
 * Usage:
 * </p>
 * <p>
 * java -cp hbase-store-[version]-utility.jar uk.gov.gchq.gaffer.hbasestore.utils.TableUtils [graphId] [pathToSchemaDirectory] [pathToStoreProperties] [pathToFileGraphLibrary]
 * </p>
 *
 * @param args [graphId] [schema directory path] [store properties path] [ file graph library path]
 * @throws Exception if the tables fails to be created/updated
 */
public static void main(final String[] args) throws Exception {
    if (args.length < NUM_REQUIRED_ARGS) {
        System.err.println("Wrong number of arguments. \nUsage: " + "<graphId> <schema directory path> <store properties path> <file graph library path>");
        System.exit(1);
    }
    final HBaseProperties storeProps = HBaseProperties.loadStoreProperties(getStorePropertiesPathString(args));
    if (null == storeProps) {
        throw new IllegalArgumentException("Store properties are required to create a store");
    }
    final Schema schema = Schema.fromJson(getSchemaDirectoryPath(args));
    GraphLibrary library;
    if (null == getFileGraphLibraryPathString(args)) {
        library = new NoGraphLibrary();
    } else {
        library = new FileGraphLibrary(getFileGraphLibraryPathString(args));
    }
    library.addOrUpdate(getGraphId(args), schema, storeProps);
    final String storeClass = storeProps.getStoreClass();
    if (null == storeClass) {
        throw new IllegalArgumentException("The Store class name was not found in the store properties for key: " + StoreProperties.STORE_CLASS);
    }
    final HBaseStore store;
    try {
        store = Class.forName(storeClass).asSubclass(HBaseStore.class).newInstance();
    } catch (final InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        throw new IllegalArgumentException("Could not create store of type: " + storeClass, e);
    }
    store.preInitialise(getGraphId(args), schema, storeProps);
    if (!store.getConnection().getAdmin().tableExists(store.getTableName())) {
        createTable(store);
    }
    try (final Admin admin = store.getConnection().getAdmin()) {
        final TableName tableName = store.getTableName();
        if (admin.tableExists(tableName)) {
            final HTableDescriptor descriptor = admin.getTableDescriptor(tableName);
            descriptor.removeCoprocessor(GafferCoprocessor.class.getName());
            addCoprocesssor(descriptor, store);
            admin.modifyTable(tableName, descriptor);
        } else {
            TableUtils.createTable(store);
        }
    }
}
Also used : HBaseStore(uk.gov.gchq.gaffer.hbasestore.HBaseStore) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Admin(org.apache.hadoop.hbase.client.Admin) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) NoGraphLibrary(uk.gov.gchq.gaffer.store.library.NoGraphLibrary) TableName(org.apache.hadoop.hbase.TableName) GafferCoprocessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.GafferCoprocessor) GraphLibrary(uk.gov.gchq.gaffer.store.library.GraphLibrary) NoGraphLibrary(uk.gov.gchq.gaffer.store.library.NoGraphLibrary) FileGraphLibrary(uk.gov.gchq.gaffer.store.library.FileGraphLibrary) FileGraphLibrary(uk.gov.gchq.gaffer.store.library.FileGraphLibrary) HBaseProperties(uk.gov.gchq.gaffer.hbasestore.HBaseProperties)

Aggregations

NoGraphLibrary (uk.gov.gchq.gaffer.store.library.NoGraphLibrary)5 Schema (uk.gov.gchq.gaffer.store.schema.Schema)4 Test (org.junit.jupiter.api.Test)2 StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)2 FileGraphLibrary (uk.gov.gchq.gaffer.store.library.FileGraphLibrary)2 GraphLibrary (uk.gov.gchq.gaffer.store.library.GraphLibrary)2 AddSchemaToLibrary (uk.gov.gchq.gaffer.store.operation.add.AddSchemaToLibrary)2 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 TableName (org.apache.hadoop.hbase.TableName)1 Admin (org.apache.hadoop.hbase.client.Admin)1 AccumuloProperties (uk.gov.gchq.gaffer.accumulostore.AccumuloProperties)1 AccumuloStore (uk.gov.gchq.gaffer.accumulostore.AccumuloStore)1 HBaseProperties (uk.gov.gchq.gaffer.hbasestore.HBaseProperties)1 HBaseStore (uk.gov.gchq.gaffer.hbasestore.HBaseStore)1 GafferCoprocessor (uk.gov.gchq.gaffer.hbasestore.coprocessor.GafferCoprocessor)1 StoreException (uk.gov.gchq.gaffer.store.StoreException)1 AddSchemaToLibraryHandler (uk.gov.gchq.gaffer.store.operation.handler.AddSchemaToLibraryHandler)1 AddStorePropertiesToLibraryHandler (uk.gov.gchq.gaffer.store.operation.handler.AddStorePropertiesToLibraryHandler)1 CountGroupsHandler (uk.gov.gchq.gaffer.store.operation.handler.CountGroupsHandler)1 CountHandler (uk.gov.gchq.gaffer.store.operation.handler.CountHandler)1