*/
public void testShutdown() throws Exception {
for (int i = 0; i < 5; i++) {
final GridHadoopExecutorService exec = new GridHadoopExecutorService(log, "_GRID_NAME_", 10, 5);
final LongAdder sum = new LongAdder();
final AtomicBoolean finish = new AtomicBoolean();
GridFuture<?> fut = multithreadedAsync(new Callable<Object>() {
@Override public Object call() throws Exception {
while (!finish.get()) {
exec.submit(new Callable<Void>() {
@Override public Void call() throws Exception {
sum.increment();
return null;
}
});
}
return null;
}
}, 19);
Thread.sleep(200);
assertTrue(exec.shutdown(50));
long res = sum.sum();
assertTrue(res > 0);
finish.set(true);
fut.get();
assertEquals(res, sum.sum()); // Nothing was executed after shutdown.
X.println("_ ok");
}
}