use of org.apache.cassandra.net.ConnectionType.SMALL_MESSAGES in project cassandra by apache.
the class StartupClusterConnectivityChecker method sendPingMessages.
/**
* Sends a "connection warmup" message to each peer in the collection, on every {@link ConnectionType}
* used for internode messaging (that is not gossip).
*/
private void sendPingMessages(Set<InetAddressAndPort> peers, Map<String, CountDownLatch> dcToRemainingPeers, AckMap acks, Function<InetAddressAndPort, String> getDatacenter) {
RequestCallback responseHandler = msg -> {
if (acks.incrementAndCheck(msg.from())) {
String datacenter = getDatacenter.apply(msg.from());
// We have to check because we might only have the local DC in the map
if (dcToRemainingPeers.containsKey(datacenter))
dcToRemainingPeers.get(datacenter).decrement();
}
};
Message<PingRequest> small = Message.out(PING_REQ, PingRequest.forSmall);
Message<PingRequest> large = Message.out(PING_REQ, PingRequest.forLarge);
for (InetAddressAndPort peer : peers) {
MessagingService.instance().sendWithCallback(small, peer, responseHandler, SMALL_MESSAGES);
MessagingService.instance().sendWithCallback(large, peer, responseHandler, LARGE_MESSAGES);
}
}
Aggregations