Search in sources :

Example 1 with Transport

use of io.vertx.core.net.impl.transport.Transport in project vert.x by eclipse.

the class VertxStartFailureTest method failStart.

private Throwable failStart(VertxOptions options) throws Exception {
    List<EventLoopGroup> loops = new ArrayList<>();
    CountDownLatch latch = new CountDownLatch(1);
    Transport transport = new Transport() {

        @Override
        public EventLoopGroup eventLoopGroup(int type, int nThreads, ThreadFactory threadFactory, int ioRatio) {
            EventLoopGroup eventLoop = super.eventLoopGroup(type, nThreads, threadFactory, ioRatio);
            loops.add(eventLoop);
            return eventLoop;
        }
    };
    AtomicReference<AsyncResult<Vertx>> resultRef = new AtomicReference<>();
    new VertxBuilder(options).init().transport(transport).clusteredVertx(ar -> {
        resultRef.set(ar);
        latch.countDown();
    });
    awaitLatch(latch);
    assertFalse(resultRef.get() == null);
    assertTrue(resultRef.get().failed());
    loops.forEach(loop -> {
        waitUntil(loop::isShutdown);
    });
    return resultRef.get().cause();
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) EventLoopGroup(io.netty.channel.EventLoopGroup) ArrayList(java.util.ArrayList) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) Transport(io.vertx.core.net.impl.transport.Transport) VertxBuilder(io.vertx.core.impl.VertxBuilder)

Example 2 with Transport

use of io.vertx.core.net.impl.transport.Transport in project vert.x by eclipse.

the class VertxFactoryTest method testFactoryTransportOverridesDefault.

@Test
public void testFactoryTransportOverridesDefault() {
    VertxBuilder factory = new VertxBuilder();
    // JDK transport
    Transport override = new Transport() {
    };
    factory.transport(override);
    factory.init();
    Vertx vertx = factory.vertx();
    assertSame(override, ((VertxInternal) vertx).transport());
}
Also used : Transport(io.vertx.core.net.impl.transport.Transport) Vertx(io.vertx.core.Vertx) Test(org.junit.Test)

Aggregations

Transport (io.vertx.core.net.impl.transport.Transport)2 EventLoopGroup (io.netty.channel.EventLoopGroup)1 Vertx (io.vertx.core.Vertx)1 VertxBuilder (io.vertx.core.impl.VertxBuilder)1 ArrayList (java.util.ArrayList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Test (org.junit.Test)1