Search in sources :

Example 21 with DeploymentOptions

use of io.vertx.core.DeploymentOptions in project java-chassis by ServiceComb.

the class HighwayClient method init.

public void init(Vertx vertx) throws Exception {
    TcpClientConfig config = createTcpClientConfig();
    DeploymentOptions deployOptions = VertxUtils.createClientDeployOptions(clientMgr, HighwayConfig.getClientThreadCount(), HighwayConfig.getClientConnectionPoolPerThread(), config);
    VertxUtils.blockDeploy(vertx, TcpClientVerticle.class, deployOptions);
}
Also used : DeploymentOptions(io.vertx.core.DeploymentOptions) TcpClientConfig(io.servicecomb.foundation.vertx.client.tcp.TcpClientConfig)

Example 22 with DeploymentOptions

use of io.vertx.core.DeploymentOptions in project java-chassis by ServiceComb.

the class VertxRestTransport method init.

@Override
public boolean init() throws Exception {
    // 部署transport server
    DeploymentOptions options = new DeploymentOptions().setInstances(TransportConfig.getThreadCount());
    setListenAddressWithoutSchema(TransportConfig.getAddress());
    SimpleJsonObject json = new SimpleJsonObject();
    json.put(ENDPOINT_KEY, getEndpoint());
    options.setConfig(json);
    return VertxUtils.blockDeploy(transportVertx, RestServerVerticle.class, options);
}
Also used : DeploymentOptions(io.vertx.core.DeploymentOptions) SimpleJsonObject(io.servicecomb.foundation.vertx.SimpleJsonObject)

Example 23 with DeploymentOptions

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

the class ContextTest method testVerticleUseDifferentOrderedExecutor.

private void testVerticleUseDifferentOrderedExecutor(boolean worker) throws Exception {
    waitFor(2);
    CountDownLatch latch1 = new CountDownLatch(1);
    CountDownLatch latch2 = new CountDownLatch(1);
    vertx.deployVerticle(new AbstractVerticle() {

        @Override
        public void start() throws Exception {
            vertx.executeBlocking(fut -> {
                latch1.countDown();
                try {
                    awaitLatch(latch2);
                    fut.complete();
                } catch (InterruptedException e) {
                    fut.fail(e);
                }
            }, ar -> {
                assertTrue(ar.succeeded());
                complete();
            });
        }
    }, new DeploymentOptions().setWorker(worker));
    awaitLatch(latch1);
    CountDownLatch latch3 = new CountDownLatch(1);
    vertx.deployVerticle(new AbstractVerticle() {

        @Override
        public void start() throws Exception {
            vertx.executeBlocking(fut -> {
                latch3.countDown();
                fut.complete();
            }, ar -> {
                assertTrue(ar.succeeded());
                complete();
            });
        }
    }, new DeploymentOptions().setWorker(worker));
    awaitLatch(latch3);
    latch2.countDown();
    await();
}
Also used : CyclicBarrier(java.util.concurrent.CyclicBarrier) Vertx(io.vertx.core.Vertx) ContextInternal(io.vertx.core.impl.ContextInternal) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.junit.Test) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) Context(io.vertx.core.Context) Future(io.vertx.core.Future) AtomicReference(java.util.concurrent.atomic.AtomicReference) WorkerExecutor(io.vertx.core.WorkerExecutor) CountDownLatch(java.util.concurrent.CountDownLatch) DeploymentOptions(io.vertx.core.DeploymentOptions) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AbstractVerticle(io.vertx.core.AbstractVerticle) TaskQueue(io.vertx.core.impl.TaskQueue) DeploymentOptions(io.vertx.core.DeploymentOptions) CountDownLatch(java.util.concurrent.CountDownLatch) AbstractVerticle(io.vertx.core.AbstractVerticle) BrokenBarrierException(java.util.concurrent.BrokenBarrierException)

Example 24 with DeploymentOptions

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

the class DNSTest method testUseInMultithreadedWorker.

@Test
public void testUseInMultithreadedWorker() throws Exception {
    class MyVerticle extends AbstractVerticle {

        @Override
        public void start() {
            assertIllegalStateException(() -> vertx.createDnsClient(1234, "localhost"));
            testComplete();
        }
    }
    MyVerticle verticle = new MyVerticle();
    vertx.deployVerticle(verticle, new DeploymentOptions().setWorker(true).setMultiThreaded(true));
    await();
}
Also used : DeploymentOptions(io.vertx.core.DeploymentOptions) AbstractVerticle(io.vertx.core.AbstractVerticle) Test(org.junit.Test)

Example 25 with DeploymentOptions

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

the class AbstractVerticleTest method testFieldsSet.

@Test
public void testFieldsSet() {
    JsonObject config = new JsonObject().put("foo", "bar");
    vertx.deployVerticle(verticle, new DeploymentOptions().setConfig(config), onSuccess(res -> {
        assertEquals(res, verticle.getDeploymentID());
        assertEquals(config, verticle.getConfig());
        testComplete();
    }));
    await();
}
Also used : DeploymentOptions(io.vertx.core.DeploymentOptions) AbstractVerticle(io.vertx.core.AbstractVerticle) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test) DeploymentOptions(io.vertx.core.DeploymentOptions) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Aggregations

DeploymentOptions (io.vertx.core.DeploymentOptions)38 Test (org.junit.Test)25 CountDownLatch (java.util.concurrent.CountDownLatch)17 AbstractVerticle (io.vertx.core.AbstractVerticle)15 JsonObject (io.vertx.core.json.JsonObject)10 Context (io.vertx.core.Context)8 Vertx (io.vertx.core.Vertx)7 VertxInternal (io.vertx.core.impl.VertxInternal)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6 AtomicReference (java.util.concurrent.atomic.AtomicReference)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 Future (io.vertx.core.Future)4 HttpClientOptions (io.vertx.core.http.HttpClientOptions)4 CompletableFuture (java.util.concurrent.CompletableFuture)4 Verticle (io.vertx.core.Verticle)3 VertxException (io.vertx.core.VertxException)3 Buffer (io.vertx.core.buffer.Buffer)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 Collections (java.util.Collections)3 TimeUnit (java.util.concurrent.TimeUnit)3