Search in sources :

Example 81 with StoreProperties

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);
    }
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) Graph(uk.gov.gchq.gaffer.graph.Graph) User(uk.gov.gchq.gaffer.user.User) Schema(uk.gov.gchq.gaffer.store.schema.Schema) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) File(java.io.File) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) OperationException(uk.gov.gchq.gaffer.operation.OperationException)

Example 82 with StoreProperties

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);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) GetTraits(uk.gov.gchq.gaffer.store.operation.GetTraits) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) Builder(uk.gov.gchq.gaffer.store.schema.Schema.Builder) GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema) Schema(uk.gov.gchq.gaffer.store.schema.Schema) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) FederatedGetTraitsHandlerTest(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetTraitsHandlerTest) FederatedGetTraitsHandlerTest(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetTraitsHandlerTest) Test(org.junit.jupiter.api.Test)

Example 83 with StoreProperties

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);
}
Also used : StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 84 with StoreProperties

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());
}
Also used : AccumuloProperties(uk.gov.gchq.gaffer.accumulostore.AccumuloProperties) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Builder(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph.Builder) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 85 with StoreProperties

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());
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) Schema(uk.gov.gchq.gaffer.store.schema.Schema) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) Store(uk.gov.gchq.gaffer.store.Store) Operation(uk.gov.gchq.gaffer.operation.Operation) OperationException(uk.gov.gchq.gaffer.operation.OperationException) Graph(uk.gov.gchq.gaffer.graph.Graph) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) Test(org.junit.jupiter.api.Test)

Aggregations

StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)170 Test (org.junit.jupiter.api.Test)136 Schema (uk.gov.gchq.gaffer.store.schema.Schema)102 Store (uk.gov.gchq.gaffer.store.Store)74 Context (uk.gov.gchq.gaffer.store.Context)47 TestStore (uk.gov.gchq.gaffer.integration.store.TestStore)42 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)39 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)26 Graph (uk.gov.gchq.gaffer.graph.Graph)26 Operation (uk.gov.gchq.gaffer.operation.Operation)24 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)21 OperationView (uk.gov.gchq.gaffer.operation.graph.OperationView)20 User (uk.gov.gchq.gaffer.user.User)18 NamedOperation (uk.gov.gchq.gaffer.named.operation.NamedOperation)17 BeforeEach (org.junit.jupiter.api.BeforeEach)16 GraphHook (uk.gov.gchq.gaffer.graph.hook.GraphHook)16 SchemaEdgeDefinition (uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition)16 ExportToOtherGraph (uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph)14 HashSet (java.util.HashSet)13 FunctionAuthoriser (uk.gov.gchq.gaffer.graph.hook.FunctionAuthoriser)13