use of org.apache.cassandra.concurrent.ScheduledExecutorPlus in project cassandra by apache.
the class PaxosSimulation method run.
public void run() {
AtomicLong counter = new AtomicLong();
ScheduledExecutorPlus livenessChecker = null;
ScheduledFuture<?> liveness = null;
if (CassandraRelevantProperties.TEST_SIMULATOR_LIVENESS_CHECK.getBoolean()) {
livenessChecker = ExecutorFactory.Global.executorFactory().scheduled("SimulationLiveness");
liveness = livenessChecker.scheduleWithFixedDelay(new Runnable() {
long prev = 0;
@Override
public void run() {
long cur = counter.get();
if (cur == prev) {
logger.error("Simulation appears to have stalled");
throw failWithOOM();
}
prev = cur;
}
}, 1L, 1L, TimeUnit.MINUTES);
}
try (CloseableIterator<?> iter = iterator()) {
while (iter.hasNext()) {
iter.next();
counter.incrementAndGet();
}
} finally {
if (liveness != null)
liveness.cancel(true);
if (livenessChecker != null)
livenessChecker.shutdownNow();
}
}
Aggregations