use of org.infinispan.remoting.transport.jgroups.JGroupsAddressCache.fromJGroupsAddress 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;
}
use of org.infinispan.remoting.transport.jgroups.JGroupsAddressCache.fromJGroupsAddress 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);
}
Aggregations