Search in sources :

Example 16 with VertxOptions

use of io.vertx.core.VertxOptions in project vert.x by eclipse.

the class BlockedThreadCheckerTest method testBlockCheckWorker.

@Test
public void testBlockCheckWorker() throws Exception {
    Verticle verticle = new AbstractVerticle() {

        @Override
        public void start() throws InterruptedException {
            Thread.sleep(2000);
            testComplete();
        }
    };
    // set warning threshold to 1s and the exception threshold as well
    VertxOptions vertxOptions = new VertxOptions();
    vertxOptions.setMaxWorkerExecuteTime(1000000000);
    vertxOptions.setWarningExceptionTime(1000000000);
    Vertx newVertx = vertx(vertxOptions);
    DeploymentOptions deploymentOptions = new DeploymentOptions();
    deploymentOptions.setWorker(true);
    newVertx.deployVerticle(verticle, deploymentOptions);
    await();
}
Also used : AbstractVerticle(io.vertx.core.AbstractVerticle) Verticle(io.vertx.core.Verticle) DeploymentOptions(io.vertx.core.DeploymentOptions) Vertx(io.vertx.core.Vertx) AbstractVerticle(io.vertx.core.AbstractVerticle) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test)

Example 17 with VertxOptions

use of io.vertx.core.VertxOptions in project vert.x by eclipse.

the class BlockedThreadCheckerTest method testBlockCheckExecuteBlocking.

@Test
public void testBlockCheckExecuteBlocking() throws Exception {
    Verticle verticle = new AbstractVerticle() {

        @Override
        public void start() throws InterruptedException {
            vertx.executeBlocking(fut -> {
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    fail();
                }
                testComplete();
            }, ar -> {
            });
        }
    };
    // set warning threshold to 1s and the exception threshold as well
    VertxOptions vertxOptions = new VertxOptions();
    vertxOptions.setMaxWorkerExecuteTime(1000000000);
    vertxOptions.setWarningExceptionTime(1000000000);
    Vertx newVertx = vertx(vertxOptions);
    newVertx.deployVerticle(verticle);
    await();
}
Also used : AbstractVerticle(io.vertx.core.AbstractVerticle) Verticle(io.vertx.core.Verticle) Vertx(io.vertx.core.Vertx) AbstractVerticle(io.vertx.core.AbstractVerticle) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test)

Example 18 with VertxOptions

use of io.vertx.core.VertxOptions in project vert.x by eclipse.

the class BlockedThreadCheckerTest method testBlockCheckExceptionTimeLimit.

@Test
public void testBlockCheckExceptionTimeLimit() throws Exception {
    Verticle verticle = new AbstractVerticle() {

        @Override
        public void start() throws InterruptedException {
            Thread.sleep(2000);
            testComplete();
        }
    };
    // set warning threshold to 1s and the exception threshold as well
    VertxOptions vertxOptions = new VertxOptions();
    vertxOptions.setMaxEventLoopExecuteTime(1000000000);
    vertxOptions.setWarningExceptionTime(1000000000);
    Vertx newVertx = vertx(vertxOptions);
    newVertx.deployVerticle(verticle);
    await();
}
Also used : AbstractVerticle(io.vertx.core.AbstractVerticle) Verticle(io.vertx.core.Verticle) Vertx(io.vertx.core.Vertx) AbstractVerticle(io.vertx.core.AbstractVerticle) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test)

Example 19 with VertxOptions

use of io.vertx.core.VertxOptions in project vert.x by eclipse.

the class MetricsOptionsTest method testMetricsFromServiceLoader.

@Test
public void testMetricsFromServiceLoader() {
    vertx.close();
    VertxOptions options = new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true));
    vertx = createVertxLoadingMetricsFromMetaInf(options, "io.vertx.test.fakemetrics.FakeMetricsFactory");
    VertxMetrics metrics = ((VertxInternal) vertx).metricsSPI();
    assertNotNull(metrics);
    assertTrue(metrics instanceof FakeVertxMetrics);
}
Also used : MetricsOptions(io.vertx.core.metrics.MetricsOptions) FakeVertxMetrics(io.vertx.test.fakemetrics.FakeVertxMetrics) DummyVertxMetrics(io.vertx.core.metrics.impl.DummyVertxMetrics) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) VertxInternal(io.vertx.core.impl.VertxInternal) FakeVertxMetrics(io.vertx.test.fakemetrics.FakeVertxMetrics) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test)

Example 20 with VertxOptions

use of io.vertx.core.VertxOptions in project vert.x by eclipse.

the class MetricsOptionsTest method testSetMetricsInstanceTakesPrecedenceOverServiceLoader.

@Test
public void testSetMetricsInstanceTakesPrecedenceOverServiceLoader() {
    DummyVertxMetrics metrics = DummyVertxMetrics.INSTANCE;
    vertx.close();
    VertxOptions options = new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true).setFactory(new SimpleVertxMetricsFactory<>(metrics)));
    vertx = createVertxLoadingMetricsFromMetaInf(options, "io.vertx.test.fakemetrics.FakeMetricsFactory");
    assertSame(metrics, ((VertxInternal) vertx).metricsSPI());
}
Also used : MetricsOptions(io.vertx.core.metrics.MetricsOptions) DummyVertxMetrics(io.vertx.core.metrics.impl.DummyVertxMetrics) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test)

Aggregations

VertxOptions (io.vertx.core.VertxOptions)38 Test (org.junit.Test)30 VertxInternal (io.vertx.core.impl.VertxInternal)12 JsonObject (io.vertx.core.json.JsonObject)12 AddressResolverOptions (io.vertx.core.dns.AddressResolverOptions)11 CountDownLatch (java.util.concurrent.CountDownLatch)11 Vertx (io.vertx.core.Vertx)9 VertxException (io.vertx.core.VertxException)9 NetClient (io.vertx.core.net.NetClient)9 NetServer (io.vertx.core.net.NetServer)9 NetServerOptions (io.vertx.core.net.NetServerOptions)9 InetAddress (java.net.InetAddress)9 HashMap (java.util.HashMap)9 CompletableFuture (java.util.concurrent.CompletableFuture)9 TimeUnit (java.util.concurrent.TimeUnit)9 AtomicReference (java.util.concurrent.atomic.AtomicReference)9 Bootstrap (io.netty.bootstrap.Bootstrap)8 Channel (io.netty.channel.Channel)8 ChannelFuture (io.netty.channel.ChannelFuture)8 ChannelInitializer (io.netty.channel.ChannelInitializer)8