Top Inners Fields Constructors Methods
io.netty.resolver.dns

pack-priv abstract Class DnsQueryContext

extends Object
Class Inheritance
Known Direct Subclasses
io.netty.resolver.dns.TcpDnsQueryContext, io.netty.resolver.dns.DatagramDnsQueryContext
Imports
io.netty.bootstrap.Bootstrap, io.netty.channel.AddressedEnvelope, .Channel, .ChannelFuture, .ChannelFutureListener, .ChannelHandlerContext, .ChannelInboundHandlerAdapter, .ChannelPromise, io.netty.handler.codec.dns.AbstractDnsOptPseudoRrRecord, .DnsQuery, .DnsQuestion, .DnsRecord, .DnsRecordType, .DnsResponse, .DnsSection, .TcpDnsQueryEncoder, .TcpDnsResponseDecoder, io.netty.util.ReferenceCountUtil, io.netty.util.concurrent.Future, .FutureListener, .GenericFutureListener, .Promise, io.netty.util.internal.SystemPropertyUtil, .ThrowableUtil, io.netty.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.net.InetSocketAddress, .SocketAddress, java.util.concurrent.CancellationException, .TimeUnit

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final DnsRecord[]
private final Channel
private final Future<? extends 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 volatile Future<?>

Constructor Summary

