Search in sources :

Example 1 with Verticle

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

the class BlockedThreadCheckerTest method testBlockCheckDefault.

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

        @Override
        public void start() throws InterruptedException {
            Thread.sleep(6000);
            testComplete();
        }
    };
    vertx.deployVerticle(verticle);
    await();
}
Also used : AbstractVerticle(io.vertx.core.AbstractVerticle) Verticle(io.vertx.core.Verticle) AbstractVerticle(io.vertx.core.AbstractVerticle) Test(org.junit.Test)

Example 2 with Verticle

use of io.vertx.core.Verticle 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 3 with Verticle

use of io.vertx.core.Verticle 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 4 with Verticle

use of io.vertx.core.Verticle 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 5 with Verticle

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

the class JavaVerticleFactory method createVerticle.

@Override
public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception {
    verticleName = VerticleFactory.removePrefix(verticleName);
    Class clazz;
    if (verticleName.endsWith(".java")) {
        CompilingClassLoader compilingLoader = new CompilingClassLoader(classLoader, verticleName);
        String className = compilingLoader.resolveMainClassName();
        clazz = compilingLoader.loadClass(className);
    } else {
        clazz = classLoader.loadClass(verticleName);
    }
    return (Verticle) clazz.newInstance();
}
Also used : Verticle(io.vertx.core.Verticle) CompilingClassLoader(io.vertx.core.impl.verticle.CompilingClassLoader)

Aggregations

Verticle (io.vertx.core.Verticle)6 AbstractVerticle (io.vertx.core.AbstractVerticle)5 Test (org.junit.Test)5 Vertx (io.vertx.core.Vertx)3 VertxOptions (io.vertx.core.VertxOptions)3 DeploymentOptions (io.vertx.core.DeploymentOptions)2 CharsetUtil (io.netty.util.CharsetUtil)1 Context (io.vertx.core.Context)1 Future (io.vertx.core.Future)1 Buffer (io.vertx.core.buffer.Buffer)1 DeliveryOptions (io.vertx.core.eventbus.DeliveryOptions)1 EventBus (io.vertx.core.eventbus.EventBus)1 MessageCodec (io.vertx.core.eventbus.MessageCodec)1 MessageConsumer (io.vertx.core.eventbus.MessageConsumer)1 ReplyException (io.vertx.core.eventbus.ReplyException)1 ReplyFailure (io.vertx.core.eventbus.ReplyFailure)1 CompilingClassLoader (io.vertx.core.impl.verticle.CompilingClassLoader)1 JsonArray (io.vertx.core.json.JsonArray)1 JsonObject (io.vertx.core.json.JsonObject)1 CountDownLatch (java.util.concurrent.CountDownLatch)1