use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class RoadTrafficDataLoader method main.
public static void main(final String[] args) {
if (args.length != 4) {
System.err.println("Usage: " + RoadTrafficDataLoader.class.getSimpleName() + " <graphConfigFile> <schemaDir> <storePropsFile> <roadTrafficDataFile.csv>");
System.exit(1);
}
final String graphConfigFile = args[0];
final String schemaDir = args[1];
final String storePropertiesFile = args[2];
final String dataFile = args[3];
final GraphConfig config = new GraphConfig.Builder().json(new File(graphConfigFile).toPath()).build();
final Schema schema = Schema.fromJson(new File(schemaDir).toPath());
final StoreProperties storeProperties = StoreProperties.loadStoreProperties(storePropertiesFile);
final Graph graph = new Graph.Builder().config(config).addSchemas(schema).storeProperties(storeProperties).build();
final User user = new User();
final RoadTrafficDataLoader dataLoader = new RoadTrafficDataLoader(graph, user);
LOGGER.info("Loading data");
try {
dataLoader.load(new File(dataFile));
LOGGER.info("Data has been loaded");
} catch (final Exception e) {
LOGGER.info("Unable to load data: " + e.getMessage());
throw new RuntimeException("Unable to load data", e);
}
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class FederatedStoreTest method shouldCombineTraitsToMin.
@Test
public void shouldCombineTraitsToMin() throws Exception {
// Given
final GetTraits getTraits = new GetTraits.Builder().currentTraits(true).build();
// When
final Set<StoreTrait> before = store.getTraits(getTraits, userContext);
store.initialise(FEDERATED_STORE_ID, null, federatedProperties);
store.execute(new AddGraph.Builder().schema(new Schema()).isPublic(true).graphId(ACC_ID_1).storeProperties(PROPERTIES_1).build(), new Context(testUser()));
final Set<StoreTrait> afterAcc = store.getTraits(getTraits, userContext);
StoreProperties TestStoreImp = new StoreProperties();
TestStoreImp.setStoreClass(FederatedGetTraitsHandlerTest.TestStoreImpl.class);
store.execute(new AddGraph.Builder().schema(new Schema()).isPublic(true).graphId(MAP_ID_1).storeProperties(TestStoreImp).build(), new Context(testUser()));
final Set<StoreTrait> afterMap = store.getTraits(getTraits, userContext);
// Then
assertNotEquals(SingleUseAccumuloStore.TRAITS, new HashSet<>(Arrays.asList(StoreTrait.INGEST_AGGREGATION, StoreTrait.PRE_AGGREGATION_FILTERING, StoreTrait.POST_AGGREGATION_FILTERING, StoreTrait.TRANSFORMATION, StoreTrait.POST_TRANSFORMATION_FILTERING, StoreTrait.MATCHED_VERTEX)));
assertEquals(Collections.emptySet(), before, "No traits should be found for an empty FederatedStore");
assertEquals(Sets.newHashSet(TRANSFORMATION, PRE_AGGREGATION_FILTERING, POST_AGGREGATION_FILTERING, POST_TRANSFORMATION_FILTERING, ORDERED, MATCHED_VERTEX), afterAcc);
assertEquals(Sets.newHashSet(TRANSFORMATION, PRE_AGGREGATION_FILTERING, POST_AGGREGATION_FILTERING, POST_TRANSFORMATION_FILTERING, MATCHED_VERTEX), afterMap);
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class AdminGetAllGraphInfoTest method setUp.
@BeforeEach
public void setUp() throws Exception {
CacheServiceLoader.shutdown();
access = new FederatedAccess(Sets.newHashSet("authA"), "testuser1", false, FederatedGraphStorage.DEFAULT_DISABLED_BY_DEFAULT);
store = new FederatedStore();
final StoreProperties fedProps = new StoreProperties();
fedProps.set(StoreProperties.ADMIN_AUTH, ADMIN_AUTH);
store.initialise("testFedStore", null, fedProps);
store.remove("graph1", ADMIN_USER, true);
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class AddGraphTest method builderShouldCreatePopulatedOperation.
@Test
@Override
public void builderShouldCreatePopulatedOperation() {
Schema expectedSchema = new Schema.Builder().build();
StoreProperties storeProperties = new AccumuloProperties();
AddGraph op = new AddGraph.Builder().graphId(EXPECTED_GRAPH_ID).schema(expectedSchema).storeProperties(storeProperties).readAccessPredicate(READ_ACCESS_PREDICATE).writeAccessPredicate(WRITE_ACCESS_PREDICATE).build();
assertEquals(EXPECTED_GRAPH_ID, op.getGraphId());
assertEquals(expectedSchema, op.getSchema());
assertNotNull(op.getStoreProperties().getStorePropertiesClassName());
assertEquals(AccumuloProperties.class, op.getStoreProperties().getStorePropertiesClass());
assertEquals(READ_ACCESS_PREDICATE, op.getReadAccessPredicate());
assertEquals(WRITE_ACCESS_PREDICATE, op.getWriteAccessPredicate());
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class FederatedOperationHandlerTest method shouldNotThrowExceptionBecauseSkipFlagSetTrue.
@Test
public void shouldNotThrowExceptionBecauseSkipFlagSetTrue() throws Exception {
// Given
final String graphID = "1,3";
final Operation op = mock(Operation.class);
when(op.getOption(KEY_OPERATION_OPTIONS_GRAPH_IDS)).thenReturn(graphID);
when(op.getOption(KEY_SKIP_FAILED_FEDERATED_STORE_EXECUTE)).thenReturn(String.valueOf(true));
when(op.getOption(eq(KEY_SKIP_FAILED_FEDERATED_STORE_EXECUTE), any(String.class))).thenReturn(String.valueOf(true));
given(op.shallowClone()).willReturn(op);
Schema unusedSchema = new Schema.Builder().build();
StoreProperties storeProperties = new StoreProperties();
Store mockStore1 = getMockStore(unusedSchema, storeProperties);
given(mockStore1.execute(any(OperationChain.class), eq(context))).willReturn(1);
Store mockStore2 = getMockStore(unusedSchema, storeProperties);
given(mockStore2.execute(any(OperationChain.class), eq(context))).willThrow(new RuntimeException("Test Exception"));
FederatedStore mockStore = mock(FederatedStore.class);
LinkedHashSet<Graph> filteredGraphs = Sets.newLinkedHashSet();
filteredGraphs.add(getGraphWithMockStore(mockStore1));
filteredGraphs.add(getGraphWithMockStore(mockStore2));
when(mockStore.getGraphs(user, graphID, op)).thenReturn(filteredGraphs);
// When
try {
new FederatedOperationHandler().doOperation(op, context, mockStore);
} catch (Exception e) {
fail("Exception should not have been thrown: " + e.getMessage());
}
// Then
final ArgumentCaptor<Context> contextCaptor1 = ArgumentCaptor.forClass(Context.class);
verify(mockStore1, atLeastOnce()).execute(any(OperationChain.class), contextCaptor1.capture());
assertEquals(context.getUser(), contextCaptor1.getValue().getUser());
assertNotEquals(context.getJobId(), contextCaptor1.getValue().getJobId());
final ArgumentCaptor<Context> contextCaptor2 = ArgumentCaptor.forClass(Context.class);
verify(mockStore2, atLeastOnce()).execute(any(OperationChain.class), contextCaptor2.capture());
assertEquals(context.getUser(), contextCaptor2.getValue().getUser());
assertNotEquals(context.getJobId(), contextCaptor2.getValue().getJobId());
}
Aggregations