Search in sources :

Example 6 with RpcManager

use of org.infinispan.remoting.rpc.RpcManager in project infinispan by infinispan.

the class PessimistTxFailureAfterLockingTest method replaceRpcManagerInCache.

private void replaceRpcManagerInCache(Cache cache) {
    RpcManager rpcManager = TestingUtil.extractComponent(cache, RpcManager.class);
    TestControllerRpcManager testControllerRpcManager = new TestControllerRpcManager(rpcManager);
    TestingUtil.replaceComponent(cache, RpcManager.class, testControllerRpcManager, true);
}
Also used : RpcManager(org.infinispan.remoting.rpc.RpcManager) AbstractDelegatingRpcManager(org.infinispan.util.AbstractDelegatingRpcManager)

Example 7 with RpcManager

use of org.infinispan.remoting.rpc.RpcManager 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)

Example 8 with RpcManager

use of org.infinispan.remoting.rpc.RpcManager in project infinispan by infinispan.

the class OutboundRpcSequencerAction method replaceRpcManager.

private void replaceRpcManager() {
    if (ourRpcManager == null) {
        ComponentRegistry componentRegistry = cache.getAdvancedCache().getComponentRegistry();
        RpcManager rpcManager = componentRegistry.getComponent(RpcManager.class);
        ourRpcManager = new SequencerRpcManager(rpcManager, stateSequencer, matcher);
        TestingUtil.replaceComponent(cache, RpcManager.class, ourRpcManager, true);
    }
}
Also used : RpcManager(org.infinispan.remoting.rpc.RpcManager) AbstractDelegatingRpcManager(org.infinispan.util.AbstractDelegatingRpcManager) ComponentRegistry(org.infinispan.factories.ComponentRegistry)

Example 9 with RpcManager

use of org.infinispan.remoting.rpc.RpcManager in project infinispan by infinispan.

the class MessageSentToLeaverTest method testGroupRequestSentToMemberAfterLeaving.

public void testGroupRequestSentToMemberAfterLeaving() {
    EmbeddedCacheManager cm1 = null, cm2 = null, cm3 = null;
    try {
        ConfigurationBuilder c = new ConfigurationBuilder();
        c.clustering().cacheMode(CacheMode.REPL_SYNC).hash().numOwners(3);
        cm1 = TestCacheManagerFactory.createClusteredCacheManager(c);
        cm2 = TestCacheManagerFactory.createClusteredCacheManager(c);
        cm3 = TestCacheManagerFactory.createClusteredCacheManager(c);
        Cache<Object, Object> c1 = cm1.getCache();
        Cache<Object, Object> c2 = cm2.getCache();
        Cache<Object, Object> c3 = cm3.getCache();
        TestingUtil.blockUntilViewsReceived(30000, c1, c2, c3);
        c2.put("k", "v1");
        RpcManager rpcManager = TestingUtil.extractComponent(c1, RpcManager.class);
        Collection<Address> addresses = cm1.getMembers();
        CommandsFactory cf = TestingUtil.extractCommandsFactory(c1);
        PutKeyValueCommand cmd = cf.buildPutKeyValueCommand("k", "v2", 0, new EmbeddedMetadata.Builder().build(), EnumUtil.EMPTY_BIT_SET);
        RpcOptions rpcOptions = rpcManager.getSyncRpcOptions();
        cmd.setTopologyId(rpcManager.getTopologyId());
        Map<Address, Response> responseMap = rpcManager.blocking(rpcManager.invokeCommand(addresses, cmd, MapResponseCollector.validOnly(), rpcOptions));
        assert responseMap.size() == 2;
        TestingUtil.killCacheManagers(cm2);
        TestingUtil.blockUntilViewsReceived(30000, false, c1, c3);
        try {
            rpcManager.blocking(rpcManager.invokeCommand(addresses, cmd, MapResponseCollector.validOnly(), rpcOptions));
            assert false : "invokeRemotely should have thrown an exception";
        } catch (SuspectException e) {
        // expected
        }
    } finally {
        TestingUtil.killCacheManagers(cm1, cm2, cm3);
    }
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) CommandsFactory(org.infinispan.commands.CommandsFactory) RpcManager(org.infinispan.remoting.rpc.RpcManager) Address(org.infinispan.remoting.transport.Address) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) SuspectException(org.infinispan.remoting.transport.jgroups.SuspectException) Response(org.infinispan.remoting.responses.Response) RpcOptions(org.infinispan.remoting.rpc.RpcOptions) PutKeyValueCommand(org.infinispan.commands.write.PutKeyValueCommand)

