Search in sources :

Example 1 with InboundInvocationHandler

use of org.infinispan.remoting.inboundhandler.InboundInvocationHandler in project infinispan by infinispan.

the class ConcurrentStartTest method replaceInboundInvocationHandler.

private void replaceInboundInvocationHandler(EmbeddedCacheManager cm, CheckPoint checkPoint, int index) {
    InboundInvocationHandler handler = extractGlobalComponent(cm, InboundInvocationHandler.class);
    BlockingInboundInvocationHandler ourHandler = new BlockingInboundInvocationHandler(handler, checkPoint, index);
    replaceComponent(cm, InboundInvocationHandler.class, ourHandler, true);
}
Also used : InboundInvocationHandler(org.infinispan.remoting.inboundhandler.InboundInvocationHandler)

Example 2 with InboundInvocationHandler

use of org.infinispan.remoting.inboundhandler.InboundInvocationHandler in project infinispan by infinispan.

the class JGroupsTransportTest method blockRemoteGets.

private CompletableFuture<Void> blockRemoteGets() {
    CompletableFuture<Void> blocker = new CompletableFuture<>();
    InboundInvocationHandler oldInvocationHandler = TestingUtil.extractGlobalComponent(manager(1), InboundInvocationHandler.class);
    InboundInvocationHandler blockingInvocationHandler = new InboundInvocationHandler() {

        @Override
        public void handleFromCluster(Address origin, ReplicableCommand command, Reply reply, DeliverOrder order) {
            if (command instanceof ClusteredGetCommand) {
                log.tracef("Blocking clustered get");
                blocker.thenRun(() -> oldInvocationHandler.handleFromCluster(origin, command, reply, order));
            } else {
                oldInvocationHandler.handleFromCluster(origin, command, reply, order);
            }
        }

        @Override
        public void handleFromRemoteSite(String origin, XSiteReplicateCommand command, Reply reply, DeliverOrder order) {
            oldInvocationHandler.handleFromRemoteSite(origin, command, reply, order);
        }
    };
    TestingUtil.replaceComponent(manager(1), InboundInvocationHandler.class, blockingInvocationHandler, true);
    return blocker;
}
Also used : XSiteReplicateCommand(org.infinispan.xsite.XSiteReplicateCommand) CompletableFuture(java.util.concurrent.CompletableFuture) Address(org.infinispan.remoting.transport.Address) ReplicableCommand(org.infinispan.commands.ReplicableCommand) InboundInvocationHandler(org.infinispan.remoting.inboundhandler.InboundInvocationHandler) DeliverOrder(org.infinispan.remoting.inboundhandler.DeliverOrder) Reply(org.infinispan.remoting.inboundhandler.Reply) ByteString(org.infinispan.util.ByteString) ClusteredGetCommand(org.infinispan.commands.remote.ClusteredGetCommand)

Example 3 with InboundInvocationHandler

use of org.infinispan.remoting.inboundhandler.InboundInvocationHandler in project infinispan by infinispan.

the class OperationsDuringMergeConflictTest method performMerge.

