use of org.apache.ignite.internal.util.lang.GridTuple in project ignite by apache.
the class GridScheduleSelfTest method testRunnableCancel.
/**
* @throws Exception If failed.
*/
public void testRunnableCancel() throws Exception {
SchedulerFuture fut = null;
final GridTuple<Integer> tpl = new GridTuple<>(0);
try {
fut = grid(0).scheduler().scheduleLocal(new Runnable() {
@Override
public void run() {
tpl.set(tpl.get() + 1);
}
}, "{1, *} * * * * *");
assertEquals(Integer.valueOf(0), tpl.get());
fut.cancel();
assert fut.isCancelled();
assert fut.isDone();
assertEquals(Integer.valueOf(0), tpl.get());
try {
fut.get();
fail("IgniteException must have been thrown");
} catch (IgniteException e) {
info("Caught expected exception: " + e);
}
try {
fut.get(500, SECONDS);
fail("IgniteException must have been thrown");
} catch (IgniteException e) {
info("Caught expected exception: " + e);
}
} finally {
assert fut != null;
if (!fut.isCancelled())
fut.cancel();
}
}
Aggregations