Search in sources :

Example 1 with PoolListener

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

Aggregations

PoolListener (com.questdb.cairo.pool.PoolListener)1 Job (com.questdb.mp.Job)1 ObjHashSet (com.questdb.std.ObjHashSet)1 Test (org.junit.Test)1