use of com.questdb.cairo.pool.PoolListener in project questdb by bluestreak01.
the class EngineTest method testExpiry.
@Test
public void testExpiry() throws Exception {
TestUtils.assertMemoryLeak(() -> {
createX();
final ObjHashSet<Job> jobs = new ObjHashSet<>();
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 (Engine engine = new Engine(configuration)) {
engine.setPoolListener(listener);
assertWriter(engine, "x");
assertReader(engine, "x");
engine.exportJobs(jobs);
Assert.assertEquals(1, jobs.size());
Job job = jobs.get(0);
Assert.assertNotNull(job);
Assert.assertTrue(job.run());
Assert.assertFalse(job.run());
Assert.assertEquals(2, listener.count);
}
});
}
Aggregations