本文整理了Java中io.vertx.core.VertxOptions.setAddressResolverOptions()
方法的一些代码示例,展示了VertxOptions.setAddressResolverOptions()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。VertxOptions.setAddressResolverOptions()
方法的具体详情如下:
包路径:io.vertx.core.VertxOptions
类名称:VertxOptions
方法名:setAddressResolverOptions
[英]Sets the address resolver configuration to configure resolving DNS servers, cache TTL, etc...
[中]设置地址解析程序配置,以配置解析DNS服务器、缓存TTL等。。。
代码示例来源:origin: eclipse-vertx/vert.x
case "addressResolverOptions":
if (member.getValue() instanceof JsonObject) {
obj.setAddressResolverOptions(new io.vertx.core.dns.AddressResolverOptions((JsonObject)member.getValue()));
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testResolveFromFile() {
File f = new File(new File(new File(new File("src"), "test"), "resources"), "hosts_config.txt");
VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsPath(f.getAbsolutePath())));
vertx.resolveAddress("server.net", onSuccess(addr -> {
assertEquals("192.168.0.15", addr.getHostAddress());
assertEquals("server.net", addr.getHostName());
testComplete();
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(
new AddressResolverOptions().
addServer(dnsServerAddress.getAddress().getHostAddress() + ":" + dnsServerAddress.getPort()).
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testNetSearchDomain() throws Exception {
Map<String, String> records = new HashMap<>();
records.put("host1.foo.com", "127.0.0.1");
dnsServer.testResolveA(records);
vertx.close();
vertx = vertx(new VertxOptions().setAddressResolverOptions(
new AddressResolverOptions().
setHostsValue(Buffer.buffer()).
setNdots(1).
addServer(dnsServerAddress.getAddress().getHostAddress() + ":" + dnsServerAddress.getPort()).
setOptResourceEnabled(false).
addSearchDomain("foo.com")
));
testNet("host1");
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testSearchDomainWithNdots2() throws Exception {
Map<String, String> records = new HashMap<>();
records.put("host1.sub.foo.com", "127.0.0.1");
records.put("host2.sub.foo.com", "127.0.0.2");
records.put("host2.sub", "127.0.0.3");
dnsServer.testResolveA(records);
VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(
new AddressResolverOptions().
addServer(dnsServerAddress.getAddress().getHostAddress() + ":" + dnsServerAddress.getPort()).
setOptResourceEnabled(false).
addSearchDomain("foo.com").
setNdots(2)
));
CountDownLatch latch1 = new CountDownLatch(1);
vertx.resolveAddress("host1.sub", onSuccess(resolved -> {
assertEquals("127.0.0.1", resolved.getHostAddress());
latch1.countDown();
}));
awaitLatch(latch1);
// "host2.sub" is resolved with the foo.com search domain as ndots = 2
CountDownLatch latch2 = new CountDownLatch(1);
vertx.resolveAddress("host2.sub", onSuccess(resolved -> {
assertEquals("127.0.0.2", resolved.getHostAddress());
latch2.countDown();
}));
awaitLatch(latch2);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testResolveFromBuffer() {
VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsValue(Buffer.buffer("192.168.0.15 server.net"))));
vertx.resolveAddress("server.net", onSuccess(addr -> {
assertEquals("192.168.0.15", addr.getHostAddress());
assertEquals("server.net", addr.getHostName());
testComplete();
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testSearchDomainWithNdots0() throws Exception {
Map<String, String> records = new HashMap<>();
records.put("host1", "127.0.0.2");
records.put("host1.foo.com", "127.0.0.3");
dnsServer.testResolveA(records);
VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(
new AddressResolverOptions().
addServer(dnsServerAddress.getAddress().getHostAddress() + ":" + dnsServerAddress.getPort()).
setOptResourceEnabled(false).
addSearchDomain("foo.com").
setNdots(0)
));
// "host1" resolves directly as ndots = 0
CountDownLatch latch1 = new CountDownLatch(1);
vertx.resolveAddress("host1", onSuccess(resolved -> {
assertEquals("127.0.0.2", resolved.getHostAddress());
latch1.countDown();
}));
awaitLatch(latch1);
// "host1.foo.com" resolves to host1.foo.com
CountDownLatch latch2 = new CountDownLatch(1);
vertx.resolveAddress("host1.foo.com", onSuccess(resolved -> {
assertEquals("127.0.0.3", resolved.getHostAddress());
latch2.countDown();
}));
awaitLatch(latch2);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testInvalidHostsConfig() {
try {
AddressResolverOptions options = new AddressResolverOptions().setHostsPath("whatever.txt");
vertx(new VertxOptions().setAddressResolverOptions(options));
fail();
} catch (VertxException ignore) {
}
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testClientSynchronousConnectFailures() {
System.setProperty("vertx.disableDnsResolver", "true");
Vertx vertx = Vertx.vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setQueryTimeout(100)));
try {
int poolSize = 2;
HttpClient client = vertx.createHttpClient(new HttpClientOptions().setMaxPoolSize(poolSize));
AtomicInteger failures = new AtomicInteger();
vertx.runOnContext(v -> {
for (int i = 0; i < (poolSize + 1); i++) {
AtomicBoolean f = new AtomicBoolean();
client.getAbs("http://invalid-host-name.foo.bar", onFailure(resp -> {
if (f.compareAndSet(false, true)) {
if (failures.incrementAndGet() == poolSize + 1) {
testComplete();
}
}
})).end();
}
});
await();
} finally {
vertx.close();
System.setProperty("vertx.disableDnsResolver", "false");
}
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testCaseInsensitiveResolveFromHosts() {
VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsPath("hosts_config.txt")));
vertx.resolveAddress("SERVER.NET", onSuccess(addr -> {
assertEquals("192.168.0.15", addr.getHostAddress());
assertEquals("server.net", addr.getHostName());
testComplete();
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testResolveFromClasspath() {
VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsPath("hosts_config.txt")));
vertx.resolveAddress("server.net", onSuccess(addr -> {
assertEquals("192.168.0.15", addr.getHostAddress());
assertEquals("server.net", addr.getHostName());
testComplete();
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(
new AddressResolverOptions().
setHostsValue(Buffer.buffer()).
代码示例来源:origin: eclipse-vertx/vert.x
VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(
new AddressResolverOptions().
addServer(dnsServerAddress.getAddress().getHostAddress() + ":" + dnsServerAddress.getPort()).
代码示例来源:origin: io.vertx/vertx-core
@Test
public void testResolveFromFile() {
File f = new File(new File(new File(new File("src"), "test"), "resources"), "hosts_config.txt");
VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsPath(f.getAbsolutePath())));
vertx.resolveAddress("server.net", onSuccess(addr -> {
assertEquals("192.168.0.15", addr.getHostAddress());
assertEquals("server.net", addr.getHostName());
testComplete();
}));
await();
}
代码示例来源:origin: io.vertx/vertx-core
@Test
public void testNetSearchDomain() throws Exception {
Map<String, String> records = new HashMap<>();
records.put("host1.foo.com", "127.0.0.1");
dnsServer.testResolveA(records);
vertx.close();
vertx = vertx(new VertxOptions().setAddressResolverOptions(
new AddressResolverOptions().
setHostsValue(Buffer.buffer()).
setNdots(1).
addServer(dnsServerAddress.getAddress().getHostAddress() + ":" + dnsServerAddress.getPort()).
setOptResourceEnabled(false).
addSearchDomain("foo.com")
));
testNet("host1");
}
代码示例来源:origin: apache/servicecomb-java-chassis
private void deployConfigClient() throws InterruptedException {
VertxOptions vertxOptions = new VertxOptions();
vertxOptions.setAddressResolverOptions(AddressResolverConfig.getAddressResover(SSL_KEY,
ConfigCenterConfig.INSTANCE.getConcurrentCompositeConfiguration()));
Vertx vertx = VertxUtils.getOrCreateVertxByName("config-center", vertxOptions);
HttpClientOptions httpClientOptions = createHttpClientOptions();
clientMgr = new ClientPoolManager<>(vertx, new HttpClientPoolFactory(httpClientOptions));
DeploymentOptions deployOptions = VertxUtils.createClientDeployOptions(clientMgr, 1);
VertxUtils.blockDeploy(vertx, ClientVerticle.class, deployOptions);
}
代码示例来源:origin: io.vertx/vertx-core
@Test
public void testResolveFromBuffer() {
VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsValue(Buffer.buffer("192.168.0.15 server.net"))));
vertx.resolveAddress("server.net", onSuccess(addr -> {
assertEquals("192.168.0.15", addr.getHostAddress());
assertEquals("server.net", addr.getHostName());
testComplete();
}));
await();
}
代码示例来源:origin: io.vertx/vertx-core
@Test
public void testResolveFromClasspath() {
VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsPath("hosts_config.txt")));
vertx.resolveAddress("server.net", onSuccess(addr -> {
assertEquals("192.168.0.15", addr.getHostAddress());
assertEquals("server.net", addr.getHostName());
testComplete();
}));
await();
}
代码示例来源:origin: io.vertx/vertx-core
@Test
public void testCaseInsensitiveResolveFromHosts() {
VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsPath("hosts_config.txt")));
vertx.resolveAddress("SERVER.NET", onSuccess(addr -> {
assertEquals("192.168.0.15", addr.getHostAddress());
assertEquals("server.net", addr.getHostName());
testComplete();
}));
await();
}
代码示例来源:origin: io.vertx/vertx-core
@Test
public void testInvalidHostsConfig() {
try {
AddressResolverOptions options = new AddressResolverOptions().setHostsPath("whatever.txt");
vertx(new VertxOptions().setAddressResolverOptions(options));
fail();
} catch (VertxException ignore) {
}
}
内容来源于网络,如有侵权,请联系作者删除!