private void probe ( ) { // First get a sorted list of discovery service nodes that are not present in the SWIM members. // This is necessary to ensure we attempt to probe all nodes that are provided by the discovery provider. List < SwimMember > probeMembers = Lists . newArrayList ( discoveryService . getNodes ( ) . stream ( ) . map ( node -> new SwimMember ( MemberId . from ( node . id ( ) . id ( ) ) , node . address ( ) ) ) . filter ( member -> ! members . containsKey ( member . id ( ) ) ) . filter ( member -> ! member . id ( ) . equals ( localMember . id ( ) ) ) . sorted ( Comparator . comparing ( Member :: id ) ) . collect ( Collectors . toList ( ) ) ) ; // Then add the randomly sorted list of SWIM members. probeMembers . addAll ( randomMembers ) ; // If there are members to probe, select the next member to probe using a counter for round robin probes. if ( ! probeMembers . isEmpty ( ) ) { SwimMember probeMember = probeMembers . get ( Math . abs ( probeCounter . incrementAndGet ( ) % probeMembers . size ( ) ) ) ; probe ( probeMember . copy ( ) ) ; } }
Sends probes to all members or to the next member in round robin fashion .