begin = Clock.currentTimeMillis();
final Map<ClientConnection, Future> futureMap = new HashMap<ClientConnection, Future>();
for (ClientConnection connection : connections.values()) {
if (begin - connection.lastReadTime() > heartBeatTimeout) {
final ClientPingRequest request = new ClientPingRequest();
final ICompletableFuture future = invocationService.send(request, connection);
futureMap.put(connection, future);
} else {
connection.heartBeatingSucceed();
}
}
for (Map.Entry<ClientConnection, Future> entry : futureMap.entrySet()) {
final Future future = entry.getValue();
final ClientConnection connection = entry.getKey();
try {
future.get(getRemainingTimeout(), TimeUnit.MILLISECONDS);
connection.heartBeatingSucceed();
} catch (Exception ignored) {
connection.heartBeatingFailed();
}
}