Search in sources :

Example 1 with QueryCacheScheduler

use of com.hazelcast.map.impl.querycache.QueryCacheScheduler in project hazelcast by hazelcast.

the class DefaultPublisherContext method startBackgroundAccumulatorScanner.

private void startBackgroundAccumulatorScanner() {
    QueryCacheScheduler scheduler = context.getQueryCacheScheduler();
    scheduler.scheduleWithRepetition(new AccumulatorScannerTask(context), SCAN_PERIOD_SECONDS);
}
Also used : AccumulatorScannerTask(com.hazelcast.map.impl.querycache.accumulator.AccumulatorScannerTask) QueryCacheScheduler(com.hazelcast.map.impl.querycache.QueryCacheScheduler)

Example 2 with QueryCacheScheduler

use of com.hazelcast.map.impl.querycache.QueryCacheScheduler in project hazelcast by hazelcast.

the class ClientQueryCacheContextTest method testGetQueryCacheScheduler.

@Test
public void testGetQueryCacheScheduler() {
    QueryCacheScheduler scheduler = context.getQueryCacheScheduler();
    assertNotNull(scheduler);
    final QuerySchedulerTask task = new QuerySchedulerTask();
    scheduler.execute(task);
    final QuerySchedulerRepetitionTask repetitionTask = new QuerySchedulerRepetitionTask();
    scheduler.scheduleWithRepetition(repetitionTask, 1);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertTrue(task.executed);
            assertTrue(repetitionTask.counter.get() > 1);
        }
    });
    scheduler.shutdown();
}
Also used : QuerySchedulerRepetitionTask(com.hazelcast.map.impl.querycache.NodeQueryCacheContextTest.QuerySchedulerRepetitionTask) QuerySchedulerTask(com.hazelcast.map.impl.querycache.NodeQueryCacheContextTest.QuerySchedulerTask) QueryCacheScheduler(com.hazelcast.map.impl.querycache.QueryCacheScheduler) AssertTask(com.hazelcast.test.AssertTask) ExpectedException(org.junit.rules.ExpectedException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with QueryCacheScheduler

use of com.hazelcast.map.impl.querycache.QueryCacheScheduler in project hazelcast by hazelcast.

the class DefaultPublisherContext method startRemovalTask.

private void startRemovalTask(final Collection<PartitionAccumulatorRegistry> removalCandidates, String uuid) {
    QueryCacheScheduler queryCacheScheduler = context.getQueryCacheScheduler();
    ScheduledFuture scheduledFuture = queryCacheScheduler.scheduleWithRepetition(new Runnable() {

        @Override
        public void run() {
            for (PartitionAccumulatorRegistry registry : removalCandidates) {
                removePartitionAccumulatorRegistry(registry);
            }
        }
    }, ORPHANED_QUERY_CACHE_REMOVAL_DELAY_SECONDS);
    ScheduledFuture prevFuture = removalCandidateFutures.put(uuid, scheduledFuture);
    if (prevFuture != null) {
        prevFuture.cancel(false);
    }
}
Also used : QueryCacheScheduler(com.hazelcast.map.impl.querycache.QueryCacheScheduler) ScheduledFuture(java.util.concurrent.ScheduledFuture)

Aggregations

QueryCacheScheduler (com.hazelcast.map.impl.querycache.QueryCacheScheduler)3 QuerySchedulerRepetitionTask (com.hazelcast.map.impl.querycache.NodeQueryCacheContextTest.QuerySchedulerRepetitionTask)1 QuerySchedulerTask (com.hazelcast.map.impl.querycache.NodeQueryCacheContextTest.QuerySchedulerTask)1 AccumulatorScannerTask (com.hazelcast.map.impl.querycache.accumulator.AccumulatorScannerTask)1 AssertTask (com.hazelcast.test.AssertTask)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 ScheduledFuture (java.util.concurrent.ScheduledFuture)1 Test (org.junit.Test)1 ExpectedException (org.junit.rules.ExpectedException)1