Class CachedDnsResolver

java.lang.Object
com.linkedin.venice.httpclient.CachedDnsResolver
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.http.conn.DnsResolver

public class CachedDnsResolver extends Object implements org.apache.http.conn.DnsResolver, Closeable
CachedDnsResolver caches the dns entries for hosts, which matches the specified host pattern. In the meantime, there is a asynchronous task running to refresh the cached entries periodically. The reason to have this customized DnsResolver: 1. If the DNS lookup is slow, AbstractNIOConnPool.lease(Object, Object) will be blocked by the slow DNS lookup, which will cause a lot of requests being blocked since the slow DNS lookup will grab the per-connection-pool lock until it is done; 2. Here we choose to use a asynchronous task to refresh the cached entries is that the synchronous refresh with TTL will still cause latency spike because of #1;