Search in sources :

Example 91 with User

use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.

the class Queries method run.

private void run() throws OperationException, IOException {
    final User user = new User("user01");
    final Graph graph = createGraph(user);
    // Get the schema
    System.out.println(graph.getSchema().toString());
    // Full example
    runFullExample(graph, user);
}
Also used : User(uk.gov.gchq.gaffer.user.User) Graph(uk.gov.gchq.gaffer.graph.Graph)

Example 92 with User

use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.

the class AddElementsFromFileHandlerIT method shouldAddElements.

@Test
public void shouldAddElements() throws Exception {
    // Given
    final Graph graph = createGraph();
    final boolean validate = true;
    final boolean skipInvalid = false;
    final AddElementsFromFile op = new AddElementsFromFile.Builder().filename(file.getAbsolutePath()).generator(TestGeneratorImpl.class).parallelism(1).validate(validate).skipInvalidElements(skipInvalid).build();
    // When
    graph.execute(op, new User());
    // Then
    verifyElements(String.class, testFileOutput, TestGeneratorImpl.class);
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph) User(uk.gov.gchq.gaffer.user.User) AddElementsFromFile(uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromFile) FlinkTest(uk.gov.gchq.gaffer.flink.operation.FlinkTest) Test(org.junit.jupiter.api.Test)

Example 93 with User

use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.

the class AddElementsFromSocketHandlerIT method shouldAddElements.

@Test
public void shouldAddElements() throws Exception {
    // Given
    MapStore.resetStaticMap();
    final Graph graph = createGraph();
    final boolean validate = true;
    final boolean skipInvalid = false;
    final String hostname = "localhost";
    final int[] port = new int[1];
    final ServerSocket server = new ServerSocket(0);
    port[0] = server.getLocalPort();
    new Thread(() -> {
        try (final Socket socket = server.accept();
            final OutputStream out = socket.getOutputStream()) {
            out.write(DATA_BYTES);
        } catch (IOException e) {
            throw new RuntimeException();
        }
    }).start();
    final AddElementsFromSocket op = new AddElementsFromSocket.Builder().generator(TestGeneratorImpl.class).parallelism(1).validate(validate).skipInvalidElements(skipInvalid).hostname(hostname).port(port[0]).build();
    // When
    graph.execute(op, new User());
    // Then
    verifyElements(byte[].class, testFileSink, TestBytesGeneratorImpl.class);
}
Also used : User(uk.gov.gchq.gaffer.user.User) OutputStream(java.io.OutputStream) ServerSocket(java.net.ServerSocket) IOException(java.io.IOException) AddElementsFromSocket(uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromSocket) Graph(uk.gov.gchq.gaffer.graph.Graph) Socket(java.net.Socket) ServerSocket(java.net.ServerSocket) AddElementsFromSocket(uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromSocket) FlinkTest(uk.gov.gchq.gaffer.flink.operation.FlinkTest) Test(org.junit.jupiter.api.Test)

Example 94 with User

use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.

the class AddElementsFromKafkaHandlerIT method shouldAddElements.

protected <T> void shouldAddElements(final Class<T> consumeAs, final Class<? extends Function<Iterable<? extends T>, Iterable<? extends Element>>> elementGenerator, final Class<? extends Serializer> valueSerialiser) throws Exception {
    // Given
    final Graph graph = createGraph();
    final boolean validate = true;
    final boolean skipInvalid = false;
    final AddElementsFromKafka op = new AddElementsFromKafka.Builder().generator(consumeAs, elementGenerator).parallelism(1).validate(validate).skipInvalidElements(skipInvalid).topic(TOPIC).bootstrapServers(bootstrapServers).groupId(GROUP_ID).build();
    // When
    new Thread(() -> {
        try {
            graph.execute(op, new User());
        } catch (final OperationException e) {
            throw new RuntimeException(e);
        }
    }).start();
    waitForOperationToStart();
    producer = new KafkaProducer<>(producerProps(valueSerialiser));
    for (final String dataValue : DATA_VALUES) {
        producer.send(new ProducerRecord(TOPIC, convert(consumeAs, dataValue))).get();
    }
    waitForElements(consumeAs, elementGenerator);
    // Then
    verifyElements(consumeAs, testFileSink, elementGenerator);
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph) User(uk.gov.gchq.gaffer.user.User) ProducerRecord(org.apache.kafka.clients.producer.ProducerRecord) AddElementsFromKafka(uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromKafka) OperationException(uk.gov.gchq.gaffer.operation.OperationException)

Example 95 with User

use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.

the class AddElementsFromKafkaDemo method run.

private void run() throws OperationException {
    final Graph graph = new Graph.Builder().config(new GraphConfig.Builder().graphId("graph1").build()).storeProperties(StreamUtil.storeProps(getClass())).addSchemas(StreamUtil.schemas(getClass())).build();
    graph.execute(new AddElementsFromKafka.Builder().parallelism(1).topic("test").groupId("group1").bootstrapServers("localhost:9092").generator(CsvToElement.class).option(FlinkConstants.SKIP_REBALANCING, "true").build(), new User());
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph) User(uk.gov.gchq.gaffer.user.User)

Aggregations

User (uk.gov.gchq.gaffer.user.User)378 Test (org.junit.jupiter.api.Test)188 Graph (uk.gov.gchq.gaffer.graph.Graph)155 Element (uk.gov.gchq.gaffer.data.element.Element)143 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)128 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)110 HashSet (java.util.HashSet)109 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)104 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)103 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)98 Edge (uk.gov.gchq.gaffer.data.element.Edge)85 Context (uk.gov.gchq.gaffer.store.Context)85 Entity (uk.gov.gchq.gaffer.data.element.Entity)77 Test (org.junit.Test)61 ArrayList (java.util.ArrayList)57 OperationException (uk.gov.gchq.gaffer.operation.OperationException)52 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)49 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)48 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)45 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)43