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