use of org.apache.geode.internal.SystemTimer in project geode by apache.
the class GemFireCacheImplTest method checkEvictorsClosed.
@Test
public void checkEvictorsClosed() {
InternalDistributedSystem ds = Fakes.distributedSystem();
CacheConfig cc = new CacheConfig();
TypeRegistry typeRegistry = mock(TypeRegistry.class);
SystemTimer ccpTimer = mock(SystemTimer.class);
HeapEvictor he = mock(HeapEvictor.class);
OffHeapEvictor ohe = mock(OffHeapEvictor.class);
GemFireCacheImpl gfc = GemFireCacheImpl.createWithAsyncEventListeners(ds, cc, typeRegistry);
try {
gfc.setHeapEvictor(he);
gfc.setOffHeapEvictor(ohe);
} finally {
gfc.close();
}
verify(he, times(1)).close();
verify(ohe, times(1)).close();
}
use of org.apache.geode.internal.SystemTimer in project geode by apache.
the class DSClock method cancelAndScheduleNewCacheTimerTask.
/**
* Cancel the previous slow down task (If it exists) and schedule a new one.
*/
private void cancelAndScheduleNewCacheTimerTask(long offset) {
InternalCache cache = GemFireCacheImpl.getInstance();
if (cache != null && !cache.isClosed()) {
if (this.cacheTimeTask != null) {
this.cacheTimeTask.cancel();
}
cacheTimeTask = new CacheTimeTask(offset);
SystemTimer timer = cache.getCCPTimer();
timer.scheduleAtFixedRate(cacheTimeTask, 1, /* Start after 1ms */
2);
if (logger.isDebugEnabled()) {
logger.debug("Started a timer task to suspend cache time for new lower offset of {}ms and current offset is: {}", offset, cacheTimeDelta);
}
}
}
use of org.apache.geode.internal.SystemTimer in project geode by apache.
the class PRSanityCheckMessage method schedule.
/**
* Send a sanity check message and schedule a timer to send another one in
* gemfire.PRSanityCheckInterval (default 5000) milliseconds. This can be enabled with
* gemfire.PRSanityCheckEnabled=true.
*/
public static void schedule(final PartitionedRegion pr) {
if (Boolean.getBoolean(DistributionConfig.GEMFIRE_PREFIX + "PRSanityCheckEnabled")) {
final DM dm = pr.getDistributionManager();
// RegionAdvisor ra = pr.getRegionAdvisor();
// final Set recipients = ra.adviseAllPRNodes();
DistributedRegion prRoot = (DistributedRegion) PartitionedRegionHelper.getPRRoot(pr.getCache(), false);
if (prRoot == null) {
return;
}
final Set recipients = prRoot.getDistributionAdvisor().adviseGeneric();
if (recipients.size() <= 0) {
return;
}
final PRSanityCheckMessage delayedInstance = new PRSanityCheckMessage(recipients, pr.getPRId(), null, pr.getRegionIdentifier());
PRSanityCheckMessage instance = new PRSanityCheckMessage(recipients, pr.getPRId(), null, pr.getRegionIdentifier());
dm.putOutgoing(instance);
int sanityCheckInterval = Integer.getInteger(DistributionConfig.GEMFIRE_PREFIX + "PRSanityCheckInterval", 5000).intValue();
if (sanityCheckInterval != 0) {
final SystemTimer tm = new SystemTimer(dm.getSystem(), true);
SystemTimer.SystemTimerTask st = new SystemTimer.SystemTimerTask() {
@Override
public void run2() {
try {
if (!pr.isLocallyDestroyed && !pr.isClosed && !pr.isDestroyed()) {
dm.putOutgoing(delayedInstance);
}
} catch (CancelException cce) {
// cache is closed - can't send the message
} finally {
tm.cancel();
}
}
};
tm.schedule(st, sanityCheckInterval);
}
}
}
use of org.apache.geode.internal.SystemTimer in project geode by apache.
the class GMSMembershipManager method startCleanupTimer.
/** starts periodic task to perform cleanup chores such as expire surprise members */
private void startCleanupTimer() {
if (this.listener == null || listener.getDM() == null) {
return;
}
DistributedSystem ds = this.listener.getDM().getSystem();
this.cleanupTimer = new SystemTimer(ds, true);
SystemTimer.SystemTimerTask st = new SystemTimer.SystemTimerTask() {
@Override
public void run2() {
cleanUpSurpriseMembers();
}
};
this.cleanupTimer.scheduleAtFixedRate(st, surpriseMemberTimeout, surpriseMemberTimeout / 3);
}
use of org.apache.geode.internal.SystemTimer in project geode by apache.
the class Connection method scheduleAckTimeouts.
/** ensure that a task is running to monitor transmission and reading of acks */
public synchronized void scheduleAckTimeouts() {
if (ackTimeoutTask == null) {
final long msAW = this.owner.getDM().getConfig().getAckWaitThreshold() * 1000;
final long msSA = this.owner.getDM().getConfig().getAckSevereAlertThreshold() * 1000;
ackTimeoutTask = new SystemTimer.SystemTimerTask() {
@Override
public void run2() {
if (owner.isClosed()) {
return;
}
byte connState = -1;
synchronized (stateLock) {
connState = connectionState;
}
boolean sentAlert = false;
synchronized (Connection.this) {
if (socketInUse) {
switch(connState) {
case Connection.STATE_IDLE:
break;
case Connection.STATE_SENDING:
sentAlert = doSevereAlertProcessing();
break;
case Connection.STATE_POST_SENDING:
break;
case Connection.STATE_READING_ACK:
sentAlert = doSevereAlertProcessing();
break;
case Connection.STATE_RECEIVED_ACK:
break;
default:
}
}
}
List group = ackConnectionGroup;
if (sentAlert && group != null) {
// the time stamps and give others more time
for (Iterator it = group.iterator(); it.hasNext(); ) {
Connection con = (Connection) it.next();
if (con != Connection.this) {
con.transmissionStartTime += con.ackSATimeout;
}
}
}
}
};
synchronized (owner) {
SystemTimer timer = owner.getIdleConnTimer();
if (timer != null) {
if (msSA > 0) {
timer.scheduleAtFixedRate(ackTimeoutTask, msAW, Math.min(msAW, msSA));
} else {
timer.schedule(ackTimeoutTask, msAW);
}
}
}
}
}
Aggregations