Class MultipleAddresses


  • public final class MultipleAddresses
    extends Object
    This class allows to store several quorum and electing addresses. See ZOOKEEPER-3188 for a discussion of this feature.
    • Field Detail

      • DEFAULT_TIMEOUT

        public static final Duration DEFAULT_TIMEOUT
    • Method Detail

      • isEmpty

        public boolean isEmpty()
      • getAllAddresses

        public Set<InetSocketAddress> getAllAddresses()
        Returns all addresses in an unmodifiable set.
        Returns:
        set of all InetSocketAddress
      • getWildcardAddresses

        public Set<InetSocketAddress> getWildcardAddresses()
        Returns wildcard addresses for all ports
        Returns:
        set of InetSocketAddress with wildcards for all ports
      • getAllPorts

        public List<Integer> getAllPorts()
        Returns all ports
        Returns:
        list of all ports
      • getAllHostStrings

        public List<String> getAllHostStrings()
        Returns distinct list of all host strings
        Returns:
        list of all hosts
      • getReachableAddress

        public InetSocketAddress getReachableAddress()
                                              throws NoRouteToHostException
        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

        public Set<InetSocketAddress> getAllReachableAddresses()
        Returns a set of all reachable addresses. If none is reachable than returns empty set.
        Returns:
        all addresses which are reachable.
      • getAllReachableAddressesOrAll

        public Set<InetSocketAddress> 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

        public InetSocketAddress 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.
      • size

        public int size()
        Returns the number of addresses in the set.
        Returns:
        the number of addresses.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object