Class DnsQueryContext
java.lang.Object
io.netty.resolver.dns.DnsQueryContext
- Direct Known Subclasses:
DatagramDnsQueryContext, TcpDnsQueryContext
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DnsRecord[]private final Channelprivate intprivate static final longprivate static final InternalLoggerprivate final InetSocketAddressprivate final DnsRecordprivate final Promise<AddressedEnvelope<DnsResponse, InetSocketAddress>> private final DnsQueryContextManagerprivate final longprivate final DnsQuestionprivate final booleanprivate final booleanprivate final Bootstrapprivate static final TcpDnsQueryEncoderprivate Future<?> -
Constructor Summary
ConstructorsConstructorDescriptionDnsQueryContext(Channel channel, InetSocketAddress nameServerAddr, DnsQueryContextManager queryContextManager, int maxPayLoadSize, boolean recursionDesired, long queryTimeoutMillis, DnsQuestion question, DnsRecord[] additionals, Promise<AddressedEnvelope<DnsResponse, InetSocketAddress>> promise, Bootstrap socketBootstrap, boolean retryWithTcpOnTimeout) -
Method Summary
Modifier and TypeMethodDescription(package private) final booleanfinishFailure(String message, Throwable cause, boolean timeout) Notifies the originalPromisethat the query completes because of an failure.private voidfinishOriginal(Object originalResult, Future<?> future) (package private) voidfinishSuccess(AddressedEnvelope<? extends DnsResponse, InetSocketAddress> envelope, boolean truncated) Notifies the originalPromisethat the response for the query was received.private static booleanhasOptRecord(DnsRecord[] additionals) (package private) final booleanisDone()Returnstrueif the query was completed already.protected abstract DnsQuerynewQuery(int id, InetSocketAddress nameServerAddr) Creates and returns a newDnsQuery.private voidonQueryWriteCompletion(long queryTimeoutMillis, ChannelFuture writeFuture) protected abstract Stringprotocol()Returns the protocol that is used for the query.(package private) final DnsQuestionquestion()Returns theDnsQuestionthat will be written as part of theDnsQuery.private voidremoveFromContextManager(InetSocketAddress nameServerAddr) private booleanretryWithTcp(Object originalResult) Retry the original query with TCP if possible.private ChannelFutureprivate booleantrySuccess(AddressedEnvelope<? extends DnsResponse, InetSocketAddress> envelope) (package private) final ChannelFuturewriteQuery(boolean flush) Write the query and return theChannelFuturethat is completed once the write completes.private voidwriteQuery(DnsQuery query, boolean flush, ChannelPromise promise)
-
Field Details
-
logger
-
ID_REUSE_ON_TIMEOUT_DELAY_MILLIS
private static final long ID_REUSE_ON_TIMEOUT_DELAY_MILLIS -
TCP_ENCODER
-
channel
-
nameServerAddr
-
queryContextManager
-
promise
-
question
-
additionals
-
optResource
-
recursionDesired
private final boolean recursionDesired -
socketBootstrap
-
retryWithTcpOnTimeout
private final boolean retryWithTcpOnTimeout -
queryTimeoutMillis
private final long queryTimeoutMillis -
timeoutFuture
-
id
private int id
-
-
Constructor Details
-
DnsQueryContext
DnsQueryContext(Channel channel, InetSocketAddress nameServerAddr, DnsQueryContextManager queryContextManager, int maxPayLoadSize, boolean recursionDesired, long queryTimeoutMillis, DnsQuestion question, DnsRecord[] additionals, Promise<AddressedEnvelope<DnsResponse, InetSocketAddress>> promise, Bootstrap socketBootstrap, boolean retryWithTcpOnTimeout)
-
-
Method Details
-
hasOptRecord
-
isDone
final boolean isDone()Returnstrueif the query was completed already.- Returns:
trueif done.
-
question
Returns theDnsQuestionthat will be written as part of theDnsQuery.- Returns:
- the question.
-
newQuery
Creates and returns a newDnsQuery.- Parameters:
id- the transaction id to use.nameServerAddr- the nameserver to which the query will be send.- Returns:
- the new query.
-
protocol
Returns the protocol that is used for the query.- Returns:
- the protocol.
-
writeQuery
Write the query and return theChannelFuturethat is completed once the write completes.- Parameters:
flush-trueifChannel.flush()should be called as well.- Returns:
- the
ChannelFuturethat is notified once once the write completes.
-
removeFromContextManager
-
sendQuery
-
writeQuery
-
onQueryWriteCompletion
-
finishSuccess
void finishSuccess(AddressedEnvelope<? extends DnsResponse, InetSocketAddress> envelope, boolean truncated) Notifies the originalPromisethat the response for the query was received. This method takes ownership of passedAddressedEnvelope. -
trySuccess
-
finishFailure
-
retryWithTcp
Retry the original query with TCP if possible.- Parameters:
originalResult- the result of the originalDnsQueryContext.- Returns:
trueif retry via TCP is supported and so the ownership oforiginalResultwas transferred,falseotherwise.
-
finishOriginal
-