forked from eclipse-vertx/vert.x
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the DNS resolver used to resolve internet names to avoid con…
…fusion with the new net address resolver mechanism
- Loading branch information
Showing
7 changed files
with
30 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,21 +9,20 @@ | |
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
*/ | ||
|
||
package io.vertx.core.impl.resolver; | ||
package io.vertx.core.dns.impl; | ||
|
||
import io.netty.resolver.AddressResolverGroup; | ||
import io.netty.resolver.DefaultAddressResolverGroup; | ||
import io.vertx.core.Future; | ||
import io.vertx.core.Handler; | ||
import io.vertx.core.dns.AddressResolverOptions; | ||
import io.vertx.core.spi.resolver.ResolverProvider; | ||
import io.vertx.core.spi.dns.AddressResolverProvider; | ||
|
||
import java.net.InetSocketAddress; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Julien Viet</a> | ||
*/ | ||
public class DefaultResolverProvider implements ResolverProvider { | ||
public class DefaultAddressResolverProvider implements AddressResolverProvider { | ||
|
||
@Override | ||
public AddressResolverGroup<InetSocketAddress> resolver(AddressResolverOptions options) { | ||
|
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 |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
*/ | ||
|
||
package io.vertx.core.impl.resolver; | ||
package io.vertx.core.dns.impl; | ||
|
||
import io.netty.channel.EventLoop; | ||
import io.netty.channel.socket.SocketChannel; | ||
|
@@ -22,14 +22,13 @@ | |
import io.vertx.core.impl.AddressResolver; | ||
import io.vertx.core.impl.ContextInternal; | ||
import io.vertx.core.impl.VertxInternal; | ||
import io.vertx.core.spi.resolver.ResolverProvider; | ||
import io.vertx.core.spi.dns.AddressResolverProvider; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.StringReader; | ||
import java.net.*; | ||
import java.util.*; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import java.util.concurrent.atomic.AtomicLong; | ||
|
||
|
@@ -38,10 +37,10 @@ | |
/** | ||
* @author <a href="mailto:[email protected]">Julien Viet</a> | ||
*/ | ||
public class DnsResolverProvider implements ResolverProvider, HostsFileEntriesResolver { | ||
public class DnsAddressResolverProvider implements AddressResolverProvider, HostsFileEntriesResolver { | ||
|
||
public static DnsResolverProvider create(VertxInternal vertx, AddressResolverOptions options) { | ||
DnsResolverProvider provider = new DnsResolverProvider(vertx, options); | ||
public static DnsAddressResolverProvider create(VertxInternal vertx, AddressResolverOptions options) { | ||
DnsAddressResolverProvider provider = new DnsAddressResolverProvider(vertx, options); | ||
provider.refresh(); | ||
return provider; | ||
} | ||
|
@@ -56,7 +55,7 @@ public static DnsResolverProvider create(VertxInternal vertx, AddressResolverOpt | |
private final long hostsRefreshPeriodNanos; | ||
private volatile HostsFileEntries parsedHostsFile = new HostsFileEntries(Collections.emptyMap(), Collections.emptyMap()); | ||
|
||
private DnsResolverProvider(VertxInternal vertx, AddressResolverOptions options) { | ||
private DnsAddressResolverProvider(VertxInternal vertx, AddressResolverOptions options) { | ||
List<String> dnsServers = options.getServers(); | ||
if (dnsServers != null && dnsServers.size() > 0) { | ||
for (String dnsServer : dnsServers) { | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,18 +9,16 @@ | |
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
*/ | ||
|
||
package io.vertx.core.spi.resolver; | ||
package io.vertx.core.spi.dns; | ||
|
||
import io.netty.resolver.AddressResolverGroup; | ||
import io.vertx.core.Future; | ||
import io.vertx.core.Handler; | ||
import io.vertx.core.Vertx; | ||
import io.vertx.core.VertxException; | ||
import io.vertx.core.dns.AddressResolverOptions; | ||
import io.vertx.core.impl.VertxImpl; | ||
import io.vertx.core.impl.VertxInternal; | ||
import io.vertx.core.impl.resolver.DnsResolverProvider; | ||
import io.vertx.core.impl.resolver.DefaultResolverProvider; | ||
import io.vertx.core.dns.impl.DnsAddressResolverProvider; | ||
import io.vertx.core.dns.impl.DefaultAddressResolverProvider; | ||
import io.vertx.core.impl.logging.Logger; | ||
import io.vertx.core.impl.logging.LoggerFactory; | ||
|
||
|
@@ -29,25 +27,25 @@ | |
/** | ||
* @author <a href="mailto:[email protected]">Julien Viet</a> | ||
*/ | ||
public interface ResolverProvider { | ||
public interface AddressResolverProvider { | ||
|
||
String DISABLE_DNS_RESOLVER_PROP_NAME = "vertx.disableDnsResolver"; | ||
|
||
static ResolverProvider factory(Vertx vertx, AddressResolverOptions options) { | ||
static AddressResolverProvider factory(Vertx vertx, AddressResolverOptions options) { | ||
// For now not really plugable, we just want to not fail when we can't load the async provider | ||
// that use an unstable API and fallback on the default (blocking) provider | ||
try { | ||
if (!Boolean.getBoolean(DISABLE_DNS_RESOLVER_PROP_NAME)) { | ||
return DnsResolverProvider.create((VertxInternal) vertx, options); | ||
return DnsAddressResolverProvider.create((VertxInternal) vertx, options); | ||
} | ||
} catch (Throwable e) { | ||
if (e instanceof VertxException) { | ||
throw e; | ||
} | ||
Logger logger = LoggerFactory.getLogger(ResolverProvider.class); | ||
Logger logger = LoggerFactory.getLogger(AddressResolverProvider.class); | ||
logger.info("Using the default address resolver as the dns resolver could not be loaded"); | ||
} | ||
return new DefaultResolverProvider(); | ||
return new DefaultAddressResolverProvider(); | ||
} | ||
|
||
AddressResolverGroup<InetSocketAddress> resolver(AddressResolverOptions options); | ||
|