| Modifier and Type | Class and Description |
|---|---|
private static class |
ExtendedResolver.Resolution |
private static class |
ExtendedResolver.ResolverEntry |
| Modifier and Type | Field and Description |
|---|---|
static java.time.Duration |
DEFAULT_RESOLVER_TIMEOUT
Default timeout until resolving with one of the used resolvers fails.
|
static java.time.Duration |
DEFAULT_TIMEOUT
Default timeout until resolving is aborted.
|
private java.util.concurrent.atomic.AtomicInteger |
lbStart |
private boolean |
loadBalance |
private java.util.List<ExtendedResolver.ResolverEntry> |
resolvers |
private int |
retries |
private java.time.Duration |
timeout |
| Constructor and Description |
|---|
ExtendedResolver()
Creates a new Extended Resolver.
|
ExtendedResolver(java.lang.Iterable<Resolver> resolvers)
Creates a new
ExtendedResolver. |
ExtendedResolver(Resolver[] resolvers)
Creates a new Extended Resolver
|
ExtendedResolver(java.lang.String[] servers)
Creates a new instance with
SimpleResolvers. |
| Modifier and Type | Method and Description |
|---|---|
void |
addResolver(Resolver r)
Adds a new resolver to be used by this ExtendedResolver
|
void |
deleteResolver(Resolver r)
Deletes a resolver used by this ExtendedResolver
|
boolean |
getLoadBalance()
Gets whether the servers receive queries load balanced.
|
Resolver |
getResolver(int n)
Returns the nth resolver used by this ExtendedResolver
|
Resolver[] |
getResolvers()
Returns all resolvers used by this ExtendedResolver
|
int |
getRetries()
Gets the number of retries sent to each server per query.
|
java.time.Duration |
getTimeout()
Gets the amount of time to wait for a response before giving up.
|
java.util.concurrent.CompletionStage<Message> |
sendAsync(Message query)
Sends a message to multiple servers, and queries are sent multiple times until either a
successful response is received, or it is clear that there is no successful response.
|
java.util.concurrent.CompletionStage<Message> |
sendAsync(Message query,
java.util.concurrent.Executor executor)
Sends a message to multiple servers, and queries are sent multiple times until either a
successful response is received, or it is clear that there is no successful response.
|
void |
setEDNS(int version,
int payloadSize,
int flags,
java.util.List<EDNSOption> options)
Sets the EDNS information on outgoing messages.
|
void |
setIgnoreTruncation(boolean flag)
Sets whether truncated responses will be ignored.
|
void |
setLoadBalance(boolean flag)
Sets whether the servers should be load balanced.
|
void |
setPort(int port)
Sets the port to communicate with on the server
|
void |
setRetries(int retries)
Sets the number of retries sent to each server per query
|
void |
setTCP(boolean flag)
Sets whether TCP connections will be used by default
|
void |
setTimeout(java.time.Duration timeout)
Sets the timeout for the
ExtendedResolver. |
void |
setTSIGKey(TSIG key)
Specifies the TSIG key that messages will be signed with
|
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitsend, sendAsync, setEDNS, setEDNS, setTimeout, setTimeoutpublic static final java.time.Duration DEFAULT_TIMEOUT
public static final java.time.Duration DEFAULT_RESOLVER_TIMEOUT
private final java.util.List<ExtendedResolver.ResolverEntry> resolvers
private final java.util.concurrent.atomic.AtomicInteger lbStart
private boolean loadBalance
private int retries
private java.time.Duration timeout
public ExtendedResolver()
ResolverConfig is used to determine the
servers for which SimpleResolvers are initialized. The timeout for each server is
initialized with DEFAULT_RESOLVER_TIMEOUT.public ExtendedResolver(java.lang.String[] servers)
throws java.net.UnknownHostException
SimpleResolvers. The timeout for each server is initialized
with DEFAULT_RESOLVER_TIMEOUT.servers - An array of server names or IP addresses for which SimpleResolvers are
initialized.java.net.UnknownHostException - A server name could not be resolvedpublic ExtendedResolver(Resolver[] resolvers)
resolvers - An array of pre-initialized Resolvers.public ExtendedResolver(java.lang.Iterable<Resolver> resolvers)
ExtendedResolver. No timeout value is applied to the individual
resolvers, make sure their timeout is smaller than the timeout of this ExtendedResolver.resolvers - An iterable of pre-initialized Resolvers.public void setPort(int port)
Resolverpublic void setTCP(boolean flag)
Resolverpublic void setIgnoreTruncation(boolean flag)
ResolversetIgnoreTruncation in interface Resolverflag - Indicates whether truncated responses should be ignored.public void setEDNS(int version,
int payloadSize,
int flags,
java.util.List<EDNSOption> options)
ResolversetEDNS in interface Resolverversion - The EDNS version to use. 0 indicates EDNS0 and -1 indicates no EDNS.payloadSize - The maximum DNS packet size that this host is capable of receiving over UDP.
If 0 is specified, the default (1280) is used.flags - EDNS extended flags to be set in the OPT record.options - EDNS options to be set in the OPT record, specified as a List of
OPTRecord.Option elements.OPTRecordpublic void setTSIGKey(TSIG key)
ResolversetTSIGKey in interface Resolverkey - The keypublic java.time.Duration getTimeout()
ResolvergetTimeout in interface ResolverResolver.setTimeout(Duration)public void setTimeout(java.time.Duration timeout)
ExtendedResolver.
Note that this only sets the timeout for the ExtendedResolver, not the
individual Resolvers. If the timeout expires, the ExtendedResolver simply stops
retrying, it does not abort running queries. The timeout value must be larger than that for the
individual resolver to have any effect.
setTimeout in interface Resolvertimeout - The amount of time to wait before sending further queries.ExtendedResolver(),
ExtendedResolver(String[])public java.util.concurrent.CompletionStage<Message> sendAsync(Message query)
public java.util.concurrent.CompletionStage<Message> sendAsync(Message query, java.util.concurrent.Executor executor)
public Resolver getResolver(int n)
public Resolver[] getResolvers()
public void addResolver(Resolver r)
public void deleteResolver(Resolver r)
public boolean getLoadBalance()
public void setLoadBalance(boolean flag)
flag - If true, servers will be tried in round-robin order. If false, servers will always
be queried in the same order.public int getRetries()
public void setRetries(int retries)
public java.lang.String toString()
toString in class java.lang.Object