throw e;
}
}
private void pushState(ConsistentHash chOld, ConsistentHash chNew, Map<Address, Map<Object, InternalCacheValue>> states) throws InterruptedException, ExecutionException {
NotifyingNotifiableFuture<Object> stateTransferFuture = new AggregatingNotifyingFutureImpl(null, states.size());
for (Map.Entry<Address, Map<Object, InternalCacheValue>> entry : states.entrySet()) {
final Address target = entry.getKey();
Map<Object, InternalCacheValue> state = entry.getValue();
log.debugf("%s pushing to %s %d keys", self, target, state.size());
if (trace) log.tracef("Pushed keys %s", self, target, state.keySet());
final RehashControlCommand cmd = cf.buildRehashControlCommand(RehashControlCommand.Type.APPLY_STATE, self,
newViewId, state, chOld, chNew);
rpcManager.invokeRemotelyInFuture(Collections.singleton(target), cmd,
false, stateTransferFuture, configuration.getRehashRpcTimeout());
}
// wait to see if all servers received the new state
// TODO we might want to retry the state transfer operation if it failed on some of the nodes and the view hasn't changed
try {
stateTransferFuture.get();
} catch (ExecutionException e) {
log.errorTransferringState(e);
throw e;
}
log.debugf("Node finished pushing data for rehash %d.", newViewId);