Class MultipleAddresses
java.lang.Object
org.apache.zookeeper.server.quorum.MultipleAddresses
This class allows to store several quorum and electing addresses.
See ZOOKEEPER-3188 for a discussion of this feature.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMultipleAddresses
(InetSocketAddress address) MultipleAddresses
(Collection<InetSocketAddress> addresses) MultipleAddresses
(Collection<InetSocketAddress> addresses, Duration timeout) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAddress
(InetSocketAddress address) boolean
Returns all addresses in an unmodifiable set.Returns distinct list of all host stringsReturns all portsReturns a set of all reachable addresses.Returns a set of all reachable addresses.getOne()
Returns an address from the set.Returns a reachable address.Returns a reachable address or an arbitrary one, if none is reachable.Returns wildcard addresses for all portsint
hashCode()
boolean
isEmpty()
void
Performs a parallel DNS lookup for all addresses.int
size()
Returns the number of addresses in the set.toString()
-
Field Details
-
DEFAULT_TIMEOUT
-
-
Constructor Details
-
MultipleAddresses
public MultipleAddresses() -
MultipleAddresses
-
MultipleAddresses
-
MultipleAddresses
-
-
Method Details
-
isEmpty
public boolean isEmpty() -
getAllAddresses
Returns all addresses in an unmodifiable set.- Returns:
- set of all InetSocketAddress
-
getWildcardAddresses
Returns wildcard addresses for all ports- Returns:
- set of InetSocketAddress with wildcards for all ports
-
getAllPorts
Returns all ports- Returns:
- list of all ports
-
getAllHostStrings
Returns distinct list of all host strings- Returns:
- list of all hosts
-
addAddress
-
getReachableAddress
Returns a reachable address. If none is reachable than throws exception. The function is nondeterministic in the sense that the result of calling this function twice with the same set of reachable addresses might lead to different results.- Returns:
- address which is reachable.
- Throws:
NoRouteToHostException
- if none of the addresses are reachable
-
getAllReachableAddresses
Returns a set of all reachable addresses. If none is reachable than returns empty set.- Returns:
- all addresses which are reachable.
-
getAllReachableAddressesOrAll
Returns a set of all reachable addresses. If none is reachable than returns all addresses.- Returns:
- all reachable addresses, or all addresses if none is reachable.
-
getReachableOrOne
Returns a reachable address or an arbitrary one, if none is reachable. It throws an exception if there are no addresses registered. The function is nondeterministic in the sense that the result of calling this function twice with the same set of reachable addresses might lead to different results.- Returns:
- address which is reachable or fist one.
- Throws:
NoSuchElementException
- if there is no address registered
-
recreateSocketAddresses
public void recreateSocketAddresses()Performs a parallel DNS lookup for all addresses. If the DNS lookup fails, then address remain unmodified. -
getOne
Returns an address from the set.- Returns:
- address from a set.
- Throws:
NoSuchElementException
- if there is no address registered
-
size
public int size()Returns the number of addresses in the set.- Returns:
- the number of addresses.
-
equals
-
hashCode
public int hashCode() -
toString
-