Search in sources :

Example 6 with SystemTimer

use of org.apache.geode.internal.SystemTimer in project geode by apache.

the class StatAlertsManager method rescheduleTimer.

private synchronized void rescheduleTimer() {
    // time
    if (timer != null)
        timer.cancel();
    // Get the swarm. Currently rather UGLY.
    InternalDistributedSystem system = dm.getSystem();
    if (system == null || system.getDistributionManager() != dm) {
        throw new org.apache.geode.distributed.DistributedSystemDisconnectedException("This manager has been cancelled");
    }
    // start and schedule new timer
    timer = new SystemTimer(system, /* swarm */
    true);
    EvaluateAlertDefnsTask task = new EvaluateAlertDefnsTask();
    if (refreshAtFixedRate) {
        timer.scheduleAtFixedRate(task, 0, refreshInterval);
    } else {
        timer.schedule(task, 0, refreshInterval);
    }
}
Also used : InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) SystemTimer(org.apache.geode.internal.SystemTimer)

Example 7 with SystemTimer

use of org.apache.geode.internal.SystemTimer in project geode by apache.

the class GemFireCacheImplTest method checkPurgeCCPTimer.

@Test
public void checkPurgeCCPTimer() {
    InternalDistributedSystem ds = Fakes.distributedSystem();
    CacheConfig cc = new CacheConfig();
    TypeRegistry typeRegistry = mock(TypeRegistry.class);
    SystemTimer ccpTimer = mock(SystemTimer.class);
    GemFireCacheImpl gfc = GemFireCacheImpl.createWithAsyncEventListeners(ds, cc, typeRegistry);
    try {
        gfc.setCCPTimer(ccpTimer);
        for (int i = 1; i < GemFireCacheImpl.PURGE_INTERVAL; i++) {
            gfc.purgeCCPTimer();
            verify(ccpTimer, times(0)).timerPurge();
        }
        gfc.purgeCCPTimer();
        verify(ccpTimer, times(1)).timerPurge();
        for (int i = 1; i < GemFireCacheImpl.PURGE_INTERVAL; i++) {
            gfc.purgeCCPTimer();
            verify(ccpTimer, times(1)).timerPurge();
        }
        gfc.purgeCCPTimer();
        verify(ccpTimer, times(2)).timerPurge();
    } finally {
        gfc.close();
    }
}
Also used : InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) TypeRegistry(org.apache.geode.pdx.internal.TypeRegistry) SystemTimer(org.apache.geode.internal.SystemTimer) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Aggregations

SystemTimer (org.apache.geode.internal.SystemTimer)7 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)4 TypeRegistry (org.apache.geode.pdx.internal.TypeRegistry)2 UnitTest (org.apache.geode.test.junit.categories.UnitTest)2 Test (org.junit.Test)2 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Set (java.util.Set)1 CancelException (org.apache.geode.CancelException)1 DistributedSystem (org.apache.geode.distributed.DistributedSystem)1 DM (org.apache.geode.distributed.internal.DM)1 SystemTimerTask (org.apache.geode.internal.SystemTimer.SystemTimerTask)1 DistributedRegion (org.apache.geode.internal.cache.DistributedRegion)1 InternalCache (org.apache.geode.internal.cache.InternalCache)1 HeapEvictor (org.apache.geode.internal.cache.lru.HeapEvictor)1 OffHeapEvictor (org.apache.geode.internal.cache.lru.OffHeapEvictor)1