writeQuery() — netty Function Reference
Architecture documentation for the writeQuery() function in DnsQueryContext.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD d553b80a_9410_aa58_ac6c_ad8bcdf2e222["writeQuery()"] 360b8eed_0666_8e3d_9331_e795bb312381["DnsQueryContext"] d553b80a_9410_aa58_ac6c_ad8bcdf2e222 -->|defined in| 360b8eed_0666_8e3d_9331_e795bb312381 6f692862_9d69_de7f_1c52_b61a73cddf20["ChannelFuture()"] 6f692862_9d69_de7f_1c52_b61a73cddf20 -->|calls| d553b80a_9410_aa58_ac6c_ad8bcdf2e222 4d492031_b30c_1800_087b_fedd91fd6347["retryWithTcp()"] 4d492031_b30c_1800_087b_fedd91fd6347 -->|calls| d553b80a_9410_aa58_ac6c_ad8bcdf2e222 c1b3ef8a_d203_e5e3_4c2f_67fdad9bbd92["finishFailure()"] d553b80a_9410_aa58_ac6c_ad8bcdf2e222 -->|calls| c1b3ef8a_d203_e5e3_4c2f_67fdad9bbd92 83864166_f1ac_4045_c639_0eaffca1b560["removeFromContextManager()"] d553b80a_9410_aa58_ac6c_ad8bcdf2e222 -->|calls| 83864166_f1ac_4045_c639_0eaffca1b560 74bccd11_01b5_da96_3a42_7c9f607f3a24["isDone()"] d553b80a_9410_aa58_ac6c_ad8bcdf2e222 -->|calls| 74bccd11_01b5_da96_3a42_7c9f607f3a24 02e54375_a4b8_ba90_af41_190cf641d5e4["onQueryWriteCompletion()"] d553b80a_9410_aa58_ac6c_ad8bcdf2e222 -->|calls| 02e54375_a4b8_ba90_af41_190cf641d5e4 style d553b80a_9410_aa58_ac6c_ad8bcdf2e222 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
resolver-dns/src/main/java/io/netty/resolver/dns/DnsQueryContext.java lines 172–231
final void writeQuery(boolean flush) {
assert id == Integer.MIN_VALUE : this.getClass().getSimpleName() +
".writeQuery(...) can only be executed once.";
if ((id = queryContextManager.add(nameServerAddr, this)) == -1) {
// We did exhaust the id space, fail the query
IllegalStateException e = new IllegalStateException("query ID space exhausted: " + question());
finishFailure("failed to send a query via " + protocol(), e, false);
queryLifecycleObserver.queryWritten(nameServerAddr, channel.newFailedFuture(e));
}
// Ensure we remove the id from the QueryContextManager once the query completes.
promise.addListener((FutureListener<AddressedEnvelope<DnsResponse, InetSocketAddress>>) future -> {
// Cancel the timeout task.
Future<?> timeoutFuture = DnsQueryContext.this.timeoutFuture;
if (timeoutFuture != null) {
DnsQueryContext.this.timeoutFuture = null;
timeoutFuture.cancel(false);
}
Throwable cause = future.cause();
if (cause instanceof DnsNameResolverTimeoutException || cause instanceof CancellationException) {
// This query was failed due a timeout or cancellation. Let's delay the removal of the id to reduce
// the risk of reusing the same id again while the remote nameserver might send the response after
// the timeout.
channel.eventLoop().schedule(new Runnable() {
@Override
public void run() {
removeFromContextManager(nameServerAddr);
}
}, ID_REUSE_ON_TIMEOUT_DELAY_MILLIS, TimeUnit.MILLISECONDS);
} else {
// Remove the id from the manager as soon as the query completes. This may be because of success,
// failure or cancellation
removeFromContextManager(nameServerAddr);
}
});
final DnsQuestion question = question();
final DnsQuery query = newQuery(id, nameServerAddr);
query.setRecursionDesired(recursionDesired);
query.addRecord(DnsSection.QUESTION, question);
for (DnsRecord record: additionals) {
query.addRecord(DnsSection.ADDITIONAL, record);
}
if (optResource != null) {
query.addRecord(DnsSection.ADDITIONAL, optResource);
}
if (logger.isDebugEnabled()) {
logger.debug("{} WRITE: {}, [{}: {}], {}",
channel, protocol(), id, nameServerAddr, question);
}
ChannelFuture f = sendQuery(query, flush);
queryLifecycleObserver.queryWritten(nameServerAddr, f);
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does writeQuery() do?
writeQuery() is a function in the netty codebase, defined in resolver-dns/src/main/java/io/netty/resolver/dns/DnsQueryContext.java.
Where is writeQuery() defined?
writeQuery() is defined in resolver-dns/src/main/java/io/netty/resolver/dns/DnsQueryContext.java at line 172.
What does writeQuery() call?
writeQuery() calls 4 function(s): finishFailure, isDone, onQueryWriteCompletion, removeFromContextManager.
What calls writeQuery()?
writeQuery() is called by 2 function(s): ChannelFuture, retryWithTcp.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free