zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anmolnar <...@git.apache.org>
Subject [GitHub] zookeeper pull request #448: client: do not try to connect to an unreachable...
Date Sun, 04 Feb 2018 13:45:04 GMT
Github user anmolnar commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/448#discussion_r165844811
  
    --- Diff: src/java/main/org/apache/zookeeper/client/StaticHostProvider.java ---
    @@ -107,16 +112,43 @@ public StaticHostProvider(Collection<InetSocketAddress> serverAddresses,
             lastIndex = -1;              
         }
     
    +    private Set<Class<? extends InetAddress>> supportedAddressTypes() {
    +        Set<Class<? extends InetAddress>> types = new HashSet<>();
    +        try {
    +            Enumeration<NetworkInterface> inets = NetworkInterface.getNetworkInterfaces();
    +            while (inets.hasMoreElements()) {
    +                NetworkInterface ne = inets.nextElement();
    +
    +                Enumeration<InetAddress> addrs = ne.getInetAddresses();
    +                while (addrs.hasMoreElements()) {
    +                    InetAddress addr = addrs.nextElement();
    +                    if (addr.isLinkLocalAddress() || addr.isLoopbackAddress()) {
    +                        continue;
    +                    }
    +                    types.add(addr.getClass());
    +                }
    +            }
    +        } catch (SocketException e) {
    +            LOG.error("Failed to resolve supported address types: ", e);
    +        }
    +        return types;
    +    }
    +
         private List<InetSocketAddress> resolveAndShuffle(Collection<InetSocketAddress>
serverAddresses) {
    -        List<InetSocketAddress> tmpList = new ArrayList<InetSocketAddress>(serverAddresses.size());
      
    +        List<InetSocketAddress> tmpList = new ArrayList<InetSocketAddress>(serverAddresses.size());
    +        Set<Class<? extends InetAddress>> supprtedInetTypes = supportedAddressTypes();
    --- End diff --
    
    typo in the variable name


---

Mime
View raw message