Search in sources :

Example 1 with SqlConnectionInternal

use of io.vertx.sqlclient.impl.SqlConnectionInternal in project vertx-sql-client by eclipse-vertx.

the class PgPoolTest method testEventLoopSize.

@Test
public void testEventLoopSize(TestContext ctx) {
    int num = VertxOptions.DEFAULT_EVENT_LOOP_POOL_SIZE;
    int size = num * 2;
    PgPool pool = PgPool.pool(options, new PoolOptions().setMaxSize(size).setEventLoopSize(2));
    Set<EventLoop> eventLoops = Collections.synchronizedSet(new HashSet<>());
    Async async = ctx.async(size);
    for (int i = 0; i < size; i++) {
        pool.getConnection(ctx.asyncAssertSuccess(conn -> {
            PgSocketConnection c = (PgSocketConnection) ((SqlConnectionInternal) conn).unwrap().unwrap();
            EventLoop eventLoop = ((ContextInternal) c.context()).nettyEventLoop();
            eventLoops.add(eventLoop);
            async.countDown();
        }));
    }
    try {
        async.await();
    } finally {
        pool.close();
    }
    ctx.assertEquals(2, eventLoops.size());
}
Also used : TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) PgSocketConnection(io.vertx.pgclient.impl.PgSocketConnection) ConnectionFactory(io.vertx.sqlclient.spi.ConnectionFactory) ContextInternal(io.vertx.core.impl.ContextInternal) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) PgDriver(io.vertx.pgclient.spi.PgDriver) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Collectors.mapping(java.util.stream.Collectors.mapping) SqlConnectionInternal(io.vertx.sqlclient.impl.SqlConnectionInternal) RepeatRule(io.vertx.ext.unit.junit.RepeatRule) Collector(java.util.stream.Collector) io.vertx.sqlclient(io.vertx.sqlclient) VertxOptions(io.vertx.core.VertxOptions) Set(java.util.Set) Test(org.junit.Test) EventLoop(io.netty.channel.EventLoop) Repeat(io.vertx.ext.unit.junit.Repeat) Future(io.vertx.core.Future) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Rule(org.junit.Rule) Handler(io.vertx.core.Handler) Collections(java.util.Collections) EventLoop(io.netty.channel.EventLoop) Async(io.vertx.ext.unit.Async) PgSocketConnection(io.vertx.pgclient.impl.PgSocketConnection) Test(org.junit.Test)

Aggregations

EventLoop (io.netty.channel.EventLoop)1 Future (io.vertx.core.Future)1 Handler (io.vertx.core.Handler)1 VertxOptions (io.vertx.core.VertxOptions)1 ContextInternal (io.vertx.core.impl.ContextInternal)1 Async (io.vertx.ext.unit.Async)1 TestContext (io.vertx.ext.unit.TestContext)1 Repeat (io.vertx.ext.unit.junit.Repeat)1 RepeatRule (io.vertx.ext.unit.junit.RepeatRule)1 PgSocketConnection (io.vertx.pgclient.impl.PgSocketConnection)1 PgDriver (io.vertx.pgclient.spi.PgDriver)1 io.vertx.sqlclient (io.vertx.sqlclient)1 SqlConnectionInternal (io.vertx.sqlclient.impl.SqlConnectionInternal)1 ConnectionFactory (io.vertx.sqlclient.spi.ConnectionFactory)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 TimeUnit (java.util.concurrent.TimeUnit)1