Search in sources :

Example 6 with QueryTracer

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

the class MSSQLDriver method newPoolImpl.

private PoolImpl newPoolImpl(VertxInternal vertx, List<? extends SqlConnectOptions> databases, PoolOptions options, CloseFuture closeFuture) {
    MSSQLConnectOptions baseConnectOptions = MSSQLConnectOptions.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;
    PoolImpl pool = new PoolImpl(vertx, this, tracer, metrics, 1, options, null, null, 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 : SqlConnectOptions(io.vertx.sqlclient.SqlConnectOptions) VertxInternal(io.vertx.core.impl.VertxInternal) MSSQLConnectionUriParser(io.vertx.mssqlclient.impl.MSSQLConnectionUriParser) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) Vertx(io.vertx.core.Vertx) ConnectionFactory(io.vertx.sqlclient.spi.ConnectionFactory) ContextInternal(io.vertx.core.impl.ContextInternal) MSSQLConnectionFactory(io.vertx.mssqlclient.impl.MSSQLConnectionFactory) Driver(io.vertx.sqlclient.spi.Driver) PoolImpl(io.vertx.sqlclient.impl.PoolImpl) MSSQLPoolImpl(io.vertx.mssqlclient.impl.MSSQLPoolImpl) Collectors(java.util.stream.Collectors) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) MSSQLConnectionImpl(io.vertx.mssqlclient.impl.MSSQLConnectionImpl) 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) MSSQLConnectOptions(io.vertx.mssqlclient.MSSQLConnectOptions) MSSQLPool(io.vertx.mssqlclient.MSSQLPool) SqlConnectionInternal(io.vertx.sqlclient.impl.SqlConnectionInternal) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) ConnectionFactory(io.vertx.sqlclient.spi.ConnectionFactory) MSSQLConnectionFactory(io.vertx.mssqlclient.impl.MSSQLConnectionFactory) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) MSSQLConnectOptions(io.vertx.mssqlclient.MSSQLConnectOptions) ClientMetrics(io.vertx.core.spi.metrics.ClientMetrics) PoolImpl(io.vertx.sqlclient.impl.PoolImpl) MSSQLPoolImpl(io.vertx.mssqlclient.impl.MSSQLPoolImpl)

Example 7 with QueryTracer

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

the class OracleConnectionFactory method connect.

@Override
public Future<SqlConnection> connect(Context context) {
    ContextInternal ctx = (ContextInternal) context;
    QueryTracer tracer = ctx.tracer() == null ? null : new QueryTracer(ctx.tracer(), options);
    return context.<OracleConnection>executeBlocking(prom -> {
        try {
            prom.complete(datasource.createConnectionBuilder().build());
        } catch (SQLException e) {
            prom.fail(e);
        }
    }).map(ora -> {
        CommandHandler conn = new CommandHandler((ContextInternal) context, options, ora);
        OracleConnectionImpl msConn = new OracleConnectionImpl(ctx, this, conn, tracer, null);
        conn.init(msConn);
        return msConn;
    });
}
Also used : OracleDataSource(oracle.jdbc.datasource.OracleDataSource) OracleConnectOptions(io.vertx.oracleclient.OracleConnectOptions) VertxInternal(io.vertx.core.impl.VertxInternal) OracleDatabaseHelper.createDataSource(io.vertx.oracleclient.impl.OracleDatabaseHelper.createDataSource) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) Promise(io.vertx.core.Promise) ConnectionFactory(io.vertx.sqlclient.spi.ConnectionFactory) ContextInternal(io.vertx.core.impl.ContextInternal) Context(io.vertx.core.Context) Future(io.vertx.core.Future) SQLException(java.sql.SQLException) SqlConnection(io.vertx.sqlclient.SqlConnection) OracleConnection(oracle.jdbc.OracleConnection) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) SQLException(java.sql.SQLException) ContextInternal(io.vertx.core.impl.ContextInternal)

Example 8 with QueryTracer

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

the class PgDriver method newPoolImpl.

