case "warningExceptionTime": if (member.getValue() instanceof Number) { obj.setWarningExceptionTime(((Number)member.getValue()).longValue());
/** * 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(addressResolverOptions()); return Vertx.vertx(options); }
@Test public void testBlockCheckExceptionTimeLimit() throws Exception { Verticle verticle = new AbstractVerticle() { @Override public void start() throws InterruptedException { Thread.sleep(3000); testComplete(); } }; // set warning threshold to 1s and the exception threshold as well long maxEventLoopExecuteTime = 1; TimeUnit maxEventLoopExecuteTimeUnit = SECONDS; VertxOptions vertxOptions = new VertxOptions(); vertxOptions.setMaxEventLoopExecuteTime(maxEventLoopExecuteTime); vertxOptions.setMaxEventLoopExecuteTimeUnit(maxEventLoopExecuteTimeUnit); vertxOptions.setWarningExceptionTime(maxEventLoopExecuteTime); vertxOptions.setWarningExceptionTimeUnit(maxEventLoopExecuteTimeUnit); Vertx newVertx = vertx(vertxOptions); newVertx.deployVerticle(verticle); await(); blockedThreadWarning.expectMessage("vert.x-eventloop-thread", maxEventLoopExecuteTime, maxEventLoopExecuteTimeUnit); }
@Override public void beforeStartingVertx(VertxOptions options) { super.beforeStartingVertx(options); System.setProperty(LOGGER_DELEGATE_FACTORY_CLASS_NAME, SLF4JLogDelegateFactory.class.getName()); options.setWarningExceptionTime( config.getLong(VERTX_OPTIONS_PROP_PREFIX + "warningExceptionTime", options.getWarningExceptionTime()) ); }
@Test public void testBlockCheckExecuteBlocking() throws Exception { Verticle verticle = new AbstractVerticle() { @Override public void start() throws InterruptedException { vertx.executeBlocking(fut -> { try { Thread.sleep(3000); } catch (InterruptedException e) { fail(); } testComplete(); }, ar -> {}); } }; // set warning threshold to 1s and the exception threshold as well long maxWorkerExecuteTime = 1; TimeUnit maxWorkerExecuteTimeUnit = SECONDS; VertxOptions vertxOptions = new VertxOptions(); vertxOptions.setMaxWorkerExecuteTime(maxWorkerExecuteTime); vertxOptions.setMaxWorkerExecuteTimeUnit(maxWorkerExecuteTimeUnit); vertxOptions.setWarningExceptionTime(maxWorkerExecuteTime); vertxOptions.setWarningExceptionTimeUnit(maxWorkerExecuteTimeUnit); Vertx newVertx = vertx(vertxOptions); newVertx.deployVerticle(verticle); await(); blockedThreadWarning.expectMessage("vert.x-worker-thread", maxWorkerExecuteTime, maxWorkerExecuteTimeUnit); } }
/** * Creates the VertxOptions by checking System variables BlockedThreadCheckInterval and WarningExceptionTime * * @deprecated Use {@link BtVertxTestBase#getOptions()} */ @Deprecated public static VertxOptions getOptions() { VertxOptions options = new VertxOptions(); String blockedThreadCheckInterval = System.getProperty("BlockedThreadCheckInterval"); if (blockedThreadCheckInterval != null) { logger.info("setting setBlockedThreadCheckInterval to " + blockedThreadCheckInterval); options.setBlockedThreadCheckInterval(Long.parseLong(blockedThreadCheckInterval)); } String warningExceptionTime = System.getProperty("WarningExceptionTime"); if (warningExceptionTime != null) { logger.info("setting setWarningExceptionTime to " + warningExceptionTime); options.setWarningExceptionTime(Long.parseLong(warningExceptionTime)); } return options; }
@Test public void testBlockCheckWorker() throws Exception { Verticle verticle = new AbstractVerticle() { @Override public void start() throws InterruptedException { Thread.sleep(3000); testComplete(); } }; // set warning threshold to 1s and the exception threshold as well long maxWorkerExecuteTime = 1; TimeUnit maxWorkerExecuteTimeUnit = SECONDS; VertxOptions vertxOptions = new VertxOptions(); vertxOptions.setMaxWorkerExecuteTime(maxWorkerExecuteTime); vertxOptions.setMaxWorkerExecuteTimeUnit(maxWorkerExecuteTimeUnit); vertxOptions.setWarningExceptionTime(maxWorkerExecuteTime); vertxOptions.setWarningExceptionTimeUnit(maxWorkerExecuteTimeUnit); Vertx newVertx = vertx(vertxOptions); DeploymentOptions deploymentOptions = new DeploymentOptions(); deploymentOptions.setWorker(true); newVertx.deployVerticle(verticle, deploymentOptions); await(); blockedThreadWarning.expectMessage("vert.x-worker-thread", maxWorkerExecuteTime, maxWorkerExecuteTimeUnit); }
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); }
new MetricsOptions(). setEnabled(metricsEnabled)); options.setWarningExceptionTime(warningExceptionTime); options.setMaxEventLoopExecuteTimeUnit(maxEventLoopExecuteTimeUnit); options.setMaxWorkerExecuteTimeUnit(maxWorkerExecuteTimeUnit);
/** * 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); }
case "warningExceptionTime": if (member.getValue() instanceof Number) { obj.setWarningExceptionTime(((Number)member.getValue()).longValue());
/** * 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); }
@Test public void testBlockCheckExceptionTimeLimit() throws Exception { Verticle verticle = new AbstractVerticle() { @Override public void start() throws InterruptedException { Thread.sleep(3000); testComplete(); } }; // set warning threshold to 1s and the exception threshold as well long maxEventLoopExecuteTime = 1; TimeUnit maxEventLoopExecuteTimeUnit = SECONDS; VertxOptions vertxOptions = new VertxOptions(); vertxOptions.setMaxEventLoopExecuteTime(maxEventLoopExecuteTime); vertxOptions.setMaxEventLoopExecuteTimeUnit(maxEventLoopExecuteTimeUnit); vertxOptions.setWarningExceptionTime(maxEventLoopExecuteTime); vertxOptions.setWarningExceptionTimeUnit(maxEventLoopExecuteTimeUnit); Vertx newVertx = vertx(vertxOptions); newVertx.deployVerticle(verticle); await(); blockedThreadWarning.expectMessage("vert.x-eventloop-thread", maxEventLoopExecuteTime, maxEventLoopExecuteTimeUnit); }
/** * Creates the VertxOptions by checking System variables BlockedThreadCheckInterval and WarningExceptionTime */ public static VertxOptions getVertxOptions() { VertxOptions options = new VertxOptions(); String blockedThreadCheckInterval = System.getProperty("BlockedThreadCheckInterval"); if (blockedThreadCheckInterval != null) { LOGGER.info("setting setBlockedThreadCheckInterval to " + blockedThreadCheckInterval); options.setBlockedThreadCheckInterval(Long.parseLong(blockedThreadCheckInterval)); } String warningExceptionTime = System.getProperty("WarningExceptionTime"); if (warningExceptionTime != null) { LOGGER.info("setting setWarningExceptionTime to " + warningExceptionTime); options.setWarningExceptionTime(Long.parseLong(warningExceptionTime)); } return options; }
@Test public void testBlockCheckExecuteBlocking() throws Exception { Verticle verticle = new AbstractVerticle() { @Override public void start() throws InterruptedException { vertx.executeBlocking(fut -> { try { Thread.sleep(3000); } catch (InterruptedException e) { fail(); } testComplete(); }, ar -> {}); } }; // set warning threshold to 1s and the exception threshold as well long maxWorkerExecuteTime = 1; TimeUnit maxWorkerExecuteTimeUnit = SECONDS; VertxOptions vertxOptions = new VertxOptions(); vertxOptions.setMaxWorkerExecuteTime(maxWorkerExecuteTime); vertxOptions.setMaxWorkerExecuteTimeUnit(maxWorkerExecuteTimeUnit); vertxOptions.setWarningExceptionTime(maxWorkerExecuteTime); vertxOptions.setWarningExceptionTimeUnit(maxWorkerExecuteTimeUnit); Vertx newVertx = vertx(vertxOptions); newVertx.deployVerticle(verticle); await(); blockedThreadWarning.expectMessage("vert.x-worker-thread", maxWorkerExecuteTime, maxWorkerExecuteTimeUnit); } }
@ConditionalOnMissingBean(VertxOptions.class) @Bean public VertxOptions vertxOptions(EventBusOptions eventBusOptions, MetricsOptions metricsOptions) { return new VertxOptions() .setBlockedThreadCheckInterval(properties.getBlockedThreadCheckInterval()) .setEventLoopPoolSize(properties.getEventLoopPoolSize()) .setWorkerPoolSize(properties.getWorkerPoolSize()) .setInternalBlockingPoolSize(properties.getInternalBlockingPoolSize()) .setQuorumSize(properties.getQuorumSize()) .setMaxEventLoopExecuteTime(properties.getMaxEventLoopExecuteTime()) .setHAGroup(properties.getHaGroup()) .setMaxWorkerExecuteTime(properties.getMaxWorkerExecuteTime()) .setWarningExceptionTime(properties.getWarningExceptionTime()) .setFileResolverCachingEnabled(properties.isFileResolverCachingEnabled()) .setHAEnabled(properties.isHaEnabled()) .setEventBusOptions(eventBusOptions) .setMetricsOptions(metricsOptions); }
@Test public void testBlockCheckWorker() throws Exception { Verticle verticle = new AbstractVerticle() { @Override public void start() throws InterruptedException { Thread.sleep(3000); testComplete(); } }; // set warning threshold to 1s and the exception threshold as well long maxWorkerExecuteTime = 1; TimeUnit maxWorkerExecuteTimeUnit = SECONDS; VertxOptions vertxOptions = new VertxOptions(); vertxOptions.setMaxWorkerExecuteTime(maxWorkerExecuteTime); vertxOptions.setMaxWorkerExecuteTimeUnit(maxWorkerExecuteTimeUnit); vertxOptions.setWarningExceptionTime(maxWorkerExecuteTime); vertxOptions.setWarningExceptionTimeUnit(maxWorkerExecuteTimeUnit); Vertx newVertx = vertx(vertxOptions); DeploymentOptions deploymentOptions = new DeploymentOptions(); deploymentOptions.setWorker(true); newVertx.deployVerticle(verticle, deploymentOptions); await(); blockedThreadWarning.expectMessage("vert.x-worker-thread", maxWorkerExecuteTime, maxWorkerExecuteTimeUnit); }
options.setWarningExceptionTime(-1); fail("Should throw exception"); } catch (IllegalArgumentException e) { assertEquals(options, options.setWarningExceptionTime(1000000000l)); assertEquals(1000000000l, options.getWarningExceptionTime());
new MetricsOptions(). setEnabled(metricsEnabled)); options.setWarningExceptionTime(warningExceptionTime); options.setMaxEventLoopExecuteTimeUnit(maxEventLoopExecuteTimeUnit); options.setMaxWorkerExecuteTimeUnit(maxWorkerExecuteTimeUnit);
options.setWarningExceptionTime(-1); fail("Should throw exception"); } catch (IllegalArgumentException e) { assertEquals(options, options.setWarningExceptionTime(1000000000l)); assertEquals(1000000000l, options.getWarningExceptionTime());