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