Search in sources :

Example 1 with SMALL_MESSAGES

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);
    }
}
Also used : PING_REQ(org.apache.cassandra.net.Verb.PING_REQ) EndpointState(org.apache.cassandra.gms.EndpointState) InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) StringUtils(org.apache.commons.lang.StringUtils) IEndpointStateChangeSubscriber(org.apache.cassandra.gms.IEndpointStateChangeSubscriber) LoggerFactory(org.slf4j.LoggerFactory) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) HashMap(java.util.HashMap) Global.nanoTime(org.apache.cassandra.utils.Clock.Global.nanoTime) CountDownLatch(org.apache.cassandra.utils.concurrent.CountDownLatch) Function(java.util.function.Function) Gossiper(org.apache.cassandra.gms.Gossiper) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) HashMultimap(com.google.common.collect.HashMultimap) CountDownLatch.newCountDownLatch(org.apache.cassandra.utils.concurrent.CountDownLatch.newCountDownLatch) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Collectors.mapping(java.util.stream.Collectors.mapping) Logger(org.slf4j.Logger) FBUtilities(org.apache.cassandra.utils.FBUtilities) LARGE_MESSAGES(org.apache.cassandra.net.ConnectionType.LARGE_MESSAGES) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) SMALL_MESSAGES(org.apache.cassandra.net.ConnectionType.SMALL_MESSAGES) SetMultimap(com.google.common.collect.SetMultimap) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 HashMultimap (com.google.common.collect.HashMultimap)1 SetMultimap (com.google.common.collect.SetMultimap)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Function (java.util.function.Function)1 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)1 Collectors.mapping (java.util.stream.Collectors.mapping)1 Collectors.toList (java.util.stream.Collectors.toList)1 EndpointState (org.apache.cassandra.gms.EndpointState)1 Gossiper (org.apache.cassandra.gms.Gossiper)1 IEndpointStateChangeSubscriber (org.apache.cassandra.gms.IEndpointStateChangeSubscriber)1