@Test public void testBlockCheckDefault() throws Exception { Verticle verticle = new AbstractVerticle() { @Override public void start() throws InterruptedException { Thread.sleep(6000); testComplete(); } }; vertx.deployVerticle(verticle); await(); blockedThreadWarning.expectMessage("vert.x-eventloop-thread", VertxOptions.DEFAULT_MAX_EVENT_LOOP_EXECUTE_TIME, VertxOptions.DEFAULT_MAX_EVENT_LOOP_EXECUTE_TIME_UNIT); }
@Test public void testMaxExecuteWorkerTime() throws Exception { String poolName = TestUtils.randomAlphaString(10); long maxWorkerExecuteTime = NANOSECONDS.convert(3, SECONDS); DeploymentOptions deploymentOptions = new DeploymentOptions() .setWorkerPoolName(poolName) .setMaxWorkerExecuteTime(maxWorkerExecuteTime); vertx.deployVerticle(new AbstractVerticle() { @Override public void start(Future<Void> startFuture) throws Exception { vertx.executeBlocking(fut -> { try { SECONDS.sleep(5); fut.complete(); } catch (InterruptedException e) { fut.fail(e); } }, startFuture); } }, deploymentOptions, onSuccess(did -> { testComplete(); })); await(); blockedThreadWarning.expectMessage(poolName, maxWorkerExecuteTime, NANOSECONDS); }
@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); }
@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); } }
@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); }
@Test public void testBlockCheckDefault() throws Exception { Verticle verticle = new AbstractVerticle() { @Override public void start() throws InterruptedException { Thread.sleep(6000); testComplete(); } }; vertx.deployVerticle(verticle); await(); blockedThreadWarning.expectMessage("vert.x-eventloop-thread", VertxOptions.DEFAULT_MAX_EVENT_LOOP_EXECUTE_TIME, VertxOptions.DEFAULT_MAX_EVENT_LOOP_EXECUTE_TIME_UNIT); }
@Test public void testMaxExecuteWorkerTime() throws Exception { String poolName = TestUtils.randomAlphaString(10); long maxWorkerExecuteTime = NANOSECONDS.convert(3, SECONDS); DeploymentOptions deploymentOptions = new DeploymentOptions() .setWorkerPoolName(poolName) .setMaxWorkerExecuteTime(maxWorkerExecuteTime); vertx.deployVerticle(new AbstractVerticle() { @Override public void start(Future<Void> startFuture) throws Exception { vertx.executeBlocking(fut -> { try { SECONDS.sleep(5); fut.complete(); } catch (InterruptedException e) { fut.fail(e); } }, startFuture); } }, deploymentOptions, onSuccess(did -> { testComplete(); })); await(); blockedThreadWarning.expectMessage(poolName, maxWorkerExecuteTime, NANOSECONDS); }
@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); }
@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); } }
@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); }