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;
}
Aggregations