Search in sources :

Example 1 with PoolListener

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);
        }
    });
}
Also used : PoolListener(io.questdb.cairo.pool.PoolListener) Job(io.questdb.mp.Job) Test(org.junit.Test)

Aggregations

PoolListener (io.questdb.cairo.pool.PoolListener)1 Job (io.questdb.mp.Job)1 Test (org.junit.Test)1