use of org.infinispan.util.AbstractDelegatingRpcManager in project infinispan by infinispan.
the class DistAsyncFuncTest method createCacheManagers.
@Override
protected void createCacheManagers() throws Throwable {
super.createCacheManagers();
r1 = new ReplListener(c1, true, true);
r2 = new ReplListener(c2, true, true);
r3 = new ReplListener(c3, true, true);
r4 = new ReplListener(c4, true, true);
r = new ReplListener[] { r1, r2, r3, r4 };
listenerLookup = new HashMap<>();
for (ReplListener rl : r) listenerLookup.put(rl.getCache().getCacheManager().getAddress(), rl);
for (Cache c : caches) {
TestingUtil.wrapComponent(c, RpcManager.class, original -> new AbstractDelegatingRpcManager(original) {
@Override
protected <T> CompletionStage<T> performRequest(Collection<Address> targets, ReplicableCommand command, ResponseCollector<T> collector, Function<ResponseCollector<T>, CompletionStage<T>> invoker, RpcOptions rpcOptions) {
if (command instanceof SingleRpcCommand) {
command = ((SingleRpcCommand) command).getCommand();
}
if (command instanceof InvalidateL1Command) {
InvalidateL1Command invalidateL1Command = (InvalidateL1Command) command;
log.tracef("Sending invalidation %s to %s", command, targets);
Collection<Address> realTargets = targets != null ? targets : cacheAddresses;
for (Address target : realTargets) {
expectedL1Invalidations.computeIfAbsent(target, ignored -> Collections.synchronizedList(new ArrayList<>())).add(invalidateL1Command);
}
}
return super.performRequest(targets, command, collector, invoker, rpcOptions);
}
});
}
}
use of org.infinispan.util.AbstractDelegatingRpcManager in project infinispan by infinispan.
the class AbstractCrashTest method skipTxCompletion.
protected void skipTxCompletion(final AdvancedCache<Object, Object> cache, final CountDownLatch releaseLocksLatch) {
RpcManager rpcManager = new AbstractDelegatingRpcManager(cache.getRpcManager()) {
@Override
protected <T> void performSend(Collection<Address> targets, ReplicableCommand command, Function<ResponseCollector<T>, CompletionStage<T>> invoker) {
if (command instanceof TxCompletionNotificationCommand) {
releaseLocksLatch.countDown();
log.tracef("Skipping TxCompletionNotificationCommand");
} else {
super.performSend(targets, command, invoker);
}
}
};
// not too nice: replace the rpc manager in the class that builds the Sync objects
final TransactionTable transactionTable = TestingUtil.getTransactionTable(cache(1));
TestingUtil.replaceField(rpcManager, "rpcManager", transactionTable, TransactionTable.class);
TxControlInterceptor txControlInterceptor = new TxControlInterceptor();
txControlInterceptor.prepareProgress.countDown();
txControlInterceptor.commitProgress.countDown();
extractInterceptorChain(advancedCache(1)).addInterceptor(txControlInterceptor, 1);
}
Aggregations