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);
}
}
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();
}
}
Aggregations