use of cz.o2.proxima.repository.Repository in project proxima-platform by O2-Czech-Republic.
the class KafkaLogReaderIT method initializeTestWithUri.
private void initializeTestWithUri(String uri, String access) {
final Repository repository = Repository.ofTest(createConfig(uri, access));
entity = repository.getEntity("entity");
fooDescriptor = entity.getAttribute("foo");
operator = repository.getOrCreateOperator(DirectDataOperator.class);
}
use of cz.o2.proxima.repository.Repository in project proxima-platform by O2-Czech-Republic.
the class BeamStreamTest method testInterruptible.
@Test(timeout = 10000)
public void testInterruptible() throws InterruptedException {
Repository repo = Repository.ofTest(ConfigFactory.load("test-reference.conf"));
BeamDataOperator op = repo.getOrCreateOperator(BeamDataOperator.class);
EntityDescriptor gateway = repo.getEntity("gateway");
AttributeDescriptor<?> armed = gateway.getAttribute("armed");
SynchronousQueue<Boolean> interrupt = new SynchronousQueue<>();
Stream<StreamElement> stream = BeamStream.stream(op, Position.OLDEST, false, true, interrupt::take, BeamStream::createPipelineDefault, armed);
CountDownLatch latch = new CountDownLatch(1);
new Thread(() -> {
// collect endless stream
stream.collect();
latch.countDown();
}).start();
// terminate
interrupt.put(true);
// and wait until the pipeline terminates
latch.await();
// make sonar happy
assertTrue(true);
}
use of cz.o2.proxima.repository.Repository in project proxima-platform by O2-Czech-Republic.
the class DirectBatchUnboundedSourceTest method testReadError.
@Test(expected = IOException.class)
public void testReadError() throws Exception {
PipelineOptions opts = PipelineOptionsFactory.create();
Repository repo = Repository.ofTest(ConfigFactory.load("test-reference.conf").resolve());
DirectBatchUnboundedSource source = DirectBatchUnboundedSource.of(repo.asFactory(), throwingReader(), Collections.singletonList(repo.getEntity("gateway").getAttribute("armed")), Long.MIN_VALUE, Long.MAX_VALUE, Collections.emptyMap());
List<? extends UnboundedSource<StreamElement, Checkpoint>> split = source.split(1, opts);
assertEquals(1, split.size());
UnboundedReader<StreamElement> reader = split.get(0).createReader(opts, null);
while (!reader.advance()) {
TimeUnit.MILLISECONDS.sleep(10);
}
}
use of cz.o2.proxima.repository.Repository in project proxima-platform by O2-Czech-Republic.
the class DirectBatchUnboundedSourceTest method testOffsetWithNoAdvance.
@Test
public void testOffsetWithNoAdvance() throws Exception {
PipelineOptions opts = PipelineOptionsFactory.create();
Repository repo = Repository.ofTest(ConfigFactory.load("test-reference.conf").resolve());
DirectBatchUnboundedSource source = DirectBatchUnboundedSource.of(repo.asFactory(), Optionals.get(direct.getBatchLogReader(armed)), Collections.singletonList(repo.getEntity("gateway").getAttribute("armed")), Long.MIN_VALUE, Long.MAX_VALUE, Collections.emptyMap());
List<? extends UnboundedSource<StreamElement, Checkpoint>> split = source.split(1, opts);
assertEquals(1, split.size());
OnlineAttributeWriter writer = Optionals.get(direct.getWriter(armed));
long now = System.currentTimeMillis();
writer.write(StreamElement.upsert(gateway, armed, UUID.randomUUID().toString(), "key", armed.getName(), now, new byte[] {}), (succ, exc) -> {
});
UnboundedReader<StreamElement> reader = split.get(0).createReader(opts, null);
while (!reader.advance()) {
TimeUnit.MILLISECONDS.sleep(10);
}
Checkpoint checkpoint = (Checkpoint) reader.getCheckpointMark();
assertNotNull(checkpoint);
assertEquals(1, checkpoint.getSkipFromFirst());
reader = split.get(0).createReader(opts, checkpoint);
checkpoint = (Checkpoint) reader.getCheckpointMark();
TestUtils.assertSerializable(source);
TestUtils.assertHashCodeAndEquals(source, SerializableUtils.clone(source));
assertEquals(checkpoint, reader.getCheckpointMark());
TestUtils.assertSerializable(checkpoint);
TestUtils.assertHashCodeAndEquals(checkpoint, SerializableUtils.clone(checkpoint));
}
use of cz.o2.proxima.repository.Repository in project proxima-platform by O2-Czech-Republic.
the class DirectBatchUnboundedSourceTest method testDirectBatchUnboundedSourceWithManyAndThrottling.
@Test(timeout = 30000)
public void testDirectBatchUnboundedSourceWithManyAndThrottling() {
Config config = ConfigFactory.parseString("beam.unbounded-batch.limit.uri = \"inmem:///proxima_gateway\"\n" + "beam.unbounded-batch.limit.throughput = 10000").withFallback(ConfigFactory.load("test-reference.conf")).resolve();
Repository repo = Repository.ofTest(config);
AttributeFamilyDescriptor readFamily = Optionals.get(repo.getAllFamilies().filter(af -> af.getName().equals("gateway-storage-stream")).findFirst());
assertEquals(URI.create("inmem:///proxima_gateway"), readFamily.getStorageUri());
testBatchUnboundedSourceWithCountUsingRepository(repo, 100);
}
Aggregations