-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DnsServiceDiscoverer
: add total resolution timeout (#2908)
Motivation: The existing `DnsServiceDiscovererBuilder.queryTimeout` is applied per each UDP/TCP query. If resolution requires multiple CNAME resolutions, retries on a different NS server, or applies a list of search domains, the total time is not capped. As a result, resolution can take significantly longer than originally anticipated. Modifications: - Add `DnsServiceDiscovererBuilder.resolutionTimeout` option that can be used to cap total resolution duration with default value set to `2 x queryTimeout`; - Add tests for `queryTimeout` and `resolutionTimeout`; Result: Users can configure the total resolution timeout.
- Loading branch information
1 parent
e94fa6c
commit c85a8f4
Showing
8 changed files
with
267 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...tty/src/main/java/io/servicetalk/dns/discovery/netty/DnsNameResolverTimeoutException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright © 2024 Apple Inc. and the ServiceTalk project authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.servicetalk.dns.discovery.netty; | ||
|
||
import io.servicetalk.concurrent.internal.ThrowableUtils; | ||
|
||
import java.net.UnknownHostException; | ||
|
||
final class DnsNameResolverTimeoutException extends UnknownHostException { | ||
private static final long serialVersionUID = 3089160074512305891L; | ||
|
||
private DnsNameResolverTimeoutException(final String name, final String recordType, final long timeoutMs) { | ||
super("Resolution for '" + name + "' [" + recordType + "] timed out after " + timeoutMs + " milliseconds"); | ||
} | ||
|
||
@Override | ||
public Throwable fillInStackTrace() { | ||
return this; | ||
} | ||
|
||
static DnsNameResolverTimeoutException newInstance(final String name, final long timeoutMs, final String recordType, | ||
final Class<?> clazz, final String method) { | ||
return ThrowableUtils.unknownStackTrace(new DnsNameResolverTimeoutException(name, recordType, timeoutMs), | ||
clazz, method); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.