Hi all,

We need more eyes and brains on the following PR:

https://github.com/apache/zookeeper/pull/451

I added a comment few days ago about the way we currently do DNS name
resolution in this class and a suggestion on how we could simplify things a
little bit. We talked about it with Abe Fine, but we're a little bit unsure
and cannot get a conclusion. It would be extremely handy to get more
feedback from you.

To add some colour to it, let me elaborate on the situation here:

In general, the task that StaticHostProvider does is to get a list of
potentially unresolved InetSocketAddress objects, resolve them and iterate
over the resolved objects by calling next() method.

*Option #1 (current logic)*
- Resolve addresses with getAllByName() which returns a list of IP
addresses associated with the address.
- Cache all these IP's, shuffle them and iterate over.
- If client is unable to connect to an IP, remove all IPs from the list
which the original servername was resolved to and re-resolve it.

*Option #2 (getByName())*
- Resolve address with getByName() instead which returns only the first IP
address of the name,
- Do not cache IPs,
- Shuffle the *names* and resolve with getByName() *every time* when next()
is called,
- JDK's built-in caching will prevent name servers from being flooded and
will do the re-resolution automatically when cache expires,
- Names with multiple IPs will be handled by DNS servers which (if
configured properly) return IPs in different order - this is called DNS
Round Robin -, so getByName() will return different IP on each call.

*Options #3*
- There's a small problem with option#2: if DNS server is not configured
properly and handles the round-robin case in a way that it always return
the IP list in the same order, getByName() will never return the next ip,
- In order to overcome that, use getAllByName() instead, shuffle the list
and return the first IP.

All feedback if much appreciated.

Thanks,
Andor

Reply via email to