@Nullable public TcpDiscoveryNode nextNode(@Nullable Collection<TcpDiscoveryNode> excluded){
  assert locNode.internalOrder() > 0 : locNode;
  assert excluded == null || excluded.isEmpty() || !excluded.contains(locNode) : excluded;
  rwLock.readLock().lock();
  try {
    Collection<TcpDiscoveryNode> filtered=serverNodes(excluded);
    if (filtered.size() < 2)     return null;
    Iterator<TcpDiscoveryNode> iter=filtered.iterator();
    while (iter.hasNext()) {
      TcpDiscoveryNode node=iter.next();
      if (locNode.equals(node))       break;
    }
    return iter.hasNext() ? iter.next() : F.first(filtered);
  }
  finally {
    rwLock.readLock().unlock();
  }
}

@ Nullable public TcpDiscoveryNode nextNode ( @ Nullable Collection < TcpDiscoveryNode > excluded ) { assert locNode . internalOrder ( ) > 0 : locNode ; assert excluded == null || excluded . isEmpty ( ) || ! excluded . contains ( locNode ) : excluded ; rwLock . readLock ( ) . lock ( ) ; try { Collection < TcpDiscoveryNode > filtered = serverNodes ( excluded ) ; if ( filtered . size ( ) < 2 ) return null ; Iterator < TcpDiscoveryNode > iter = filtered . iterator ( ) ; while ( iter . hasNext ( ) ) { TcpDiscoveryNode node = iter . next ( ) ; if ( locNode . equals ( node ) ) break ; } return iter . hasNext ( ) ? iter . next ( ) : F . first ( filtered ) ; } finally { rwLock . readLock ( ) . unlock ( ) ; } }
finds next node in the topology filtering excluded nodes from search . < p > this may be used when detecting and handling nodes failure .
