use of java.util.concurrent.ScheduledFuture in project hazelcast by hazelcast.
the class LoggingScheduledExecutor method afterExecute.
@Override
protected void afterExecute(Runnable runnable, Throwable throwable) {
super.afterExecute(runnable, throwable);
Level level = FINE;
if (throwable == null && runnable instanceof ScheduledFuture && ((ScheduledFuture) runnable).isDone()) {
try {
((Future) runnable).get();
} catch (CancellationException ce) {
throwable = ce;
} catch (ExecutionException ee) {
level = SEVERE;
throwable = ee.getCause();
} catch (InterruptedException ie) {
throwable = ie;
currentThread().interrupt();
}
}
if (throwable != null) {
logger.log(level, "Failed to execute " + runnable, throwable);
}
}
use of java.util.concurrent.ScheduledFuture in project hazelcast by hazelcast.
the class SecondsBasedEntryTaskScheduler method cancelAll.
public void cancelAll() {
synchronized (mutex) {
secondsOfKeys.clear();
scheduledEntries.clear();
for (ScheduledFuture task : scheduledTaskMap.values()) {
task.cancel(false);
}
scheduledTaskMap.clear();
}
}
use of java.util.concurrent.ScheduledFuture in project hazelcast by hazelcast.
the class DelegatingScheduledFutureStripperTest method get_unsupported.
@Test(expected = UnsupportedOperationException.class)
public void get_unsupported() throws ExecutionException, InterruptedException, TimeoutException {
ScheduledFuture future = scheduler.schedule(new SimpleCallableTestTask(), 0, TimeUnit.SECONDS);
new DelegatingScheduledFutureStripper(future).get(1, TimeUnit.SECONDS);
}
use of java.util.concurrent.ScheduledFuture in project hazelcast by hazelcast.
the class DelegatingScheduledFutureStripperTest method get.
@Test
public void get() throws ExecutionException, InterruptedException {
ScheduledFuture original = taskScheduler.schedule(new SimpleCallableTestTask(), 0, TimeUnit.SECONDS);
ScheduledFuture stripper = new DelegatingScheduledFutureStripper(original);
assertTrue(original.get() instanceof Future);
assertEquals(5, stripper.get());
}
use of java.util.concurrent.ScheduledFuture in project hazelcast by hazelcast.
the class DelegatingScheduledFutureStripperTest method equals.
@Test
public void equals() {
ScheduledFuture original = taskScheduler.schedule(new SimpleCallableTestTask(), 0, TimeUnit.SECONDS);
ScheduledFuture joker = taskScheduler.schedule(new SimpleCallableTestTask(), 1, TimeUnit.SECONDS);
ScheduledFuture testA = new DelegatingScheduledFutureStripper(original);
ScheduledFuture testB = new DelegatingScheduledFutureStripper(original);
ScheduledFuture testC = new DelegatingScheduledFutureStripper(joker);
assertTrue(testA.equals(testA));
assertTrue(testA.equals(testB));
assertFalse(testA.equals(null));
assertFalse(testA.equals(testC));
}
Aggregations