Package io.netty.resolver.dns
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 Channel
private int
private static final long
private static final InternalLogger
private final InetSocketAddress
private final DnsRecord
private final Promise
<AddressedEnvelope<DnsResponse, InetSocketAddress>> private final DnsQueryContextManager
private final long
private final DnsQuestion
private final boolean
private final boolean
private final Bootstrap
private static final TcpDnsQueryEncoder
private 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 boolean
finishFailure
(String message, Throwable cause, boolean timeout) Notifies the originalPromise
that the query completes because of an failure.private void
finishOriginal
(Object originalResult, Future<?> future) (package private) void
finishSuccess
(AddressedEnvelope<? extends DnsResponse, InetSocketAddress> envelope, boolean truncated) Notifies the originalPromise
that the response for the query was received.private static boolean
hasOptRecord
(DnsRecord[] additionals) (package private) final boolean
isDone()
Returnstrue
if the query was completed already.protected abstract DnsQuery
newQuery
(int id, InetSocketAddress nameServerAddr) Creates and returns a newDnsQuery
.private void
onQueryWriteCompletion
(long queryTimeoutMillis, ChannelFuture writeFuture) protected abstract String
protocol()
Returns the protocol that is used for the query.(package private) final DnsQuestion
question()
Returns theDnsQuestion
that will be written as part of theDnsQuery
.private void
removeFromContextManager
(InetSocketAddress nameServerAddr) private boolean
retryWithTcp
(Object originalResult) Retry the original query with TCP if possible.private ChannelFuture
private boolean
trySuccess
(AddressedEnvelope<? extends DnsResponse, InetSocketAddress> envelope) (package private) final ChannelFuture
writeQuery
(boolean flush) Write the query and return theChannelFuture
that is completed once the write completes.private void
writeQuery
(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()Returnstrue
if the query was completed already.- Returns:
true
if done.
-
question
Returns theDnsQuestion
that 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 theChannelFuture
that is completed once the write completes.- Parameters:
flush
-true
ifChannel.flush()
should be called as well.- Returns:
- the
ChannelFuture
that is notified once once the write completes.
-
removeFromContextManager
-
sendQuery
-
writeQuery
-
onQueryWriteCompletion
-
finishSuccess
void finishSuccess(AddressedEnvelope<? extends DnsResponse, InetSocketAddress> envelope, boolean truncated) Notifies the originalPromise
that the response for the query was received. This method takes ownership of passedAddressedEnvelope
. -
trySuccess
-
finishFailure
Notifies the originalPromise
that the query completes because of an failure. -
retryWithTcp
Retry the original query with TCP if possible.- Parameters:
originalResult
- the result of the originalDnsQueryContext
.- Returns:
true
if retry via TCP is supported and so the ownership oforiginalResult
was transferred,false
otherwise.
-
finishOriginal
-