The implementation is free to decide whether to return a single address, or multiple addresses if they are + * available.
+ * + * @return The next available {@link InetAddress}(es) in the pool, or an empty array if none are available. + */ + InetAddress[] next(); +} diff --git a/src/main/java/org/greencheek/caching/herdcache/memcached/factory/BackgroundDnsResolver.java b/src/main/java/org/greencheek/caching/herdcache/memcached/factory/BackgroundDnsResolver.java new file mode 100644 index 0000000..9595fc8 --- /dev/null +++ b/src/main/java/org/greencheek/caching/herdcache/memcached/factory/BackgroundDnsResolver.java @@ -0,0 +1,164 @@ +package org.greencheek.caching.herdcache.memcached.factory; + +import org.greencheek.caching.herdcache.memcached.config.Host; +import org.greencheek.caching.herdcache.memcached.dns.AddressResolver; +import org.greencheek.caching.herdcache.memcached.dns.DefaultAddressResolver; +import org.greencheek.caching.herdcache.memcached.dns.resolver.InetAddressComparator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.Inet4Address; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; + +/** + * Created by dominictootell on 17/05/2018. + */ +public class BackgroundDnsResolver implements ReferencedClientHolder { + private static final Logger LOG = LoggerFactory.getLogger(BackgroundDnsResolver.class); + private static Holder EMPTY = new Holder(SpyReferencedClient.UNAVAILABLE_REFERENCE_CLIENT,new InetAddress[0]); + + private final AtomicReference