private PoolImpl newPoolImpl(VertxInternal vertx, List<? extends SqlConnectOptions> databases, PoolOptions options, CloseFuture closeFuture) {
    PgConnectOptions baseConnectOptions = PgConnectOptions.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;
    boolean pipelinedPool = options instanceof PgPoolOptions && ((PgPoolOptions) options).isPipelined();
    int pipeliningLimit = pipelinedPool ? baseConnectOptions.getPipeliningLimit() : 1;
    PoolImpl pool = new PoolImpl(vertx, this, tracer, metrics, pipeliningLimit, options, null, null, 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 : 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) PgPool(io.vertx.pgclient.PgPool) 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) 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) PgConnectOptions(io.vertx.pgclient.PgConnectOptions) io.vertx.pgclient.impl(io.vertx.pgclient.impl) PgConnectOptions(io.vertx.pgclient.PgConnectOptions) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) ConnectionFactory(io.vertx.sqlclient.spi.ConnectionFactory) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) ClientMetrics(io.vertx.core.spi.metrics.ClientMetrics) PoolImpl(io.vertx.sqlclient.impl.PoolImpl)

Example 9 with QueryTracer

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

the class DB2ConnectionFactory method connect.

@Override
public Future<SqlConnection> connect(Context context) {
    ContextInternal contextInternal = (ContextInternal) context;
    QueryTracer tracer = contextInternal.tracer() == null ? null : new QueryTracer(contextInternal.tracer(), options);
    Promise<SqlConnection> promise = contextInternal.promise();
    connect(asEventLoopContext(contextInternal)).map(conn -> {
        DB2ConnectionImpl db2Connection = new DB2ConnectionImpl(contextInternal, this, conn, tracer, null);
        conn.init(db2Connection);
        return (SqlConnection) db2Connection;
    }).onComplete(promise);
    return promise.future();
}
Also used : SqlConnectOptions(io.vertx.sqlclient.SqlConnectOptions) ConnectionFactoryBase(io.vertx.sqlclient.impl.ConnectionFactoryBase) VertxInternal(io.vertx.core.impl.VertxInternal) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) Promise(io.vertx.core.Promise) ContextInternal(io.vertx.core.impl.ContextInternal) Context(io.vertx.core.Context) Future(io.vertx.core.Future) NetClientOptions(io.vertx.core.net.NetClientOptions) Connection(io.vertx.sqlclient.impl.Connection) EventLoopContext(io.vertx.core.impl.EventLoopContext) SqlConnection(io.vertx.sqlclient.SqlConnection) DB2ConnectOptions(io.vertx.db2client.DB2ConnectOptions) NetSocketInternal(io.vertx.core.net.impl.NetSocketInternal) SocketAddress(io.vertx.core.net.SocketAddress) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) ContextInternal(io.vertx.core.impl.ContextInternal) SqlConnection(io.vertx.sqlclient.SqlConnection)

Example 10 with QueryTracer

use of io.vertx.sqlclient.impl.tracing.QueryTracer 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

ContextInternal (io.vertx.core.impl.ContextInternal)10 VertxInternal (io.vertx.core.impl.VertxInternal)10 QueryTracer (io.vertx.sqlclient.impl.tracing.QueryTracer)10 SqlConnectOptions (io.vertx.sqlclient.SqlConnectOptions)9 Connection (io.vertx.sqlclient.impl.Connection)9 Future (io.vertx.core.Future)6 ConnectionFactory (io.vertx.sqlclient.spi.ConnectionFactory)6 Context (io.vertx.core.Context)5 Vertx (io.vertx.core.Vertx)5 CloseFuture (io.vertx.core.impl.CloseFuture)5 JsonObject (io.vertx.core.json.JsonObject)5 ClientMetrics (io.vertx.core.spi.metrics.ClientMetrics)5 VertxMetrics (io.vertx.core.spi.metrics.VertxMetrics)5 PoolOptions (io.vertx.sqlclient.PoolOptions)5 SqlConnection (io.vertx.sqlclient.SqlConnection)5 PoolImpl (io.vertx.sqlclient.impl.PoolImpl)5 SqlConnectionInternal (io.vertx.sqlclient.impl.SqlConnectionInternal)5 Driver (io.vertx.sqlclient.spi.Driver)5 List (java.util.List)5 Collectors (java.util.stream.Collectors)5