case "queryTimeout": if (member.getValue() instanceof Number) { obj.setQueryTimeout(((Number)member.getValue()).longValue());
@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"); } }
case "queryTimeout": if (member.getValue() instanceof Number) { obj.setQueryTimeout(((Number)member.getValue()).longValue());
assertSame(options, options.setQueryTimeout(queryTimeout)); try { options.setQueryTimeout(0); fail("Should throw exception"); } catch (IllegalArgumentException e) { options.setCacheMaxTimeToLive(AddressResolverOptions.DEFAULT_CACHE_MAX_TIME_TO_LIVE); options.setCacheNegativeTimeToLive(AddressResolverOptions.DEFAULT_CACHE_NEGATIVE_TIME_TO_LIVE); options.setQueryTimeout(AddressResolverOptions.DEFAULT_QUERY_TIMEOUT); options.setMaxQueries(AddressResolverOptions.DEFAULT_MAX_QUERIES); options.setRdFlag(AddressResolverOptions.DEFAULT_RD_FLAG);
@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++) { HttpClientRequest clientRequest = client.getAbs("http://invalid-host-name.foo.bar", resp -> fail()); AtomicBoolean f = new AtomicBoolean(); clientRequest.exceptionHandler(e -> { if (f.compareAndSet(false, true)) { if (failures.incrementAndGet() == poolSize + 1) { testComplete(); } } }); clientRequest.end(); } }); await(); } finally { vertx.close(); System.setProperty("vertx.disableDnsResolver", "false"); } }
"addressResolver.cacheNegativeTimeToLive")); addressResolverOptions .setQueryTimeout(getPositiveIntProperty(configSource, AddressResolverOptions.DEFAULT_QUERY_TIMEOUT, "addressResolver." + tag + ".queryTimeout",
final Vertx vertx() { final VertxOptions options = new VertxOptions() .setWarningExceptionTime(1500000000) .setAddressResolverOptions(new AddressResolverOptions() .setCacheNegativeTimeToLive(0) // discard failed DNS lookup results immediately .setCacheMaxTimeToLive(0) // support DNS based service resolution .setRotateServers(true) .setQueryTimeout(DEFAULT_ADDRESS_RESOLUTION_TIMEOUT_MILLIS)); return Vertx.vertx(options); }
/** * Gets the singleton Vert.x instance to be used by Hono. * * @return the instance. */ @Bean public Vertx vertx() { final VertxOptions options = new VertxOptions() .setWarningExceptionTime(1500000000) .setAddressResolverOptions(new AddressResolverOptions() .setCacheNegativeTimeToLive(0) // discard failed DNS lookup results immediately .setCacheMaxTimeToLive(0) // support DNS based service resolution .setQueryTimeout(1000)); vertxProperties().configureVertx(options); return Vertx.vertx(options); }
/** * Exposes a Vert.x instance as a Spring bean. * * @return The Vert.x instance. */ @Bean public Vertx vertx() { final VertxOptions options = new VertxOptions() .setWarningExceptionTime(1500000000) .setAddressResolverOptions(new AddressResolverOptions() .setCacheNegativeTimeToLive(0) // discard failed DNS lookup results immediately .setCacheMaxTimeToLive(0) // support DNS based service resolution .setQueryTimeout(1000)); vertxProperties().configureVertx(options); return Vertx.vertx(options); }
assertSame(options, options.setQueryTimeout(queryTimeout)); try { options.setQueryTimeout(0); fail("Should throw exception"); } catch (IllegalArgumentException e) { options.setCacheMaxTimeToLive(AddressResolverOptions.DEFAULT_CACHE_MAX_TIME_TO_LIVE); options.setCacheNegativeTimeToLive(AddressResolverOptions.DEFAULT_CACHE_NEGATIVE_TIME_TO_LIVE); options.setQueryTimeout(AddressResolverOptions.DEFAULT_QUERY_TIMEOUT); options.setMaxQueries(AddressResolverOptions.DEFAULT_MAX_QUERIES); options.setRdFlag(AddressResolverOptions.DEFAULT_RD_FLAG);
/** * Configures the Vert.x options based on this object's property values. * * @param options The options to configure. * @return The (updated) options. */ public VertxOptions configureVertx(final VertxOptions options) { options.setPreferNativeTransport(this.preferNative); if (this.enableMetrics) { options.setMetricsOptions(new MetricsOptions().setEnabled(true)); } options.setMaxEventLoopExecuteTime(maxEventLoopExecuteTimeMillis * 1000000L); options.setWarningExceptionTime(maxEventLoopExecuteTimeMillis * 1500000L); options.setAddressResolverOptions(new AddressResolverOptions() .setCacheNegativeTimeToLive(0) // discard failed DNS lookup results immediately .setCacheMaxTimeToLive(0) // support DNS based service resolution .setQueryTimeout(dnsQueryTimeout)); return options; }
"addressResolver.cacheNegativeTimeToLive")); addressResolverOptions .setQueryTimeout(getPositiveIntProperty(configSource, AddressResolverOptions.DEFAULT_QUERY_TIMEOUT, "addressResolver." + tag + ".queryTimeout",