zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hanm <...@git.apache.org>
Subject [GitHub] zookeeper pull request #451: ZOOKEEPER-2184: Zookeeper Client should re-reso...
Date Sat, 26 May 2018 00:56:05 GMT
Github user hanm commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/451#discussion_r191034929
  
    --- Diff: src/java/main/org/apache/zookeeper/client/HostProvider.java ---
    @@ -53,7 +54,7 @@
          * @param spinDelay
          *            Milliseconds to wait if all hosts have been tried once.
          */
    -    public InetSocketAddress next(long spinDelay);
    +    public InetSocketAddress next(long spinDelay) throws UnknownHostException;
    --- End diff --
    
    >> In a nutshell the problem of unresolvable DNS name must be handled somewhere
and here're the considerations
    
    I agree with this, however this can be done without throwing the UnknownHostException
here. We can just return the curAddr in case of resolving failure, and since curAddr is not
resolved, trying to connect to it on caller side will not succeed and caller can continue
retry etc with existing logic. The primary concern here is change of a public API which might
require clients (e.g. HBase) to recompile with ZK, so I prefer the approach that can achieve
same goal (let caller handle retry logic) w/o changing the signature of a public API (alternatively
we can throw an unchecked exception but semantically that sounds no better than UnknownHostException).
    
    So I am thinking the semantic of next() is:
    
    * If we can resolve an address, resolve it and return.
    * If we can't resolve an address, return an unresolved address which contain enough information
(host, port etc) for caller to decide what to do.


---

Mime
View raw message