Class DnsQueryContext

    • Field Detail

      • ID_REUSE_ON_TIMEOUT_DELAY_MILLIS

        private static final long ID_REUSE_ON_TIMEOUT_DELAY_MILLIS
      • channelReadyFuture

        private final Future<? extends Channel> channelReadyFuture
      • channel

        private final Channel channel
      • nameServerAddr

        private final java.net.InetSocketAddress nameServerAddr
      • 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
    • Method Detail

      • hasOptRecord

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

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

        protected abstract DnsQuery newQuery​(int id,
                                             java.net.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 java.lang.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​(java.net.InetSocketAddress nameServerAddr)
      • failQuery

        private void failQuery​(DnsQuery query,
                               java.lang.Throwable cause,
                               ChannelPromise writePromise)
      • onQueryWriteCompletion

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

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

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

        private boolean retryWithTcp​(java.lang.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​(java.lang.Object originalResult,
                                    Future<?> future)