Search in sources :

Example 16 with SqlConnectOptions

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

the class DriverTestBase method testCreatePool05.

@Test
public void testCreatePool05(TestContext ctx) {
    // The default options will be an instanceof the driver-specific class, so manually copy
    // each option over onto a fresh generic options object to force the generic constructor path
    SqlConnectOptions defaults = defaultOptions();
    SqlConnectOptions opts = new SqlConnectOptions().setHost(defaults.getHost()).setPort(defaults.getPort()).setDatabase(defaults.getDatabase()).setUser(defaults.getUser()).setPassword(defaults.getPassword());
    testCreatePool(ctx, () -> Pool.pool(opts));
}
Also used : SqlConnectOptions(io.vertx.sqlclient.SqlConnectOptions) Test(org.junit.Test)

Example 17 with SqlConnectOptions

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

the class DB2Driver method newPool.

@Override
public DB2Pool newPool(Vertx vertx, List<? extends SqlConnectOptions> databases, PoolOptions options, CloseFuture closeFuture) {
    VertxInternal vx = (VertxInternal) vertx;
    PoolImpl pool;
    if (options.isShared()) {
        pool = vx.createSharedClient(SHARED_CLIENT_KEY, options.getName(), closeFuture, cf -> newPoolImpl(vx, databases, options, cf));
    } else {
        pool = newPoolImpl(vx, databases, options, closeFuture);
    }
    return new DB2PoolImpl(vx, closeFuture, pool);
}
Also used : SqlConnectOptions(io.vertx.sqlclient.SqlConnectOptions) VertxInternal(io.vertx.core.impl.VertxInternal) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) Vertx(io.vertx.core.Vertx) ConnectionFactory(io.vertx.sqlclient.spi.ConnectionFactory) ContextInternal(io.vertx.core.impl.ContextInternal) Driver(io.vertx.sqlclient.spi.Driver) PoolImpl(io.vertx.sqlclient.impl.PoolImpl) Collectors(java.util.stream.Collectors) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) PoolOptions(io.vertx.sqlclient.PoolOptions) Connection(io.vertx.sqlclient.impl.Connection) List(java.util.List) DB2Pool(io.vertx.db2client.DB2Pool) CloseFuture(io.vertx.core.impl.CloseFuture) DB2ConnectOptions(io.vertx.db2client.DB2ConnectOptions) io.vertx.db2client.impl(io.vertx.db2client.impl) JsonObject(io.vertx.core.json.JsonObject) ClientMetrics(io.vertx.core.spi.metrics.ClientMetrics) SqlConnectionInternal(io.vertx.sqlclient.impl.SqlConnectionInternal) VertxInternal(io.vertx.core.impl.VertxInternal) PoolImpl(io.vertx.sqlclient.impl.PoolImpl)

Example 18 with SqlConnectOptions

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

the class DB2ConnectionAutoRetryTest method initialConnector.

@Override
protected void initialConnector(int proxyPort) {
    SqlConnectOptions proxyOptions = new DB2ConnectOptions(options);
    proxyOptions.setPort(proxyPort);
    proxyOptions.setHost("localhost");
    connectionConnector = ClientConfig.CONNECT.connect(vertx, proxyOptions);
    poolConnector = ClientConfig.POOLED.connect(vertx, proxyOptions);
}
Also used : SqlConnectOptions(io.vertx.sqlclient.SqlConnectOptions) DB2ConnectOptions(io.vertx.db2client.DB2ConnectOptions)

Example 19 with SqlConnectOptions

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

the class MySQLDriver method newPool.

@Override
public MySQLPool newPool(Vertx vertx, List<? extends SqlConnectOptions> databases, PoolOptions options, CloseFuture closeFuture) {
    VertxInternal vx = (VertxInternal) vertx;
    PoolImpl pool;
    if (options.isShared()) {
        pool = vx.createSharedClient(SHARED_CLIENT_KEY, options.getName(), closeFuture, cf -> newPoolImpl(vx, databases, options, cf));
    } else {
        pool = newPoolImpl(vx, databases, options, closeFuture);
    }
    return new MySQLPoolImpl(vx, closeFuture, pool);
}
Also used : SqlConnectOptions(io.vertx.sqlclient.SqlConnectOptions) VertxInternal(io.vertx.core.impl.VertxInternal) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) Vertx(io.vertx.core.Vertx) ConnectionFactory(io.vertx.sqlclient.spi.ConnectionFactory) ContextInternal(io.vertx.core.impl.ContextInternal) MySQLConnectionImpl(io.vertx.mysqlclient.impl.MySQLConnectionImpl) Driver(io.vertx.sqlclient.spi.Driver) MySQLPoolImpl(io.vertx.mysqlclient.impl.MySQLPoolImpl) PoolImpl(io.vertx.sqlclient.impl.PoolImpl) Collectors(java.util.stream.Collectors) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) MySQLConnectionFactory(io.vertx.mysqlclient.impl.MySQLConnectionFactory) PoolOptions(io.vertx.sqlclient.PoolOptions) Connection(io.vertx.sqlclient.impl.Connection) List(java.util.List) MySQLPool(io.vertx.mysqlclient.MySQLPool) CloseFuture(io.vertx.core.impl.CloseFuture) MySQLConnectionUriParser(io.vertx.mysqlclient.impl.MySQLConnectionUriParser) JsonObject(io.vertx.core.json.JsonObject) ClientMetrics(io.vertx.core.spi.metrics.ClientMetrics) MySQLConnectOptions(io.vertx.mysqlclient.MySQLConnectOptions) SqlConnectionInternal(io.vertx.sqlclient.impl.SqlConnectionInternal) VertxInternal(io.vertx.core.impl.VertxInternal) MySQLPoolImpl(io.vertx.mysqlclient.impl.MySQLPoolImpl) MySQLPoolImpl(io.vertx.mysqlclient.impl.MySQLPoolImpl) PoolImpl(io.vertx.sqlclient.impl.PoolImpl)

