Search in sources :

Example 11 with GraphConfig

use of uk.gov.gchq.gaffer.graph.GraphConfig in project Gaffer by gchq.

the class FederatedGraphStorageTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    graphStorage = new FederatedGraphStorage();
    e1 = new SchemaEntityDefinition.Builder().vertex("string").build();
    a = new GraphSerialisable.Builder().config(new GraphConfig(GRAPH_ID_A)).properties(PROPERTIES).schema(new Schema.Builder().entity("e1", e1).type("string", String.class).build()).build();
    e2 = new SchemaEntityDefinition.Builder().vertex("string2").build();
    b = new GraphSerialisable.Builder().config(new GraphConfig(GRAPH_ID_B)).properties(PROPERTIES).schema(new Schema.Builder().entity("e2", e2).type("string2", String.class).build()).build();
    nullUser = null;
    testUser = testUser();
    authUser = authUser();
    blankUser = blankUser();
    testUserContext = new Context(testUser);
    authUserContext = new Context(authUser);
    blankUserContext = new Context(blankUser);
    access = new FederatedAccess(Sets.newHashSet(AUTH_1), TEST_USER_ID);
    altAccess = new FederatedAccess(Sets.newHashSet(AUTH_2), TEST_USER_ID);
    disabledByDefaultAccess = new FederatedAccess(Sets.newHashSet(AUTH_1), TEST_USER_ID, false, true);
    blockingAccessPredicate = new NoAccessPredicate();
    blockingReadAccess = new FederatedAccess(NULL_GRAPH_AUTHS, TEST_USER_ID, false, false, blockingAccessPredicate, null);
    blockingWriteAccess = new FederatedAccess(NULL_GRAPH_AUTHS, TEST_USER_ID, false, false, null, blockingAccessPredicate);
    permissiveAccessPredicate = new UnrestrictedAccessPredicate();
    permissiveReadAccess = new FederatedAccess(NULL_GRAPH_AUTHS, TEST_USER_ID, false, false, permissiveAccessPredicate, null);
    permissiveWriteAccess = new FederatedAccess(NULL_GRAPH_AUTHS, TEST_USER_ID, false, false, null, permissiveAccessPredicate);
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) Context(uk.gov.gchq.gaffer.store.Context) NoAccessPredicate(uk.gov.gchq.gaffer.access.predicate.NoAccessPredicate) GraphSerialisable(uk.gov.gchq.gaffer.graph.GraphSerialisable) UnrestrictedAccessPredicate(uk.gov.gchq.gaffer.access.predicate.UnrestrictedAccessPredicate) SchemaEntityDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 12 with GraphConfig

use of uk.gov.gchq.gaffer.graph.GraphConfig in project Gaffer by gchq.

the class FederatedStoreToFederatedStoreTest method setUpStores.

@BeforeEach
public void setUpStores() throws OperationException {
    SingleUseFederatedStore.cleanUp();
    ProxyProperties proxyProperties = new ProxyProperties();
    proxyProperties.setStoreClass(SingleUseFederatedStore.class);
    restApiFederatedGraph = new Graph.Builder().storeProperties(proxyProperties).config(new GraphConfig("RestApiGraph")).addSchema(new Schema()).build();
    federatedStoreGraph = new Graph.Builder().config(new GraphConfig("federatedStoreGraph")).storeProperties(new FederatedStoreProperties()).build();
    connectGraphs();
    addMapStore();
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) ProxyProperties(uk.gov.gchq.gaffer.proxystore.ProxyProperties) AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) Graph(uk.gov.gchq.gaffer.graph.Graph) Schema(uk.gov.gchq.gaffer.store.schema.Schema) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 13 with GraphConfig

use of uk.gov.gchq.gaffer.graph.GraphConfig in project Gaffer by gchq.

the class PredefinedFederatedStore method initialise.

@Override
public void initialise(final String graphId, final Schema schema, final StoreProperties properties) throws StoreException {
    HashMapGraphLibrary.clear();
    CacheServiceLoader.shutdown();
    ExecutorService.shutdown();
    super.initialise(graphId, schema, properties);
    // Accumulo store just contains edges
    try {
        addGraphs(null, User.UNKNOWN_USER_ID, false, new GraphSerialisable.Builder().config(new GraphConfig(ACCUMULO_GRAPH_WITH_EDGES)).schema(new Schema.Builder().merge(schema.clone()).entities(Collections.emptyMap()).build()).properties(PROPERTIES).build());
        // Accumulo store just contains entities
        addGraphs(null, User.UNKNOWN_USER_ID, false, new GraphSerialisable.Builder().config(new GraphConfig(ACCUMULO_GRAPH_WITH_ENTITIES)).schema(new Schema.Builder().merge(schema.clone()).edges(Collections.emptyMap()).build()).properties(PROPERTIES).build());
    } catch (final StorageException e) {
        throw new StoreException(e.getMessage(), e);
    }
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) GraphSerialisable(uk.gov.gchq.gaffer.graph.GraphSerialisable) Schema(uk.gov.gchq.gaffer.store.schema.Schema) StorageException(uk.gov.gchq.gaffer.federatedstore.exception.StorageException) StoreException(uk.gov.gchq.gaffer.store.StoreException)