AccessConstructor and Description
pack-priv
DnsQueryContext(Channel channel, Future<? extends Channel> channelReadyFuture, 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 TypeMethod and Description
private void
failQuery(DnsQuery query, Throwable cause, ChannelPromise writePromise)

pack-priv final boolean
finishFailure(String message, Throwable cause, boolean timeout)

Notifies the original Promise that the query completes because of an failure.

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

pack-priv void
finishSuccess(AddressedEnvelope<? extends DnsResponse, InetSocketAddress> envelope, boolean truncated)

Notifies the original Promise that the response for the query was received.

private static boolean
hasOptRecord(DnsRecord[] additionals)

pack-priv final boolean

Returns:

true if done.
isDone
()

Returns true if the query was completed already.

protected abstract DnsQuery

Returns:

the new query.
newQuery
(int
the transaction id to use.
id
,
InetSocketAddress
the nameserver to which the query will be send.
nameServerAddr
)

Creates and returns a new DnsQuery.

private void
onQueryWriteCompletion(final long queryTimeoutMillis, ChannelFuture writeFuture)

protected abstract String

Returns:

the protocol.
protocol
()

Returns the protocol that is used for the query.

pack-priv final DnsQuestion

Returns:

the question.
question
()

Returns the DnsQuestion that will be written as part of the DnsQuery.

private void
private boolean

Returns:

true if retry via TCP is supported and so the ownership of originalResult was transferred, false otherwise.
retryWithTcp
(final Object
the result of the original DnsQueryContext.
originalResult
)

Retry the original query with TCP if possible.

private ChannelFuture
sendQuery(final DnsQuery query, final boolean flush)

private boolean
pack-priv final ChannelFuture

Returns:

the ChannelFuture that is notified once once the write completes.
writeQuery
(boolean
true if Channel#flush() should be called as well.
flush
)

Write the query and return the ChannelFuture that is completed once the write completes.

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

additionalsback to summary
private final DnsRecord[] additionals
channelback to summary
private final Channel channel
channelReadyFutureback to summary
private final Future<? extends Channel> channelReadyFuture
idback to summary
private int id
ID_REUSE_ON_TIMEOUT_DELAY_MILLISback to summary
private static final long ID_REUSE_ON_TIMEOUT_DELAY_MILLIS
loggerback to summary
private static final InternalLogger logger
nameServerAddrback to summary
private final InetSocketAddress nameServerAddr
optResourceback to summary
private final DnsRecord optResource
promiseback to summary
private final Promise<AddressedEnvelope<DnsResponse, InetSocketAddress>> promise
queryContextManagerback to summary
private final DnsQueryContextManager queryContextManager
queryTimeoutMillisback to summary
private final long queryTimeoutMillis
questionback to summary
private final DnsQuestion question
recursionDesiredback to summary
private final boolean recursionDesired
retryWithTcpOnTimeoutback to summary
private final boolean retryWithTcpOnTimeout
socketBootstrapback to summary
private final Bootstrap socketBootstrap
TCP_ENCODERback to summary
private static final TcpDnsQueryEncoder TCP_ENCODER
timeoutFutureback to summary
private volatile Future<?> timeoutFuture

Constructor Detail

DnsQueryContextback to summary
pack-priv DnsQueryContext(Channel channel, Future<? extends Channel> channelReadyFuture, InetSocketAddress nameServerAddr, DnsQueryContextManager queryContextManager, int maxPayLoadSize, boolean recursionDesired, long queryTimeoutMillis, DnsQuestion question, DnsRecord[] additionals, Promise<AddressedEnvelope<DnsResponse, InetSocketAddress>> promise, Bootstrap socketBootstrap, boolean retryWithTcpOnTimeout)

Method Detail

failQueryback to summary
private void failQuery(DnsQuery query, Throwable cause, ChannelPromise writePromise)
finishFailureback to summary
pack-priv final boolean finishFailure(String message, Throwable cause, boolean timeout)

Notifies the original Promise that the query completes because of an failure.

finishOriginalback to summary
private void finishOriginal(Object originalResult, Future<?> future)
Annotations
@SuppressWarnings:unchecked
finishSuccessback to summary
pack-priv 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.

hasOptRecordback to summary
private static boolean hasOptRecord(DnsRecord[] additionals)
isDoneback to summary
pack-priv final boolean isDone()

Returns true if the query was completed already.

Returns:boolean

true if done.

newQueryback to summary
protected abstract DnsQuery newQuery(int id, InetSocketAddress nameServerAddr)

Creates and returns a new DnsQuery.

Parameters
id:int

the transaction id to use.

nameServerAddr:InetSocketAddress

the nameserver to which the query will be send.

Returns:DnsQuery

the new query.

onQueryWriteCompletionback to summary
private void onQueryWriteCompletion(final long queryTimeoutMillis, ChannelFuture writeFuture)
protocolback to summary
protected abstract String protocol()

Returns the protocol that is used for the query.

Returns:String

the protocol.

questionback to summary
pack-priv final DnsQuestion question()

Returns the DnsQuestion that will be written as part of the DnsQuery.

Returns:DnsQuestion

the question.

removeFromContextManagerback to summary
private void removeFromContextManager(InetSocketAddress nameServerAddr)
retryWithTcpback to summary
private boolean retryWithTcp(final Object originalResult)

Retry the original query with TCP if possible.

Parameters
originalResult:Object

the result of the original DnsQueryContext.

Returns:boolean

true if retry via TCP is supported and so the ownership of originalResult was transferred, false otherwise.

sendQueryback to summary
private ChannelFuture sendQuery(final DnsQuery query, final boolean flush)
trySuccessback to summary
private boolean trySuccess(AddressedEnvelope<? extends DnsResponse, InetSocketAddress> envelope)
Annotations
@SuppressWarnings:unchecked
writeQueryback to summary
pack-priv final ChannelFuture writeQuery(boolean flush)

Write the query and return the ChannelFuture that is completed once the write completes.

Parameters
flush:boolean

true if Channel#flush() should be called as well.

Returns:ChannelFuture

the ChannelFuture that is notified once once the write completes.

writeQueryback to summary
private void writeQuery(final DnsQuery query, final boolean flush, ChannelPromise promise)
io.netty.resolver.dns back to summary

private final Class DnsQueryContext.AddressedEnvelopeAdapter

extends Object
implements AddressedEnvelope<DnsResponse, InetSocketAddress>
Class Inheritance
  • java.lang.Object
  • io.netty.resolver.dns.DnsQueryContext.AddressedEnvelopeAdapter
All Implemented Interfaces
io.netty.channel.AddressedEnvelope, io.netty.util.ReferenceCounted

Field Summary

Modifier and TypeField and Description
private final InetSocketAddress
private final DnsResponse
private final InetSocketAddress

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public DnsResponse
content()

Implements io.netty.channel.AddressedEnvelope.content.

Returns the message wrapped by this envelope message.
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public InetSocketAddress
recipient()

Implements io.netty.channel.AddressedEnvelope.recipient.

Returns the address of the recipient of this message.
public int
refCnt()

Implements io.netty.util.ReferenceCounted.refCnt.

Returns the reference count of this object.
public boolean
release()

Implements io.netty.util.ReferenceCounted.release.

Decreases the reference count by 1 and deallocates this object if the reference count reaches at 0.
public boolean
release(int decrement)

Implements io.netty.util.ReferenceCounted.release.

Decreases the reference count by the specified decrement and deallocates this object if the reference count reaches at 0.
public AddressedEnvelope<DnsResponse, InetSocketAddress>
retain()

Implements io.netty.channel.AddressedEnvelope.retain.

Increases the reference count by 1.
public AddressedEnvelope<DnsResponse, InetSocketAddress>
retain(int increment)

Implements io.netty.channel.AddressedEnvelope.retain.

Increases the reference count by the specified increment.
public InetSocketAddress
sender()

Implements io.netty.channel.AddressedEnvelope.sender.

Returns the address of the sender of this message.
public AddressedEnvelope<DnsResponse, InetSocketAddress>
touch()

Implements io.netty.channel.AddressedEnvelope.touch.

Records the current access location of this object for debugging purposes.
public AddressedEnvelope<DnsResponse, InetSocketAddress>
touch(Object hint)

Implements io.netty.channel.AddressedEnvelope.touch.

Records the current access location of this object with an additional arbitrary information for debugging purposes.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

recipientback to summary
private final InetSocketAddress recipient
responseback to summary
private final DnsResponse response
senderback to summary
private final InetSocketAddress sender

Constructor Detail

AddressedEnvelopeAdapterback to summary
pack-priv AddressedEnvelopeAdapter(InetSocketAddress sender, InetSocketAddress recipient, DnsResponse response)

Method Detail

contentback to summary
public DnsResponse content()

Implements io.netty.channel.AddressedEnvelope.content.

Doc from io.netty.channel.AddressedEnvelope.content.

Returns the message wrapped by this envelope message.

Annotations
@Override
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
recipientback to summary
public InetSocketAddress recipient()

Implements io.netty.channel.AddressedEnvelope.recipient.

Doc from io.netty.channel.AddressedEnvelope.recipient.

Returns the address of the recipient of this message.

Annotations
@Override
refCntback to summary
public int refCnt()

Implements io.netty.util.ReferenceCounted.refCnt.

Doc from io.netty.util.ReferenceCounted.refCnt.

Returns the reference count of this object. If 0, it means this object has been deallocated.

Annotations
@Override
releaseback to summary
public boolean release()

Implements io.netty.util.ReferenceCounted.release.

Doc from io.netty.util.ReferenceCounted.release.

Decreases the reference count by 1 and deallocates this object if the reference count reaches at 0.

Returns:boolean

true if and only if the reference count became 0 and this object has been deallocated

Annotations
@Override
releaseback to summary
public boolean release(int decrement)

Implements io.netty.util.ReferenceCounted.release.

Doc from io.netty.util.ReferenceCounted.release.

Decreases the reference count by the specified decrement and deallocates this object if the reference count reaches at 0.

Returns:boolean

true if and only if the reference count became 0 and this object has been deallocated

Annotations
@Override
retainback to summary
public AddressedEnvelope<DnsResponse, InetSocketAddress> retain()

Implements io.netty.channel.AddressedEnvelope.retain.

Doc from io.netty.util.ReferenceCounted.retain.

Increases the reference count by 1.

Annotations
@Override
retainback to summary
public AddressedEnvelope<DnsResponse, InetSocketAddress> retain(int increment)

Implements io.netty.channel.AddressedEnvelope.retain.

Doc from io.netty.util.ReferenceCounted.retain.

Increases the reference count by the specified increment.

Annotations
@Override
senderback to summary
public InetSocketAddress sender()

Implements io.netty.channel.AddressedEnvelope.sender.

Doc from io.netty.channel.AddressedEnvelope.sender.

Returns the address of the sender of this message.

Annotations
@Override
touchback to summary
public AddressedEnvelope<DnsResponse, InetSocketAddress> touch()

Implements io.netty.channel.AddressedEnvelope.touch.

Doc from io.netty.util.ReferenceCounted.touch.

Records the current access location of this object for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you via ResourceLeakDetector. This method is a shortcut to touch(null).

Annotations
@Override
touchback to summary
public AddressedEnvelope<DnsResponse, InetSocketAddress> touch(Object hint)

Implements io.netty.channel.AddressedEnvelope.touch.

Doc from io.netty.util.ReferenceCounted.touch.

Records the current access location of this object with an additional arbitrary information for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you via ResourceLeakDetector.

Annotations
@Override