Search in sources :

Example 1 with SiteUnreachableXSiteResponse

use of org.infinispan.remoting.transport.impl.SiteUnreachableXSiteResponse in project infinispan by infinispan.

the class JGroupsTransport method backupRemotely.

@Override
public <O> XSiteResponse<O> backupRemotely(XSiteBackup backup, XSiteReplicateCommand<O> rpcCommand) {
    assert !localSite.equals(backup.getSiteName()) : "sending to local site";
    if (unreachableSites.containsKey(backup.getSiteName())) {
        // fail fast if we have thread handling a SITE_UNREACHABLE event.
        return new SiteUnreachableXSiteResponse<>(backup, timeService);
    }
    Address recipient = JGroupsAddressCache.fromJGroupsAddress(new SiteMaster(backup.getSiteName()));
    long requestId = requests.newRequestId();
    logRequest(requestId, rpcCommand, recipient, "backup");
    SingleSiteRequest<ValidResponse> request = new SingleSiteRequest<>(SingleResponseCollector.validOnly(), requestId, requests, backup.getSiteName());
    addRequest(request);
    DeliverOrder order = backup.isSync() ? DeliverOrder.NONE : DeliverOrder.PER_SENDER;
    long timeout = backup.getTimeout();
    XSiteResponseImpl<O> xSiteResponse = new XSiteResponseImpl<>(timeService, backup);
    try {
        sendCommand(recipient, rpcCommand, request.getRequestId(), order, false, false);
        if (timeout > 0) {
            request.setTimeout(timeoutExecutor, timeout, TimeUnit.MILLISECONDS);
        }
        request.whenComplete(xSiteResponse);
    } catch (Throwable t) {
        request.cancel(true);
        xSiteResponse.completeExceptionally(t);
    }
    return xSiteResponse;
}
Also used : 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) ValidResponse(org.infinispan.remoting.responses.ValidResponse) DeliverOrder(org.infinispan.remoting.inboundhandler.DeliverOrder) SiteMaster(org.jgroups.protocols.relay.SiteMaster) SiteUnreachableXSiteResponse(org.infinispan.remoting.transport.impl.SiteUnreachableXSiteResponse) XSiteResponseImpl(org.infinispan.remoting.transport.impl.XSiteResponseImpl)

Aggregations

DeliverOrder (org.infinispan.remoting.inboundhandler.DeliverOrder)1 ValidResponse (org.infinispan.remoting.responses.ValidResponse)1 Address (org.infinispan.remoting.transport.Address)1 SiteUnreachableXSiteResponse (org.infinispan.remoting.transport.impl.SiteUnreachableXSiteResponse)1 XSiteResponseImpl (org.infinispan.remoting.transport.impl.XSiteResponseImpl)1 JGroupsAddressCache.fromJGroupsAddress (org.infinispan.remoting.transport.jgroups.JGroupsAddressCache.fromJGroupsAddress)1 PhysicalAddress (org.jgroups.PhysicalAddress)1 SiteAddress (org.jgroups.protocols.relay.SiteAddress)1 SiteMaster (org.jgroups.protocols.relay.SiteMaster)1