@Override
protected void performMerge() {
    boolean modifyDuringMerge = mergeAction != MergeAction.NONE;
    CountDownLatch conflictLatch = new CountDownLatch(1);
    CountDownLatch stateTransferLatch = new CountDownLatch(1);
    try {
        IntStream.range(0, numMembersInCluster).forEach(i -> {
            wrapInboundInvocationHandler(cache(i), handler -> new BlockStateResponseCommandHandler(handler, conflictLatch));
            EmbeddedCacheManager manager = manager(i);
            InboundInvocationHandler handler = extractGlobalComponent(manager, InboundInvocationHandler.class);
            BlockingInboundInvocationHandler ourHandler = new BlockingInboundInvocationHandler(handler, stateTransferLatch);
            replaceComponent(manager, InboundInvocationHandler.class, ourHandler, true);
        });
        assertCacheGet(conflictKey, PARTITION_0_VAL, p0.getNodes());
        assertCacheGet(conflictKey, PARTITION_1_VAL, p1.getNodes());
        partition(0).merge(partition(1), false);
        assertCacheGet(conflictKey, PARTITION_0_VAL, p0.getNodes());
        assertCacheGet(conflictKey, PARTITION_1_VAL, p1.getNodes());
        if (modifyDuringMerge) {
            // Wait for CONFLICT_RESOLUTION topology to have been installed by the coordinator and then proceed
            List<Address> allMembers = caches().stream().map(cache -> cache.getCacheManager().getAddress()).collect(Collectors.toList());
            TestingUtil.waitForTopologyPhase(allMembers, CacheTopology.Phase.CONFLICT_RESOLUTION, caches().toArray(new Cache[numMembersInCluster]));
            if (mergeAction == MergeAction.PUT) {
                cache(0).put(conflictKey, mergeAction.value);
            } else {
                cache(0).remove(conflictKey);
            }
        }
        conflictLatch.countDown();
        stateTransferLatch.countDown();
        TestingUtil.waitForNoRebalance(caches());
        assertCacheGetValAllCaches(mergeAction);
    } catch (Throwable t) {
        conflictLatch.countDown();
        stateTransferLatch.countDown();
        throw t;
    }
}
Also used : IntStream(java.util.stream.IntStream) Reply(org.infinispan.remoting.inboundhandler.Reply) Test(org.testng.annotations.Test) Cache(org.infinispan.Cache) AbstractDelegatingHandler(org.infinispan.remoting.inboundhandler.AbstractDelegatingHandler) READ_OLD_WRITE_ALL(org.infinispan.topology.CacheTopology.Phase.READ_OLD_WRITE_ALL) AdvancedCache(org.infinispan.AdvancedCache) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) TestingUtil(org.infinispan.test.TestingUtil) TestInternalCacheEntryFactory(org.infinispan.test.fwk.TestInternalCacheEntryFactory) Address(org.infinispan.remoting.transport.Address) TestingUtil.extractGlobalComponent(org.infinispan.test.TestingUtil.extractGlobalComponent) InboundInvocationHandler(org.infinispan.remoting.inboundhandler.InboundInvocationHandler) MagicKey(org.infinispan.distribution.MagicKey) ReplicableCommand(org.infinispan.commands.ReplicableCommand) XSiteReplicateCommand(org.infinispan.xsite.XSiteReplicateCommand) StateResponseCommand(org.infinispan.commands.statetransfer.StateResponseCommand) TopologyUpdateCommand(org.infinispan.commands.topology.TopologyUpdateCommand) DIST_SYNC(org.infinispan.configuration.cache.CacheMode.DIST_SYNC) CacheTopology(org.infinispan.topology.CacheTopology) AssertJUnit.fail(org.testng.AssertJUnit.fail) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) CacheRpcCommand(org.infinispan.commands.remote.CacheRpcCommand) PerCacheInboundInvocationHandler(org.infinispan.remoting.inboundhandler.PerCacheInboundInvocationHandler) TestingUtil.wrapInboundInvocationHandler(org.infinispan.test.TestingUtil.wrapInboundInvocationHandler) TestingUtil.replaceComponent(org.infinispan.test.TestingUtil.replaceComponent) DeliverOrder(org.infinispan.remoting.inboundhandler.DeliverOrder) Address(org.infinispan.remoting.transport.Address) InboundInvocationHandler(org.infinispan.remoting.inboundhandler.InboundInvocationHandler) PerCacheInboundInvocationHandler(org.infinispan.remoting.inboundhandler.PerCacheInboundInvocationHandler) TestingUtil.wrapInboundInvocationHandler(org.infinispan.test.TestingUtil.wrapInboundInvocationHandler) CountDownLatch(java.util.concurrent.CountDownLatch) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) Cache(org.infinispan.Cache) AdvancedCache(org.infinispan.AdvancedCache)

Aggregations

InboundInvocationHandler (org.infinispan.remoting.inboundhandler.InboundInvocationHandler)3 ReplicableCommand (org.infinispan.commands.ReplicableCommand)2 DeliverOrder (org.infinispan.remoting.inboundhandler.DeliverOrder)2 Reply (org.infinispan.remoting.inboundhandler.Reply)2 Address (org.infinispan.remoting.transport.Address)2 XSiteReplicateCommand (org.infinispan.xsite.XSiteReplicateCommand)2 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 AdvancedCache (org.infinispan.AdvancedCache)1 Cache (org.infinispan.Cache)1 CacheRpcCommand (org.infinispan.commands.remote.CacheRpcCommand)1 ClusteredGetCommand (org.infinispan.commands.remote.ClusteredGetCommand)1 StateResponseCommand (org.infinispan.commands.statetransfer.StateResponseCommand)1 TopologyUpdateCommand (org.infinispan.commands.topology.TopologyUpdateCommand)1 DIST_SYNC (org.infinispan.configuration.cache.CacheMode.DIST_SYNC)1 MagicKey (org.infinispan.distribution.MagicKey)1