Search in sources :

Example 6 with DeliverOrder

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

the class JGroupsTransport method backupRemotely.

@Override
public BackupResponse backupRemotely(Collection<XSiteBackup> backups, XSiteReplicateCommand command) {
    if (log.isTraceEnabled())
        log.tracef("About to send to backups %s, command %s", backups, command);
    Map<XSiteBackup, CompletableFuture<ValidResponse>> backupCalls = new HashMap<>(backups.size());
    for (XSiteBackup xsb : backups) {
        assert !localSite.equals(xsb.getSiteName()) : "sending to local site";
        Address recipient = JGroupsAddressCache.fromJGroupsAddress(new SiteMaster(xsb.getSiteName()));
        long requestId = requests.newRequestId();
        logRequest(requestId, command, recipient, "backup");
        SingleSiteRequest<ValidResponse> request = new SingleSiteRequest<>(SingleResponseCollector.validOnly(), requestId, requests, xsb.getSiteName());
        addRequest(request);
        backupCalls.put(xsb, request);
        DeliverOrder order = xsb.isSync() ? DeliverOrder.NONE : DeliverOrder.PER_SENDER;
        long timeout = xsb.getTimeout();
        try {
            sendCommand(recipient, command, request.getRequestId(), order, false, false);
            if (timeout > 0) {
                request.setTimeout(timeoutExecutor, timeout, TimeUnit.MILLISECONDS);
            }
        } catch (Throwable t) {
            request.cancel(true);
            throw t;
        }
    }
    return new JGroupsBackupResponse(backupCalls, timeService);
}
Also used : XSiteBackup(org.infinispan.xsite.XSiteBackup) PhysicalAddress(org.jgroups.PhysicalAddress) SiteAddress(org.jgroups.protocols.relay.SiteAddress) JGroupsAddressCache.fromJGroupsAddress(org.infinispan.remoting.transport.jgroups.JGroupsAddressCache.fromJGroupsAddress) Address(org.infinispan.remoting.transport.Address) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ValidResponse(org.infinispan.remoting.responses.ValidResponse) DeliverOrder(org.infinispan.remoting.inboundhandler.DeliverOrder) CompletableFuture(java.util.concurrent.CompletableFuture) SiteMaster(org.jgroups.protocols.relay.SiteMaster)

Example 7 with DeliverOrder

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

the class TopologyManagementHelper method executeOnClusterAsync.

public void executeOnClusterAsync(Transport transport, ReplicableCommand command) {
    // invoke remotely
    try {
        DeliverOrder deliverOrder = DeliverOrder.NONE;
        transport.sendToAll(command, deliverOrder);
    } catch (Exception e) {
        throw Util.rewrapAsCacheException(e);
    }
    // invoke the command on the local node
    try {
        if (log.isTraceEnabled())
            log.tracef("Attempting to execute command on self: %s", command);
        bcr.wireDependencies(command, true);
        invokeAsync(command);
    } catch (Throwable throwable) {
    // The command already logs any exception in invoke()
    }
}
Also used : DeliverOrder(org.infinispan.remoting.inboundhandler.DeliverOrder)

Example 8 with DeliverOrder

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

the class ScatteredStreamIteratorTest method blockStateTransfer.