Example 10 with RpcManager

use of org.infinispan.remoting.rpc.RpcManager in project infinispan by infinispan.

the class ForceSyncAsyncFlagsTest method testForceAsyncFlagUsage.

public void testForceAsyncFlagUsage() throws Exception {
    ConfigurationBuilder builder = getDefaultClusteredCacheConfig(CacheMode.REPL_SYNC, false);
    builder.clustering().hash().numSegments(1).consistentHashFactory(new ReplicatedControlledConsistentHashFactory(0));
    createClusteredCaches(2, "replSync", builder);
    AdvancedCache<String, String> cache1 = this.<String, String>cache(0, "replSync").getAdvancedCache();
    cache(1, "replSync").getAdvancedCache();
    Transport originalTransport = TestingUtil.extractGlobalComponent(cache1.getCacheManager(), Transport.class);
    RpcManagerImpl rpcManager = (RpcManagerImpl) TestingUtil.extractComponent(cache1, RpcManager.class);
    Transport mockTransport = spy(originalTransport);
    rpcManager.setTransport(mockTransport);
    // check that the replication call was sync
    cache1.put("k", "v");
    verify(mockTransport).invokeCommandOnAll(any(), any(), any(), any(), anyLong(), any());
    reset(mockTransport);
    // verify FORCE_ASYNCHRONOUS flag on SYNC cache
    cache1.withFlags(Flag.FORCE_ASYNCHRONOUS).put("k", "v");
    verify(mockTransport).sendToAll(any(ReplicableCommand.class), any(DeliverOrder.class));
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) RpcManagerImpl(org.infinispan.remoting.rpc.RpcManagerImpl) RpcManager(org.infinispan.remoting.rpc.RpcManager) ReplicableCommand(org.infinispan.commands.ReplicableCommand) DeliverOrder(org.infinispan.remoting.inboundhandler.DeliverOrder) ReplicatedControlledConsistentHashFactory(org.infinispan.util.ReplicatedControlledConsistentHashFactory) Transport(org.infinispan.remoting.transport.Transport)

Aggregations

RpcManager (org.infinispan.remoting.rpc.RpcManager)37 Address (org.infinispan.remoting.transport.Address)11 CommandsFactory (org.infinispan.commands.CommandsFactory)7 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)7 RpcOptions (org.infinispan.remoting.rpc.RpcOptions)7 Transport (org.infinispan.remoting.transport.Transport)7 Map (java.util.Map)5 ComponentRegistry (org.infinispan.factories.ComponentRegistry)5 DeliverOrder (org.infinispan.remoting.inboundhandler.DeliverOrder)4 RpcManagerImpl (org.infinispan.remoting.rpc.RpcManagerImpl)4 AbstractDelegatingRpcManager (org.infinispan.util.AbstractDelegatingRpcManager)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 List (java.util.List)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 Cache (org.infinispan.Cache)3 IntSet (org.infinispan.commons.util.IntSet)3 InternalDataContainer (org.infinispan.container.impl.InternalDataContainer)3 InitialPublisherCommand (org.infinispan.reactive.publisher.impl.commands.batch.InitialPublisherCommand)3 Response (org.infinispan.remoting.responses.Response)3