Package org.xbill.DNS

Class ExtendedResolver

java.lang.Object
org.xbill.DNS.ExtendedResolver
All Implemented Interfaces:
Resolver

public class ExtendedResolver extends Object implements Resolver
An implementation of Resolver that can send queries to multiple servers, sending the queries multiple times if necessary.
Author:
Brian Wellington
See Also:
  • Field Details

    • DEFAULT_TIMEOUT

      public static final Duration DEFAULT_TIMEOUT
      Default timeout until resolving is aborted.
      Since:
      3.2
    • DEFAULT_RESOLVER_TIMEOUT

      public static final Duration DEFAULT_RESOLVER_TIMEOUT
      Default timeout until resolving with one of the used resolvers fails.
      Since:
      3.2
  • Constructor Details

  • Method Details

    • setPort

      public void setPort(int port)
      Description copied from interface: Resolver
      Sets the port to communicate with on the server
      Specified by:
      setPort in interface Resolver
      Parameters:
      port - The port to send messages to
    • setTCP

      public void setTCP(boolean flag)
      Description copied from interface: Resolver
      Sets whether TCP connections will be used by default
      Specified by:
      setTCP in interface Resolver
      Parameters:
      flag - Indicates whether TCP connections are made
    • setIgnoreTruncation

      public void setIgnoreTruncation(boolean flag)
      Description copied from interface: Resolver
      Sets whether truncated responses will be ignored. If not, a truncated response over UDP will cause a retransmission over TCP.
      Specified by:
      setIgnoreTruncation in interface Resolver
      Parameters:
      flag - Indicates whether truncated responses should be ignored.
    • setEDNS

      public void setEDNS(int version, int payloadSize, int flags, List<EDNSOption> options)
      Description copied from interface: Resolver
      Sets the EDNS information on outgoing messages.
      Specified by:
      setEDNS in interface Resolver
      Parameters:
      version - 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.
      See Also:
    • setTSIGKey

      public void setTSIGKey(TSIG key)
      Description copied from interface: Resolver
      Specifies the TSIG key that messages will be signed with
      Specified by:
      setTSIGKey in interface Resolver
      Parameters:
      key - The key
    • getTimeout

      public Duration getTimeout()
      Description copied from interface: Resolver
      Gets the amount of time to wait for a response before giving up.
      Specified by:
      getTimeout in interface Resolver
      See Also:
    • setTimeout

      public void setTimeout(Duration timeout)
      Sets the timeout for the 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.

      Specified by:
      setTimeout in interface Resolver
      Parameters:
      timeout - The amount of time to wait before sending further queries.
      See Also:
    • sendAsync

      public 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.
      Specified by:
      sendAsync in interface Resolver
      Parameters:
      query - The query to send.
      Returns:
      A future that completes when the query is finished.
    • sendAsync

      public CompletionStage<Message> sendAsync(Message query, 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.
      Specified by:
      sendAsync in interface Resolver
      Parameters:
      query - The query to send.
      executor - The service to use for async operations.
      Returns:
      A future that completes when the query is finished.
    • getResolver

      public Resolver getResolver(int n)
      Returns the nth resolver used by this ExtendedResolver
    • getResolvers

      public Resolver[] getResolvers()
      Returns all resolvers used by this ExtendedResolver
    • addResolver

      public void addResolver(Resolver r)
      Adds a new resolver to be used by this ExtendedResolver
    • deleteResolver

      public void deleteResolver(Resolver r)
      Deletes a resolver used by this ExtendedResolver
    • getLoadBalance

      public boolean getLoadBalance()
      Gets whether the servers receive queries load balanced.
      Since:
      3.2
    • setLoadBalance

      public void setLoadBalance(boolean flag)
      Sets whether the servers should be load balanced.
      Parameters:
      flag - If true, servers will be tried in round-robin order. If false, servers will always be queried in the same order.
    • getRetries

      public int getRetries()
      Gets the number of retries sent to each server per query.
      Since:
      3.2
    • setRetries

      public void setRetries(int retries)
      Sets the number of retries sent to each server per query
    • toString

      public String toString()
      Overrides:
      toString in class Object