@Override
protected <K> void blockStateTransfer(Cache<?, ?> cache, CheckPoint checkPoint) {
    // TODO Replace with Mocks.blockInboundCacheRpcCommand() once ISPN-10864 is fixed
    Executor executor = extractGlobalComponent(cache.getCacheManager(), ExecutorService.class, KnownComponentNames.NON_BLOCKING_EXECUTOR);
    TestingUtil.wrapInboundInvocationHandler(cache, handler -> new AbstractDelegatingHandler(handler) {

        @Override
        public void handle(CacheRpcCommand command, Reply reply, DeliverOrder order) {
            if (!(command instanceof ScatteredStateGetKeysCommand)) {
                delegate.handle(command, reply, order);
                return;
            }
            checkPoint.trigger(Mocks.BEFORE_INVOCATION);
            // Scattered cache iteration blocks and waits for state transfer to fetch the values
            // if a segment is owned in the pending CH, so we can't block forever
            // Instead we just block for 2 seconds to verify ISPN-10984
            checkPoint.future(Mocks.BEFORE_RELEASE, 2, TimeUnit.SECONDS, executor).whenComplete((ignored1, ignored2) -> delegate.handle(command, reply, order)).thenCompose(ignored -> {
                checkPoint.trigger(Mocks.AFTER_INVOCATION);
                return checkPoint.future(Mocks.AFTER_RELEASE, 20, TimeUnit.SECONDS, executor);
            });
        }
    });
}
Also used : CheckPoint(org.infinispan.test.fwk.CheckPoint) Executor(java.util.concurrent.Executor) Mocks(org.infinispan.test.Mocks) Reply(org.infinispan.remoting.inboundhandler.Reply) KnownComponentNames(org.infinispan.factories.KnownComponentNames) Test(org.testng.annotations.Test) DistributedStreamIteratorTest(org.infinispan.stream.DistributedStreamIteratorTest) Cache(org.infinispan.Cache) AbstractDelegatingHandler(org.infinispan.remoting.inboundhandler.AbstractDelegatingHandler) TimeUnit(java.util.concurrent.TimeUnit) ScatteredStateGetKeysCommand(org.infinispan.commands.statetransfer.ScatteredStateGetKeysCommand) CacheRpcCommand(org.infinispan.commands.remote.CacheRpcCommand) CacheMode(org.infinispan.configuration.cache.CacheMode) TestingUtil(org.infinispan.test.TestingUtil) DeliverOrder(org.infinispan.remoting.inboundhandler.DeliverOrder) ExecutorService(java.util.concurrent.ExecutorService) TestingUtil.extractGlobalComponent(org.infinispan.test.TestingUtil.extractGlobalComponent) Executor(java.util.concurrent.Executor) AbstractDelegatingHandler(org.infinispan.remoting.inboundhandler.AbstractDelegatingHandler) DeliverOrder(org.infinispan.remoting.inboundhandler.DeliverOrder) CacheRpcCommand(org.infinispan.commands.remote.CacheRpcCommand) Reply(org.infinispan.remoting.inboundhandler.Reply) ScatteredStateGetKeysCommand(org.infinispan.commands.statetransfer.ScatteredStateGetKeysCommand)

Aggregations

DeliverOrder (org.infinispan.remoting.inboundhandler.DeliverOrder)8 Reply (org.infinispan.remoting.inboundhandler.Reply)5 Cache (org.infinispan.Cache)3 CacheRpcCommand (org.infinispan.commands.remote.CacheRpcCommand)3 AbstractDelegatingHandler (org.infinispan.remoting.inboundhandler.AbstractDelegatingHandler)3 Address (org.infinispan.remoting.transport.Address)3 SiteAddress (org.jgroups.protocols.relay.SiteAddress)3 CompletableFuture (java.util.concurrent.CompletableFuture)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 TimeUnit (java.util.concurrent.TimeUnit)2 ReplicableCommand (org.infinispan.commands.ReplicableCommand)2 IllegalLifecycleStateException (org.infinispan.commons.IllegalLifecycleStateException)2 PerCacheInboundInvocationHandler (org.infinispan.remoting.inboundhandler.PerCacheInboundInvocationHandler)2 ValidResponse (org.infinispan.remoting.responses.ValidResponse)2 JGroupsAddressCache.fromJGroupsAddress (org.infinispan.remoting.transport.jgroups.JGroupsAddressCache.fromJGroupsAddress)2 TestingUtil (org.infinispan.test.TestingUtil)2 XSiteReplicateCommand (org.infinispan.xsite.XSiteReplicateCommand)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1