public class ReachableSocketFinder
extends java.lang.Object
Constructor and Description |
---|
ReachableSocketFinder() |
ReachableSocketFinder(com.google.common.base.Predicate<? super com.google.common.net.HostAndPort> socketTester) |
ReachableSocketFinder(com.google.common.base.Predicate<? super com.google.common.net.HostAndPort> socketTester,
Duration gracePeriod) |
Modifier and Type | Method and Description |
---|---|
com.google.common.net.HostAndPort |
findOpenSocketOnNode(java.lang.Iterable<? extends com.google.common.net.HostAndPort> sockets,
Duration timeout)
Returns the first element of sockets that is reachable.
|
java.lang.Iterable<com.google.common.net.HostAndPort> |
findOpenSocketsOnNode(java.lang.Iterable<? extends com.google.common.net.HostAndPort> sockets,
Duration timeout)
Returns an iterable of the elements in sockets that are reachable.
|
public ReachableSocketFinder()
public ReachableSocketFinder(com.google.common.base.Predicate<? super com.google.common.net.HostAndPort> socketTester)
public ReachableSocketFinder(com.google.common.base.Predicate<? super com.google.common.net.HostAndPort> socketTester, Duration gracePeriod)
socketTester
- A predicate that determines the reachability of a host and portgracePeriod
- The duration to allow remaining checks to continue after a socket is reached for the first time.public com.google.common.net.HostAndPort findOpenSocketOnNode(java.lang.Iterable<? extends com.google.common.net.HostAndPort> sockets, Duration timeout)
sockets
- The host-and-ports to testtimeout
- Max time to try to connect to the ip:portjava.util.NoSuchElementException
- If no ports are accessible within the given timejava.lang.NullPointerException
- If sockets or timeout is nulljava.lang.IllegalStateException
- If the sockets to test is emptypublic java.lang.Iterable<com.google.common.net.HostAndPort> findOpenSocketsOnNode(java.lang.Iterable<? extends com.google.common.net.HostAndPort> sockets, Duration timeout)
sockets
- The host-and-ports to testtimeout
- Max time to try to connect to each ip:portsocketTester
.java.lang.NullPointerException
- If sockets or timeout is nulljava.lang.IllegalStateException
- If the sockets to test is empty