Search in sources :

Example 1 with AbstractDelegatingRpcManager

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);
            }
        });
    }
}
Also used : Address(org.infinispan.remoting.transport.Address) ReplicableCommand(org.infinispan.commands.ReplicableCommand) ArrayList(java.util.ArrayList) InvalidateL1Command(org.infinispan.commands.write.InvalidateL1Command) SingleRpcCommand(org.infinispan.commands.remote.SingleRpcCommand) AbstractDelegatingRpcManager(org.infinispan.util.AbstractDelegatingRpcManager) ResponseCollector(org.infinispan.remoting.transport.ResponseCollector) RpcOptions(org.infinispan.remoting.rpc.RpcOptions) Collection(java.util.Collection) ReplListener(org.infinispan.test.ReplListener) CompletionStage(java.util.concurrent.CompletionStage) Cache(org.infinispan.Cache)

Example 2 with AbstractDelegatingRpcManager

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);
}
Also used : AbstractDelegatingRpcManager(org.infinispan.util.AbstractDelegatingRpcManager) Function(java.util.function.Function) RpcManager(org.infinispan.remoting.rpc.RpcManager) AbstractDelegatingRpcManager(org.infinispan.util.AbstractDelegatingRpcManager) TxCompletionNotificationCommand(org.infinispan.commands.remote.recovery.TxCompletionNotificationCommand) ReplicableCommand(org.infinispan.commands.ReplicableCommand) TransactionTable(org.infinispan.transaction.impl.TransactionTable) Collection(java.util.Collection)

Aggregations

Collection (java.util.Collection)2 ReplicableCommand (org.infinispan.commands.ReplicableCommand)2 AbstractDelegatingRpcManager (org.infinispan.util.AbstractDelegatingRpcManager)2 ArrayList (java.util.ArrayList)1 CompletionStage (java.util.concurrent.CompletionStage)1 Function (java.util.function.Function)1 Cache (org.infinispan.Cache)1 SingleRpcCommand (org.infinispan.commands.remote.SingleRpcCommand)1 TxCompletionNotificationCommand (org.infinispan.commands.remote.recovery.TxCompletionNotificationCommand)1 InvalidateL1Command (org.infinispan.commands.write.InvalidateL1Command)1 RpcManager (org.infinispan.remoting.rpc.RpcManager)1 RpcOptions (org.infinispan.remoting.rpc.RpcOptions)1 Address (org.infinispan.remoting.transport.Address)1 ResponseCollector (org.infinispan.remoting.transport.ResponseCollector)1 ReplListener (org.infinispan.test.ReplListener)1 TransactionTable (org.infinispan.transaction.impl.TransactionTable)1