use of org.infinispan.test.fwk.TestClassLocal in project infinispan by infinispan.
the class AllClusterExecutorTest method testExecutorTriConsumerTimeoutException.
public void testExecutorTriConsumerTimeoutException() {
withCacheManagers(new MultiCacheManagerCallable(TestCacheManagerFactory.createCacheManager(CacheMode.DIST_SYNC, false), TestCacheManagerFactory.createCacheManager(CacheMode.DIST_SYNC, false)) {
@Override
public void call() throws InterruptedException, ExecutionException, TimeoutException {
EmbeddedCacheManager cm1 = cms[0];
TestClassLocal<CheckPoint> checkPoint = AllClusterExecutorTest.this.checkPoint;
SerializableFunction<EmbeddedCacheManager, Object> blockingFunction = m -> {
try {
checkPoint.get().trigger("block_execution");
checkPoint.get().awaitStrict("resume_execution", 10, TimeUnit.SECONDS);
checkPoint.get().trigger("complete");
} catch (InterruptedException | TimeoutException e) {
throw new TestException(e);
}
return null;
};
CompletableFuture<Void> futureRemote = executor(cm1).filterTargets(a -> !a.equals(cm1.getAddress())).timeout(1, TimeUnit.MILLISECONDS).submitConsumer(blockingFunction, (a, i, t) -> {
log.tracef("Consumer invoked with %s, %s, %s", a, i, t);
});
Exceptions.expectExecutionException(org.infinispan.util.concurrent.TimeoutException.class, futureRemote);
checkPoint.get().awaitStrict("block_execution", 10, TimeUnit.SECONDS);
checkPoint.get().trigger("resume_execution");
// Have to wait for callback to complete - otherwise a different thread could find the "resume_execution"
// checkpoint reached incorrectly
checkPoint.get().awaitStrict("complete", 10, TimeUnit.SECONDS);
CompletableFuture<Void> futureLocal = executor(cm1).filterTargets(a -> a.equals(cm1.getAddress())).timeout(1, TimeUnit.MILLISECONDS).submitConsumer(blockingFunction, (a, i, t) -> {
log.tracef("Consumer invoked with %s, %s, %s", a, i, t);
});
Exceptions.expectExecutionException(org.infinispan.util.concurrent.TimeoutException.class, futureLocal);
checkPoint.get().awaitStrict("block_execution", 10, TimeUnit.SECONDS);
checkPoint.get().trigger("resume_execution");
checkPoint.get().awaitStrict("complete", 10, TimeUnit.SECONDS);
}
});
}
Aggregations