Example 20 with SqlConnectOptions

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

the class OracleDriver method newPoolImpl.

private PoolImpl newPoolImpl(VertxInternal vertx, List<? extends SqlConnectOptions> databases, PoolOptions options, CloseFuture closeFuture) {
    OracleConnectOptions baseConnectOptions = OracleConnectOptions.wrap(databases.get(0));
    QueryTracer tracer = vertx.tracer() == null ? null : new QueryTracer(vertx.tracer(), baseConnectOptions);
    VertxMetrics vertxMetrics = vertx.metricsSPI();
    ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(baseConnectOptions.getSocketAddress(), "sql", baseConnectOptions.getMetricsName()) : null;
    Function<Connection, Future<Void>> afterAcquire = conn -> ((CommandHandler) conn).afterAcquire();
    Function<Connection, Future<Void>> beforeRecycle = conn -> ((CommandHandler) conn).beforeRecycle();
    PoolImpl pool = new PoolImpl(vertx, this, tracer, metrics, 1, options, afterAcquire, beforeRecycle, closeFuture);
    List<ConnectionFactory> lst = databases.stream().map(o -> createConnectionFactory(vertx, o)).collect(Collectors.toList());
    ConnectionFactory factory = ConnectionFactory.roundRobinSelector(lst);
    pool.connectionProvider(factory::connect);
    pool.init();
    closeFuture.add(factory);
    return pool;
}
Also used : OracleConnectOptions(io.vertx.oracleclient.OracleConnectOptions) SqlConnectOptions(io.vertx.sqlclient.SqlConnectOptions) VertxInternal(io.vertx.core.impl.VertxInternal) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) io.vertx.oracleclient.impl(io.vertx.oracleclient.impl) Vertx(io.vertx.core.Vertx) ConnectionFactory(io.vertx.sqlclient.spi.ConnectionFactory) ContextInternal(io.vertx.core.impl.ContextInternal) Pool(io.vertx.sqlclient.Pool) Driver(io.vertx.sqlclient.spi.Driver) PoolImpl(io.vertx.sqlclient.impl.PoolImpl) Future(io.vertx.core.Future) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) PoolOptions(io.vertx.sqlclient.PoolOptions) Connection(io.vertx.sqlclient.impl.Connection) List(java.util.List) CloseFuture(io.vertx.core.impl.CloseFuture) JsonObject(io.vertx.core.json.JsonObject) ClientMetrics(io.vertx.core.spi.metrics.ClientMetrics) SqlConnectionInternal(io.vertx.sqlclient.impl.SqlConnectionInternal) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) OracleConnectOptions(io.vertx.oracleclient.OracleConnectOptions) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) Connection(io.vertx.sqlclient.impl.Connection) PoolImpl(io.vertx.sqlclient.impl.PoolImpl) ConnectionFactory(io.vertx.sqlclient.spi.ConnectionFactory) Future(io.vertx.core.Future) CloseFuture(io.vertx.core.impl.CloseFuture) ClientMetrics(io.vertx.core.spi.metrics.ClientMetrics)

Aggregations

SqlConnectOptions (io.vertx.sqlclient.SqlConnectOptions)20 CloseFuture (io.vertx.core.impl.CloseFuture)11 ContextInternal (io.vertx.core.impl.ContextInternal)11 VertxInternal (io.vertx.core.impl.VertxInternal)11 Vertx (io.vertx.core.Vertx)10 JsonObject (io.vertx.core.json.JsonObject)10 ClientMetrics (io.vertx.core.spi.metrics.ClientMetrics)10 VertxMetrics (io.vertx.core.spi.metrics.VertxMetrics)10 PoolOptions (io.vertx.sqlclient.PoolOptions)10 Connection (io.vertx.sqlclient.impl.Connection)10 PoolImpl (io.vertx.sqlclient.impl.PoolImpl)10 SqlConnectionInternal (io.vertx.sqlclient.impl.SqlConnectionInternal)10 QueryTracer (io.vertx.sqlclient.impl.tracing.QueryTracer)10 ConnectionFactory (io.vertx.sqlclient.spi.ConnectionFactory)10 Driver (io.vertx.sqlclient.spi.Driver)10 List (java.util.List)10 Collectors (java.util.stream.Collectors)10 DB2ConnectOptions (io.vertx.db2client.DB2ConnectOptions)3 MSSQLConnectOptions (io.vertx.mssqlclient.MSSQLConnectOptions)3 MySQLConnectOptions (io.vertx.mysqlclient.MySQLConnectOptions)3