use of cz.o2.proxima.direct.commitlog.ObserveHandle in project proxima-platform by O2-Czech-Republic.
the class ListCommitLogTest method testObserveExternalizableUnnamedPauseContinue.
@Test(timeout = 10000)
public void testObserveExternalizableUnnamedPauseContinue() throws InterruptedException {
CommitLogReader reader = ListCommitLog.of(data(10), direct.getContext());
List<StreamElement> data = new ArrayList<>();
CountDownLatch latch = new CountDownLatch(1);
ObserveHandle handle = reader.observe(null, toList(data, b -> latch.countDown(), v -> v.getValue()[0] < 5));
latch.await();
assertEquals(6, data.size());
assertTrue(handle.getCommittedOffsets().isEmpty());
assertFalse(handle.getCurrentOffsets().isEmpty());
CountDownLatch nextLatch = new CountDownLatch(1);
reader.observeBulkOffsets(handle.getCurrentOffsets(), toList(data, b -> nextLatch.countDown()));
nextLatch.await();
assertEquals(11, data.size());
}
use of cz.o2.proxima.direct.commitlog.ObserveHandle in project proxima-platform by O2-Czech-Republic.
the class ListCommitLogTest method testObserveExternalizableUnnamed.
@Test(timeout = 10000)
public void testObserveExternalizableUnnamed() throws InterruptedException {
CommitLogReader reader = ListCommitLog.of(data(10), direct.getContext());
List<StreamElement> data = new ArrayList<>();
CountDownLatch latch = new CountDownLatch(1);
ObserveHandle handle = reader.observe(null, toList(data, b -> latch.countDown()));
latch.await();
assertEquals(10, data.size());
assertTrue(handle.getCommittedOffsets().isEmpty());
assertFalse(handle.getCurrentOffsets().isEmpty());
}
use of cz.o2.proxima.direct.commitlog.ObserveHandle in project proxima-platform by O2-Czech-Republic.
the class ListCommitLogTest method testObserveNonExternalizableUnnamedPauseContinue.
@Test(timeout = 10000)
public void testObserveNonExternalizableUnnamedPauseContinue() throws InterruptedException {
CommitLogReader reader = ListCommitLog.ofNonExternalizable(data(10), direct.getContext());
List<StreamElement> data = new ArrayList<>();
CountDownLatch latch = new CountDownLatch(1);
ObserveHandle handle = reader.observe(null, toList(data, b -> latch.countDown(), v -> v.getValue()[0] < 5));
latch.await();
assertEquals(6, data.size());
assertFalse(handle.getCommittedOffsets().isEmpty());
assertFalse(handle.getCurrentOffsets().isEmpty());
CountDownLatch nextLatch = new CountDownLatch(1);
reader.observeBulkOffsets(handle.getCurrentOffsets(), toList(data, b -> nextLatch.countDown()));
nextLatch.await();
assertEquals(10, data.size());
}
use of cz.o2.proxima.direct.commitlog.ObserveHandle in project proxima-platform by O2-Czech-Republic.
the class ListCommitLogTest method testObserveNonExternalizableUnnamed.
@Test(timeout = 10000)
public void testObserveNonExternalizableUnnamed() throws InterruptedException {
CommitLogReader reader = ListCommitLog.ofNonExternalizable(data(10), direct.getContext());
List<StreamElement> data = new ArrayList<>();
CountDownLatch latch = new CountDownLatch(1);
ObserveHandle handle = reader.observe(null, toList(data, b -> latch.countDown()));
latch.await();
assertEquals(10, data.size());
assertFalse(handle.getCommittedOffsets().isEmpty());
assertFalse(handle.getCurrentOffsets().isEmpty());
ListObserveHandle listObserveHandle = (ListObserveHandle) handle;
ListCommitLog.Consumer consumer = listObserveHandle.getConsumer();
assertTrue(consumer.getInflightOffsets().isEmpty());
}
use of cz.o2.proxima.direct.commitlog.ObserveHandle in project proxima-platform by O2-Czech-Republic.
the class ListCommitLogTest method testObserveBulkNonExternalizableUnnamed.
@Test(timeout = 10000)
public void testObserveBulkNonExternalizableUnnamed() throws InterruptedException {
CommitLogReader reader = ListCommitLog.ofNonExternalizable(data(10), direct.getContext());
List<StreamElement> data = new ArrayList<>();
CountDownLatch first = new CountDownLatch(1);
CountDownLatch second = new CountDownLatch(1);
ObserveHandle handle = reader.observeBulk(null, new CommitLogObserver() {
@Override
public boolean onError(Throwable error) {
throw new RuntimeException(error);
}
@Override
public boolean onNext(StreamElement ingest, OnNextContext context) {
context.nack();
return false;
}
@Override
public void onCancelled() {
first.countDown();
}
});
first.await();
List<Offset> offsets = handle.getCurrentOffsets();
handle = reader.observeBulkOffsets(offsets, toList(data, b -> second.countDown()));
second.await();
assertEquals(10, data.size());
assertFalse(handle.getCommittedOffsets().isEmpty());
assertFalse(handle.getCurrentOffsets().isEmpty());
ListObserveHandle listObserveHandle = (ListObserveHandle) handle;
ListCommitLog.Consumer consumer = listObserveHandle.getConsumer();
assertTrue(consumer.getInflightOffsets().isEmpty());
}
Aggregations