Source:
private CompletableFuture<?> executeRunnable(Runnable runnable, ResponseMode mode) { CompletableFuture<?> localFuture = startLocalInvocation(runnable); List<org.jgroups.Address> targets = getJGroupsTargets(); int size = targets.size(); CompletableFuture<?> remoteFuture; if (size == 1) { org.jgroups.Address target = targets.get(0); if (isTrace) { log.tracef("Submitting runnable to single remote node - JGroups Address %s", target); } CommandAwareRpcDispatcher card = transport.getCommandAwareRpcDispatcher(); remoteFuture = card.invokeRemoteCommand(target, new ReplicableCommandRunnable( new RunnableAdapter<>(runnable, null)), mode, unit.toMillis(time), DeliverOrder.NONE).handle((r, t) -> { if (t != null) { rethrowException(t); } if (r.wasReceived()) { if (r.hasException()) { rethrowException(r.getException()); } } else if (r.wasSuspected()) { throw new SuspectException("Node " + JGroupsAddressCache.fromJGroupsAddress(target) + " was suspected"); } else { throw new TimeoutException("Node " + JGroupsAddressCache.fromJGroupsAddress(target) + " timed out, time : " + time + " " + unit); } return null; }); } else if (size > 1) { CommandAwareRpcDispatcher card = transport.getCommandAwareRpcDispatcher(); remoteFuture = card.invokeRemoteCommands(targets, new ReplicableCommandRunnable( new RunnableAdapter<>(runnable, null)), mode, unit.toMillis(time), null, DeliverOrder.NONE); } else if (localFuture != null) { return localFuture; } else { return CompletableFutures.completedExceptionFuture(new SuspectException("No available nodes!")); } if (localFuture != null && mode != ResponseMode.GET_NONE) { return CompletableFuture.allOf(localFuture, remoteFuture); } return remoteFuture; }

Target:
private CompletableFuture<?> executeRunnable(Runnable runnable, ResponseMode mode) { CompletableFuture<?> localFuture = startLocalInvocation(runnable); List<org.jgroups.Address> targets = getJGroupsTargets(); int size = targets.size(); CompletableFuture<?> remoteFuture; if (size == 1) { org.jgroups.Address target = targets.get(0); if (isTrace) { log.tracef("Submitting runnable to single remote node - JGroups Address %s", target); } CommandAwareRpcDispatcher card = transport.getCommandAwareRpcDispatcher(); remoteFuture = card.invokeRemoteCommand(target, new ReplicableCommandRunnable(runnable), mode, unit.toMillis(time), DeliverOrder.NONE).handle((r, t) -> { if (t != null) { rethrowException(t); } if (r.wasReceived()) { if (r.hasException()) { rethrowException(r.getException()); } } else if (r.wasSuspected()) { throw log.remoteNodeSuspected(JGroupsAddressCache.fromJGroupsAddress(target)); } else { throw log.remoteNodeTimedOut(JGroupsAddressCache.fromJGroupsAddress(target), time, unit); } return null; }); } else if (size > 1) { CommandAwareRpcDispatcher card = transport.getCommandAwareRpcDispatcher(); remoteFuture = card.invokeRemoteCommands(targets, new ReplicableCommandRunnable(runnable), mode, unit.toMillis(time), null, DeliverOrder.NONE); } else if (localFuture != null) { return localFuture; } else { return CompletableFutures.completedExceptionFuture(new SuspectException("No available nodes!")); } if (localFuture != null && mode != ResponseMode.GET_NONE) { return CompletableFuture.allOf(localFuture, remoteFuture); } return remoteFuture; }