Class DnsQueryContext
java.lang.Object
io.netty.resolver.dns.DnsQueryContext
- Direct Known Subclasses:
DatagramDnsQueryContext, TcpDnsQueryContext
abstract class DnsQueryContext
extends java.lang.Object
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DnsRecord[]private final Channelprivate final byte[]private final booleanprivate intprivate static final longprivate static final InternalLoggerprivate final java.net.InetSocketAddressprivate final DnsRecordprivate final Promise<AddressedEnvelope<DnsResponse, java.net.InetSocketAddress>> private final DnsQueryProtectionprivate final DnsQueryContextManagerprivate final DnsQueryLifecycleObserverprivate final longprivate final DnsQuestionprivate final booleanprivate final booleanprivate final Bootstrapprivate static final TcpDnsQueryEncoderprivate Future<?> private final DnsQuestion -
Constructor Summary
ConstructorsConstructorDescriptionDnsQueryContext(Channel channel, java.net.InetSocketAddress nameServerAddr, DnsQueryContextManager queryContextManager, DnsQueryLifecycleObserver queryLifecycleObserver, int maxPayLoadSize, boolean recursionDesired, long queryTimeoutMillis, DnsQuestion question, DnsQuestion wireQuestion, DnsRecord[] additionals, Promise<AddressedEnvelope<DnsResponse, java.net.InetSocketAddress>> promise, Bootstrap socketBootstrap, boolean retryWithTcpOnTimeout, DnsQueryProtection protection) -
Method Summary
Modifier and TypeMethodDescription(package private) final booleanfinishFailure(java.lang.String message, java.lang.Throwable cause, boolean timeout) Notifies the originalPromisethat the query completes because of an failure.private voidfinishOriginal(java.lang.Object originalResult, Future<?> future) (package private) voidfinishSuccess(AddressedEnvelope<? extends DnsResponse, java.net.InetSocketAddress> envelope, boolean truncated) Notifies the originalPromisethat the response for the query was received.private voidfinishSuccess(AddressedEnvelope<? extends DnsResponse, java.net.InetSocketAddress> envelope, boolean truncated, boolean validateCookie) private static booleanhasOptRecord(DnsRecord[] additionals) (package private) final booleanisDone()Returnstrueif the query was completed already.private booleanmatchesQuestion(java.lang.Object responseQuestion) protected abstract DnsQuerynewQuery(int id, java.net.InetSocketAddress nameServerAddr) Creates and returns a newDnsQuery.private voidonQueryWriteCompletion(long queryTimeoutMillis, ChannelFuture writeFuture) protected abstract java.lang.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(java.net.InetSocketAddress nameServerAddr) private booleanretryWithTcp(java.lang.Object originalResult) Retry the original query with TCP if possible.private ChannelFutureprivate booleantrySuccess(AddressedEnvelope<? extends DnsResponse, java.net.InetSocketAddress> envelope) private boolean(package private) final DnsQuestionReturns theDnsQuestionthat is written to the wire.(package private) final voidwriteQuery(boolean flush) Write the query and return theChannelFuturethat is completed once the write completes.private voidwriteQuery(DnsQuery query, boolean flush, ChannelPromise promise) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
logger
-
ID_REUSE_ON_TIMEOUT_DELAY_MILLIS
private static final long ID_REUSE_ON_TIMEOUT_DELAY_MILLIS -
TCP_ENCODER
-
channel
-
nameServerAddr
private final java.net.InetSocketAddress nameServerAddr -
queryContextManager
-
queryLifecycleObserver
-
promise
-
question
-
wireQuestion
-
exactCaseMatch
private final boolean exactCaseMatch -
additionals
-
optResource
-
protection
-
clientCookie
private final byte[] clientCookie -
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, java.net.InetSocketAddress nameServerAddr, DnsQueryContextManager queryContextManager, DnsQueryLifecycleObserver queryLifecycleObserver, int maxPayLoadSize, boolean recursionDesired, long queryTimeoutMillis, DnsQuestion question, DnsQuestion wireQuestion, DnsRecord[] additionals, Promise<AddressedEnvelope<DnsResponse, java.net.InetSocketAddress>> promise, Bootstrap socketBootstrap, boolean retryWithTcpOnTimeout, DnsQueryProtection protection)
-
-
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.
-
wireQuestion
Returns theDnsQuestionthat is written to the wire. This may differ in case fromquestion().- Returns:
- the question.
-
newQuery
-
protocol
protected abstract java.lang.String protocol()Returns the protocol that is used for the query.- Returns:
- the protocol.
-
writeQuery
final void writeQuery(boolean flush) Write the query and return theChannelFuturethat is completed once the write completes.- Parameters:
flush-trueifChannel.flush()should be called as well.
-
removeFromContextManager
private void removeFromContextManager(java.net.InetSocketAddress nameServerAddr) -
sendQuery
-
writeQuery
-
onQueryWriteCompletion
-
finishSuccess
void finishSuccess(AddressedEnvelope<? extends DnsResponse, java.net.InetSocketAddress> envelope, boolean truncated) Notifies the originalPromisethat the response for the query was received. This method takes ownership of passedAddressedEnvelope. -
finishSuccess
private void finishSuccess(AddressedEnvelope<? extends DnsResponse, java.net.InetSocketAddress> envelope, boolean truncated, boolean validateCookie) - Parameters:
validateCookie-falseif the response was received via a different, already authenticated, transport (like TCP) and so does not carry a cookie that belongs to this query.
-
matchesQuestion
private boolean matchesQuestion(java.lang.Object responseQuestion) -
validateCookie
-
trySuccess
private boolean trySuccess(AddressedEnvelope<? extends DnsResponse, java.net.InetSocketAddress> envelope) -
finishFailure
final boolean finishFailure(java.lang.String message, java.lang.Throwable cause, boolean timeout) Notifies the originalPromisethat 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 originalDnsQueryContext.- Returns:
trueif retry via TCP is supported and so the ownership oforiginalResultwas transferred,falseotherwise.
-
finishOriginal
-