use of org.infinispan.commands.write.PutKeyValueCommand in project hibernate-orm by hibernate.
the class AbstractRegionAccessStrategyTest method expectRemotePutFromLoad.
private CountDownLatch expectRemotePutFromLoad(AdvancedCache localCache, AdvancedCache remoteCache) {
CountDownLatch putFromLoadLatch;
if (!isUsingInvalidation()) {
putFromLoadLatch = new CountDownLatch(1);
// The command may fail to replicate if it can't acquire lock locally
ExpectingInterceptor.Condition remoteCondition = ExpectingInterceptor.get(remoteCache).when((ctx, cmd) -> !ctx.isOriginLocal() && cmd instanceof PutKeyValueCommand);
ExpectingInterceptor.Condition localCondition = ExpectingInterceptor.get(localCache).whenFails((ctx, cmd) -> ctx.isOriginLocal() && cmd instanceof PutKeyValueCommand);
remoteCondition.run(() -> {
localCondition.cancel();
putFromLoadLatch.countDown();
});
localCondition.run(() -> {
remoteCondition.cancel();
putFromLoadLatch.countDown();
});
// just for case the test fails and does not remove the interceptor itself
cleanup.add(() -> ExpectingInterceptor.cleanup(localCache, remoteCache));
} else {
putFromLoadLatch = new CountDownLatch(0);
}
return putFromLoadLatch;
}
use of org.infinispan.commands.write.PutKeyValueCommand in project hibernate-orm by hibernate.
the class AbstractRegionAccessStrategyTest method expectPutWithValue.
protected CountDownLatch expectPutWithValue(Predicate<Object> valuePredicate) {
if (!isUsingInvalidation() && accessType != AccessType.NONSTRICT_READ_WRITE) {
CountDownLatch latch = new CountDownLatch(1);
ExpectingInterceptor.get(remoteRegion.getCache()).when((ctx, cmd) -> cmd instanceof PutKeyValueCommand && valuePredicate.test(((PutKeyValueCommand) cmd).getValue())).countDown(latch);
cleanup.add(() -> ExpectingInterceptor.cleanup(remoteRegion.getCache()));
return latch;
} else {
return new CountDownLatch(0);
}
}
use of org.infinispan.commands.write.PutKeyValueCommand in project hibernate-orm by hibernate.
the class AbstractFunctionalTest method expectPutWithValue.
protected CountDownLatch expectPutWithValue(AdvancedCache cache, Predicate<Object> valuePredicate, int numUpdates) {
if (!cacheMode.isInvalidation() && accessType != AccessType.NONSTRICT_READ_WRITE) {
CountDownLatch latch = new CountDownLatch(numUpdates);
ExpectingInterceptor.get(cache).when((ctx, cmd) -> cmd instanceof PutKeyValueCommand && valuePredicate.test(((PutKeyValueCommand) cmd).getValue())).countDown(latch);
cleanup.add(() -> ExpectingInterceptor.cleanup(cache));
return latch;
} else {
return new CountDownLatch(0);
}
}
Aggregations