diff --git a/src/main/generated/io/vertx/core/dns/AddressResolverOptionsConverter.java b/src/main/generated/io/vertx/core/dns/AddressResolverOptionsConverter.java index c4cee6a673d..c30585cdbac 100644 --- a/src/main/generated/io/vertx/core/dns/AddressResolverOptionsConverter.java +++ b/src/main/generated/io/vertx/core/dns/AddressResolverOptionsConverter.java @@ -40,6 +40,11 @@ static void fromJson(Iterable> json, Address obj.setHostsPath((String)member.getValue()); } break; + case "hostsRefreshPeriod": + if (member.getValue() instanceof Number) { + obj.setHostsRefreshPeriod(((Number)member.getValue()).intValue()); + } + break; case "hostsValue": if (member.getValue() instanceof String) { obj.setHostsValue(io.vertx.core.buffer.Buffer.buffer(BASE64_DECODER.decode((String)member.getValue()))); @@ -115,6 +120,7 @@ static void toJson(AddressResolverOptions obj, java.util.Map jso if (obj.getHostsPath() != null) { json.put("hostsPath", obj.getHostsPath()); } + json.put("hostsRefreshPeriod", obj.getHostsRefreshPeriod()); if (obj.getHostsValue() != null) { json.put("hostsValue", BASE64_ENCODER.encodeToString(obj.getHostsValue().getBytes())); } diff --git a/src/main/java/io/vertx/core/Vertx.java b/src/main/java/io/vertx/core/Vertx.java index 1082c0028f6..430f26a6abf 100644 --- a/src/main/java/io/vertx/core/Vertx.java +++ b/src/main/java/io/vertx/core/Vertx.java @@ -11,7 +11,6 @@ package io.vertx.core; -import io.netty.channel.EventLoopGroup; import io.vertx.codegen.annotations.*; import io.vertx.core.datagram.DatagramSocket; import io.vertx.core.datagram.DatagramSocketOptions; @@ -25,7 +24,7 @@ import io.vertx.core.http.HttpServerOptions; import io.vertx.core.impl.ContextInternal; import io.vertx.core.impl.VertxBuilder; -import io.vertx.core.impl.resolver.DnsResolverProvider; +import io.vertx.core.dns.impl.DnsAddressResolverProvider; import io.vertx.core.metrics.Measured; import io.vertx.core.net.NetClient; import io.vertx.core.net.NetClientOptions; @@ -229,7 +228,7 @@ default DatagramSocket createDatagramSocket() { /** * Create a DNS client to connect to the DNS server configured by {@link VertxOptions#getAddressResolverOptions()} *

- * DNS client takes the first configured resolver address provided by {@link DnsResolverProvider#nameServerAddresses()}} + * DNS client takes the first configured resolver address provided by {@link DnsAddressResolverProvider#nameServerAddresses()}} * * @return the DNS client */ diff --git a/src/main/java/io/vertx/core/impl/resolver/DefaultResolverProvider.java b/src/main/java/io/vertx/core/dns/impl/DefaultAddressResolverProvider.java similarity index 83% rename from src/main/java/io/vertx/core/impl/resolver/DefaultResolverProvider.java rename to src/main/java/io/vertx/core/dns/impl/DefaultAddressResolverProvider.java index d3a9bbb46b0..11cdb814112 100644 --- a/src/main/java/io/vertx/core/impl/resolver/DefaultResolverProvider.java +++ b/src/main/java/io/vertx/core/dns/impl/DefaultAddressResolverProvider.java @@ -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 Julien Viet */ -public class DefaultResolverProvider implements ResolverProvider { +public class DefaultAddressResolverProvider implements AddressResolverProvider { @Override public AddressResolverGroup resolver(AddressResolverOptions options) { diff --git a/src/main/java/io/vertx/core/impl/resolver/DnsResolverProvider.java b/src/main/java/io/vertx/core/dns/impl/DnsAddressResolverProvider.java similarity index 95% rename from src/main/java/io/vertx/core/impl/resolver/DnsResolverProvider.java rename to src/main/java/io/vertx/core/dns/impl/DnsAddressResolverProvider.java index c54707092c0..7bed8dfc114 100644 --- a/src/main/java/io/vertx/core/impl/resolver/DnsResolverProvider.java +++ b/src/main/java/io/vertx/core/dns/impl/DnsAddressResolverProvider.java @@ -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 Julien Viet */ -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 dnsServers = options.getServers(); if (dnsServers != null && dnsServers.size() > 0) { for (String dnsServer : dnsServers) { diff --git a/src/main/java/io/vertx/core/impl/AddressResolver.java b/src/main/java/io/vertx/core/impl/AddressResolver.java index c710e1d358f..84586bdd000 100644 --- a/src/main/java/io/vertx/core/impl/AddressResolver.java +++ b/src/main/java/io/vertx/core/impl/AddressResolver.java @@ -21,8 +21,7 @@ import io.vertx.core.impl.future.PromiseInternal; import io.vertx.core.impl.logging.Logger; import io.vertx.core.impl.logging.LoggerFactory; -import io.vertx.core.impl.resolver.DnsResolverProvider; -import io.vertx.core.spi.resolver.ResolverProvider; +import io.vertx.core.spi.dns.AddressResolverProvider; import java.io.File; import java.net.InetAddress; @@ -74,10 +73,10 @@ private static Pattern resolvOption(String regex) { private final Vertx vertx; private final AddressResolverGroup resolverGroup; - private final ResolverProvider provider; + private final AddressResolverProvider provider; public AddressResolver(Vertx vertx, AddressResolverOptions options) { - this.provider = ResolverProvider.factory(vertx, options); + this.provider = AddressResolverProvider.factory(vertx, options); this.resolverGroup = provider.resolver(options); this.vertx = vertx; } diff --git a/src/main/java/io/vertx/core/impl/VertxImpl.java b/src/main/java/io/vertx/core/impl/VertxImpl.java index e31fce145fa..3343286560d 100644 --- a/src/main/java/io/vertx/core/impl/VertxImpl.java +++ b/src/main/java/io/vertx/core/impl/VertxImpl.java @@ -45,7 +45,7 @@ import io.vertx.core.impl.future.PromiseInternal; import io.vertx.core.impl.logging.Logger; import io.vertx.core.impl.logging.LoggerFactory; -import io.vertx.core.impl.resolver.DnsResolverProvider; +import io.vertx.core.dns.impl.DnsAddressResolverProvider; import io.vertx.core.spi.transport.Transport; import io.vertx.core.shareddata.SharedData; import io.vertx.core.shareddata.impl.SharedDataImpl; @@ -518,7 +518,7 @@ public DnsClient createDnsClient(DnsClientOptions options) { String host = options.getHost(); int port = options.getPort(); if (host == null || port < 0) { - DnsResolverProvider provider = DnsResolverProvider.create(this, addressResolverOptions); + DnsAddressResolverProvider provider = DnsAddressResolverProvider.create(this, addressResolverOptions); InetSocketAddress address = provider.nameServerAddresses().get(0); // provide the host and port options = new DnsClientOptions(options) diff --git a/src/main/java/io/vertx/core/spi/resolver/ResolverProvider.java b/src/main/java/io/vertx/core/spi/dns/AddressResolverProvider.java similarity index 74% rename from src/main/java/io/vertx/core/spi/resolver/ResolverProvider.java rename to src/main/java/io/vertx/core/spi/dns/AddressResolverProvider.java index 234d2931ec3..14fbca6e77a 100644 --- a/src/main/java/io/vertx/core/spi/resolver/ResolverProvider.java +++ b/src/main/java/io/vertx/core/spi/dns/AddressResolverProvider.java @@ -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 Julien Viet */ -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 resolver(AddressResolverOptions options);