use of com.questdb.store.factory.FactoryEventListener in project questdb by bluestreak01.
the class FactoryEventLoggerTest method testThroughput.
@Test
@Ignore
public void testThroughput() throws Exception {
final FactoryEventLogger logger = new FactoryEventLogger(getFactory(), 1000, 1000, MicrosecondClockImpl.INSTANCE);
final int count = 1000;
final CountDownLatch done = new CountDownLatch(1);
final CyclicBarrier barrier = new CyclicBarrier(2);
final FactoryEventListener listener = getFactory().getEventListener();
new Thread(() -> {
try (Journal r = getFactory().reader("$mon_factory")) {
barrier.await();
int i = 0;
while (i < count) {
if (logger.run()) {
i++;
} else {
r.refresh();
if (r.size() == count) {
break;
}
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
done.countDown();
}
}).start();
barrier.await();
int i = 0;
while (i < count) {
if (listener.onEvent((byte) 1, 1, "test", (short) 1, (short) 0, (short) 5)) {
i++;
} else {
LockSupport.parkNanos(1);
}
}
done.await();
logger.close();
try (Journal r = getFactory().reader("$mon_factory")) {
System.out.println(r.size());
}
}
Aggregations