Class DnsQueryContext

java.lang.Object
io.netty.resolver.dns.DnsQueryContext
Direct Known Subclasses:
DatagramDnsQueryContext, TcpDnsQueryContext

abstract class DnsQueryContext extends Object
  • Field Details

    • logger

      private static final InternalLogger logger
    • ID_REUSE_ON_TIMEOUT_DELAY_MILLIS

      private static final long ID_REUSE_ON_TIMEOUT_DELAY_MILLIS
    • TCP_ENCODER

      private static final TcpDnsQueryEncoder TCP_ENCODER
    • channel

      private final Channel channel
    • nameServerAddr

      private final InetSocketAddress nameServerAddr
    • queryContextManager

      private final DnsQueryContextManager queryContextManager
    • promise

    • question

      private final DnsQuestion question
    • additionals

      private final DnsRecord[] additionals
    • optResource

      private final DnsRecord optResource
    • recursionDesired

      private final boolean recursionDesired
    • socketBootstrap

      private final Bootstrap socketBootstrap
    • retryWithTcpOnTimeout

      private final boolean retryWithTcpOnTimeout
    • queryTimeoutMillis

      private final long queryTimeoutMillis
    • timeoutFuture

      private volatile Future<?> timeoutFuture
    • id

      private int id
  • Constructor Details

  • Method Details

    • hasOptRecord

      private static boolean hasOptRecord(DnsRecord[] additionals)
    • isDone

      final boolean isDone()
      Returns true if the query was completed already.
      Returns:
      true if done.
    • question

      final DnsQuestion question()
      Returns the DnsQuestion that will be written as part of the DnsQuery.
      Returns:
      the question.
    • newQuery

      protected abstract DnsQuery newQuery(int id, InetSocketAddress nameServerAddr)
      Creates and returns a new DnsQuery.
      Parameters:
      id - the transaction id to use.
      nameServerAddr - the nameserver to which the query will be send.
      Returns:
      the new query.
    • protocol

      protected abstract String protocol()
      Returns the protocol that is used for the query.
      Returns:
      the protocol.
    • writeQuery

      final ChannelFuture writeQuery(boolean flush)
      Write the query and return the ChannelFuture that is completed once the write completes.
      Parameters:
      flush - true if Channel.flush() should be called as well.
      Returns:
      the ChannelFuture that is notified once once the write completes.
    • removeFromContextManager

      private void removeFromContextManager(InetSocketAddress nameServerAddr)
    • sendQuery

      private ChannelFuture sendQuery(DnsQuery query, boolean flush)
    • writeQuery

      private void writeQuery(DnsQuery query, boolean flush, ChannelPromise promise)
    • onQueryWriteCompletion

      private void onQueryWriteCompletion(long queryTimeoutMillis, ChannelFuture writeFuture)
    • finishSuccess

      void finishSuccess(AddressedEnvelope<? extends DnsResponse,InetSocketAddress> envelope, boolean truncated)
      Notifies the original Promise that the response for the query was received. This method takes ownership of passed AddressedEnvelope.
    • trySuccess

      private boolean trySuccess(AddressedEnvelope<? extends DnsResponse,InetSocketAddress> envelope)
    • finishFailure

      final boolean finishFailure(String message, Throwable cause, boolean timeout)
      Notifies the original Promise that the query completes because of an failure.
    • retryWithTcp

      private boolean retryWithTcp(Object originalResult)
      Retry the original query with TCP if possible.
      Parameters:
      originalResult - the result of the original DnsQueryContext.
      Returns:
      true if retry via TCP is supported and so the ownership of originalResult was transferred, false otherwise.
    • finishOriginal

      private void finishOriginal(Object originalResult, Future<?> future)