if (isReceiver) {
// optimise ...
providers.remove(self);
try {
RehashControlCommand cmd = cf.buildRehashControlCommand(PULL_STATE_LEAVE, self,
null, oldCH, newCH, leaversHandled);
log.debugf("I %s am pulling state from %s", self, providers);
Set<Future<Void>> stateRetrievalProcesses = new HashSet<Future<Void>>(providers.size());
for (Address stateProvider : providers) {
stateRetrievalProcesses.add(
statePullExecutor.submit(new LeaveStateGrabber(stateProvider, cmd, newCH))
);
}
// Wait for all this state to be applied, in parallel.
log.trace("State retrieval being processed.");
for (Future<Void> f : stateRetrievalProcesses) f.get();
log.tracef("State retrieval from %s completed.", providers);
} finally {
// Inform state senders that state has been applied successfully so they can proceed.
// Needs to be SYNC - we need to make sure these messages don't get 'lost' or you end up with a
// blocked up cluster
log.tracef("Informing %s that state has been applied.", providers);
RehashControlCommand c = cf.buildRehashControlCommand(LEAVE_REHASH_END, self);
rpcManager.invokeRemotely(providers, c, SYNCHRONOUS, configuration.getRehashRpcTimeout(), true);
}
}
if (isSender) {
Set<Address> recCopy = new HashSet<Address>(receivers);