Example 14 with GraphConfig

use of uk.gov.gchq.gaffer.graph.GraphConfig in project Gaffer by gchq.

the class FederatedStoreTest method shouldAddMultipleGraphsToCache.

@Test
public void shouldAddMultipleGraphsToCache() throws Exception {
    federatedProperties.setCacheProperties(CACHE_SERVICE_CLASS_STRING);
    store.initialise(FEDERATED_STORE_ID, null, federatedProperties);
    // Given
    List<GraphSerialisable> graphsToAdd = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        graphsToAdd.add(new GraphSerialisable.Builder().config(new GraphConfig(ACC_ID_1 + i)).properties(PROPERTIES_ALT).schema(StreamUtil.openStream(FederatedStoreTest.class, PATH_BASIC_EDGE_SCHEMA_JSON)).build());
    }
    // When
    store.addGraphs(null, TEST_USER_ID, false, graphsToAdd.toArray(new GraphSerialisable[graphsToAdd.size()]));
    // Then
    for (int i = 0; i < 10; i++) {
        assertTrue(CacheServiceLoader.getService().getAllKeysFromCache(CACHE_SERVICE_NAME).contains(ACC_ID_1 + i));
    }
    // When
    store = new FederatedStore();
    // Then
    for (int i = 0; i < 10; i++) {
        assertTrue(CacheServiceLoader.getService().getAllKeysFromCache(CACHE_SERVICE_NAME).contains(ACC_ID_1 + i));
    }
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) GraphSerialisable(uk.gov.gchq.gaffer.graph.GraphSerialisable) ArrayList(java.util.ArrayList) FederatedGetTraitsHandlerTest(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetTraitsHandlerTest) Test(org.junit.jupiter.api.Test)

Example 15 with GraphConfig

use of uk.gov.gchq.gaffer.graph.GraphConfig in project Gaffer by gchq.

the class FederatedStoreTest method shouldAddGraphsToCache.

@Test
public void shouldAddGraphsToCache() throws Exception {
    federatedProperties.setCacheProperties(CACHE_SERVICE_CLASS_STRING);
    store.initialise(FEDERATED_STORE_ID, null, federatedProperties);
    // Given
    GraphSerialisable graphToAdd = new GraphSerialisable.Builder().config(new GraphConfig(ACC_ID_1)).properties(PROPERTIES_ALT).schema(StreamUtil.openStream(FederatedStoreTest.class, PATH_BASIC_EDGE_SCHEMA_JSON)).build();
    // When
    store.addGraphs(null, TEST_USER_ID, true, graphToAdd);
    // Then
    assertEquals(1, store.getGraphs(blankUser, ACC_ID_1, ignore).size());
    // When
    Collection<Graph> storeGraphs = store.getGraphs(blankUser, null, ignore);
    // Then
    assertTrue(CacheServiceLoader.getService().getAllKeysFromCache(CACHE_SERVICE_NAME).contains(ACC_ID_1));
    assertThat(storeGraphs).contains(graphToAdd.getGraph());
    // When
    store = new FederatedStore();
    // Then
    assertTrue(CacheServiceLoader.getService().getAllKeysFromCache(CACHE_SERVICE_NAME).contains(ACC_ID_1));
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) Graph(uk.gov.gchq.gaffer.graph.Graph) RemoveGraph(uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph) AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) GraphSerialisable(uk.gov.gchq.gaffer.graph.GraphSerialisable) Builder(uk.gov.gchq.gaffer.store.schema.Schema.Builder) FederatedGetTraitsHandlerTest(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetTraitsHandlerTest) Test(org.junit.jupiter.api.Test)

Aggregations

GraphConfig (uk.gov.gchq.gaffer.graph.GraphConfig)37 Graph (uk.gov.gchq.gaffer.graph.Graph)19 Schema (uk.gov.gchq.gaffer.store.schema.Schema)19 GraphSerialisable (uk.gov.gchq.gaffer.graph.GraphSerialisable)18 Test (org.junit.jupiter.api.Test)15 Context (uk.gov.gchq.gaffer.store.Context)8 MapStoreProperties (uk.gov.gchq.gaffer.mapstore.MapStoreProperties)7 BeforeEach (org.junit.jupiter.api.BeforeEach)6 StoreTrait (uk.gov.gchq.gaffer.store.StoreTrait)6 Test (org.junit.Test)5 AddGraph (uk.gov.gchq.gaffer.federatedstore.operation.AddGraph)5 FederatedGetTraitsHandlerTest (uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetTraitsHandlerTest)5 NoAccessPredicate (uk.gov.gchq.gaffer.access.predicate.NoAccessPredicate)4 FederatedStore (uk.gov.gchq.gaffer.federatedstore.FederatedStore)4 FederatedStoreProperties (uk.gov.gchq.gaffer.federatedstore.FederatedStoreProperties)4 RemoveGraph (uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph)4 ProxyProperties (uk.gov.gchq.gaffer.proxystore.ProxyProperties)4 StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)4 SchemaEdgeDefinition (uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition)4 ArrayList (java.util.ArrayList)3