doQuery() — netty Function Reference
Architecture documentation for the doQuery() function in DnsNameResolver.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 9a99849e_e4db_2770_bf8c_fd1deccf3738["doQuery()"] a8faea52_3f45_7b36_4918_3dfb9bd6ee9b["DnsNameResolver"] 9a99849e_e4db_2770_bf8c_fd1deccf3738 -->|defined in| a8faea52_3f45_7b36_4918_3dfb9bd6ee9b 84f19abd_141a_7a6b_231d_77cb1e904980["query()"] 84f19abd_141a_7a6b_231d_77cb1e904980 -->|calls| 9a99849e_e4db_2770_bf8c_fd1deccf3738 4b8e3d3a_943e_7aa5_2a64_33bb11b7df6e["cast()"] 9a99849e_e4db_2770_bf8c_fd1deccf3738 -->|calls| 4b8e3d3a_943e_7aa5_2a64_33bb11b7df6e c5ca97ec_1f60_5385_797b_cc14da1a91c4["isOptResourceEnabled()"] 9a99849e_e4db_2770_bf8c_fd1deccf3738 -->|calls| c5ca97ec_1f60_5385_797b_cc14da1a91c4 0b6fa87b_ef23_a9ae_625d_694f2b7d999e["maxPayloadSize()"] 9a99849e_e4db_2770_bf8c_fd1deccf3738 -->|calls| 0b6fa87b_ef23_a9ae_625d_694f2b7d999e 4a800f4c_00ae_ef6b_7a2e_8ce9bc9490f2["isTimeoutError()"] 9a99849e_e4db_2770_bf8c_fd1deccf3738 -->|calls| 4a800f4c_00ae_ef6b_7a2e_8ce9bc9490f2 3581828a_7b6f_bee9_3ae4_2434fd28eb01["doQueryNow()"] 9a99849e_e4db_2770_bf8c_fd1deccf3738 -->|calls| 3581828a_7b6f_bee9_3ae4_2434fd28eb01 style 9a99849e_e4db_2770_bf8c_fd1deccf3738 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java lines 1389–1471
@SuppressWarnings("unchecked")
final Future<AddressedEnvelope<DnsResponse, InetSocketAddress>> doQuery(
Channel channel,
InetSocketAddress nameServerAddr, DnsQuestion question,
final DnsQueryLifecycleObserver queryLifecycleObserver,
DnsRecord[] additionals, boolean flush,
Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> promise) {
final Promise<AddressedEnvelope<DnsResponse, InetSocketAddress>> castPromise = cast(
checkNotNull(promise, "promise"));
final int payloadSize = isOptResourceEnabled() ? maxPayloadSize() : 0;
if (inflightLookups != null && (additionals == null || additionals.length == 0)) {
Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> inflight =
inflightLookups.get(question);
if (inflight != null) {
// We have a query / response inflight, let's just cascade on it to reduce the network traffic.
inflight.addListener(f -> {
if (f.isSuccess()) {
// Notify the observer and after that the promise
queryLifecycleObserver.querySucceed();
AddressedEnvelope<? extends DnsResponse, InetSocketAddress> result =
(AddressedEnvelope<? extends DnsResponse, InetSocketAddress>) f.getNow();
// Retain the result as the listener on the promise is responsible to release it.
ReferenceCountUtil.retain(result);
promise.setSuccess(result);
} else {
Throwable cause = f.cause();
if (isTimeoutError(cause)) {
doQueryNow(channel, nameServerAddr, question, queryLifecycleObserver,
additionals, flush, payloadSize, castPromise);
} else {
// Notify the observer and after that the promise
queryLifecycleObserver.queryFailed(cause);
promise.setFailure(cause);
}
}
});
return castPromise;
} else if (inflightLookups.size() < maxNumConsolidation) {
// Create a new promise as we need to ensure we are the first that will add a listener to it to retain
// the result before anyone can release it.
Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> newPromise =
executor().newPromise();
Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> old =
inflightLookups.put(question, newPromise);
assert old == null;
newPromise.addListener(f -> {
// Remove the promise and add another listener to it that will call release() on the result.
// As the execution of the listeners is guaranteed to be in the same order as how these were added
// we know that all previous added listeners had a chance to handle the result already.
Promise<AddressedEnvelope<? extends DnsResponse, InetSocketAddress>> p =
inflightLookups.remove(question);
assert p == newPromise;
if (f.isSuccess()) {
// On success we need to retain the result so listeners that are added after this one
// will still be able to use the result.
AddressedEnvelope<? extends DnsResponse, InetSocketAddress> result =
(AddressedEnvelope<? extends DnsResponse, InetSocketAddress>) f.getNow();
ReferenceCountUtil.retain(result);
promise.setSuccess(result);
} else {
promise.setFailure(f.cause());
}
p.addListener(RELEASE_LISTENER);
});
doQueryNow(channel, nameServerAddr, question, queryLifecycleObserver,
additionals, flush, payloadSize, cast(newPromise));
// Return the original castPromise which will be notified by the newPromise that we used above.
// This was it's impossible for the user to add any extra listeners to the newPromise itself, which
// is needed to guarantee the correct life-cycle of the reference counted response.
return castPromise;
}
}
doQueryNow(channel, nameServerAddr, question, queryLifecycleObserver,
additionals, flush, payloadSize, castPromise);
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does doQuery() do?
doQuery() is a function in the netty codebase, defined in resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java.
Where is doQuery() defined?
doQuery() is defined in resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java at line 1389.
What does doQuery() call?
doQuery() calls 5 function(s): cast, doQueryNow, isOptResourceEnabled, isTimeoutError, maxPayloadSize.
What calls doQuery()?
doQuery() is called by 1 function(s): query.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free