use of io.questdb.cairo.pool.PoolListener in project questdb by bluestreak01.
the class CairoEngineTest method testExpiry.
@Test
public void testExpiry() throws Exception {
TestUtils.assertMemoryLeak(() -> {
createX();
class MyListener implements PoolListener {
int count = 0;
@Override
public void onEvent(byte factoryType, long thread, CharSequence name, short event, short segment, short position) {
if (event == PoolListener.EV_EXPIRE) {
count++;
}
}
}
MyListener listener = new MyListener();
try (CairoEngine engine = new CairoEngine(configuration)) {
engine.setPoolListener(listener);
assertWriter(engine, "x");
assertReader(engine, "x");
Job job = engine.getWriterMaintenanceJob();
Assert.assertNotNull(job);
Assert.assertTrue(job.run(0));
Assert.assertFalse(job.run(0));
Assert.assertEquals(2, listener.count);
}
});
}
Aggregations