Search in sources :

Example 1 with QueryTracer

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

the class MySQLDriver method newPoolImpl.

private PoolImpl newPoolImpl(VertxInternal vertx, List<? extends SqlConnectOptions> databases, PoolOptions options, CloseFuture closeFuture) {
    MySQLConnectOptions baseConnectOptions = MySQLConnectOptions.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) 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) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) ConnectionFactory(io.vertx.sqlclient.spi.ConnectionFactory) MySQLConnectionFactory(io.vertx.mysqlclient.impl.MySQLConnectionFactory) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) MySQLConnectOptions(io.vertx.mysqlclient.MySQLConnectOptions) ClientMetrics(io.vertx.core.spi.metrics.ClientMetrics) MySQLPoolImpl(io.vertx.mysqlclient.impl.MySQLPoolImpl) PoolImpl(io.vertx.sqlclient.impl.PoolImpl)

Example 2 with QueryTracer

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

the class MySQLConnectionFactory 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 -> {
        MySQLConnectionImpl mySQLConnection = new MySQLConnectionImpl(contextInternal, this, conn, tracer, null);
        conn.init(mySQLConnection);
        return (SqlConnection) mySQLConnection;
    }).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) io.vertx.core.net(io.vertx.core.net) MySQLAuthenticationPlugin(io.vertx.mysqlclient.MySQLAuthenticationPlugin) Connection(io.vertx.sqlclient.impl.Connection) CapabilitiesFlag(io.vertx.mysqlclient.impl.protocol.CapabilitiesFlag) EventLoopContext(io.vertx.core.impl.EventLoopContext) Buffer(io.vertx.core.buffer.Buffer) SslMode(io.vertx.mysqlclient.SslMode) SqlConnection(io.vertx.sqlclient.SqlConnection) Charset(java.nio.charset.Charset) MySQLConnectOptions(io.vertx.mysqlclient.MySQLConnectOptions) NetSocketInternal(io.vertx.core.net.impl.NetSocketInternal) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) ContextInternal(io.vertx.core.impl.ContextInternal) SqlConnection(io.vertx.sqlclient.SqlConnection)

Example 3 with QueryTracer

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

the class DB2Driver method newPoolImpl.

private PoolImpl newPoolImpl(VertxInternal vertx, List<? extends SqlConnectOptions> databases, PoolOptions options, CloseFuture closeFuture) {
    DB2ConnectOptions baseConnectOptions = DB2ConnectOptions.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 Db2PoolOptions && ((Db2PoolOptions) 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) 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) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) ConnectionFactory(io.vertx.sqlclient.spi.ConnectionFactory) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) DB2ConnectOptions(io.vertx.db2client.DB2ConnectOptions) ClientMetrics(io.vertx.core.spi.metrics.ClientMetrics) PoolImpl(io.vertx.sqlclient.impl.PoolImpl)

Example 4 with QueryTracer

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

the class MSSQLConnectionFactory method connect.

@Override
public Future<SqlConnection> connect(Context context) {
    ContextInternal ctx = (ContextInternal) context;
    QueryTracer tracer = ctx.tracer() == null ? null : new QueryTracer(ctx.tracer(), options);
    Promise<SqlConnection> promise = ctx.promise();
    connect(asEventLoopContext(ctx)).map(conn -> {
        MSSQLConnectionImpl msConn = new MSSQLConnectionImpl(ctx, this, conn, tracer, null);
        conn.init(msConn);
        return (SqlConnection) msConn;
    }).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) EncryptionLevel(io.vertx.mssqlclient.impl.codec.EncryptionLevel) 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) MSSQLConnectOptions(io.vertx.mssqlclient.MSSQLConnectOptions) NetSocketInternal(io.vertx.core.net.impl.NetSocketInternal) NetSocket(io.vertx.core.net.NetSocket) 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 5 with QueryTracer

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

the class PgConnectionFactory method connect.

@Override
public Future<SqlConnection> connect(Context context) {
    ContextInternal contextInternal = (ContextInternal) context;
    PromiseInternal<SqlConnection> promise = contextInternal.promise();
    connect(asEventLoopContext(contextInternal)).map(conn -> {
        QueryTracer tracer = contextInternal.tracer() == null ? null : new QueryTracer(contextInternal.tracer(), options);
        PgConnectionImpl pgConn = new PgConnectionImpl(this, contextInternal, conn, tracer, null);
        conn.init(pgConn);
        return (SqlConnection) pgConn;
    }).onComplete(promise);
    return promise.future();
}
Also used : SqlConnectOptions(io.vertx.sqlclient.SqlConnectOptions) ConnectionFactoryBase(io.vertx.sqlclient.impl.ConnectionFactoryBase) VertxInternal(io.vertx.core.impl.VertxInternal) PromiseInternal(io.vertx.core.impl.future.PromiseInternal) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) 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) TrustOptions(io.vertx.core.net.TrustOptions) SqlConnection(io.vertx.sqlclient.SqlConnection) AsyncResult(io.vertx.core.AsyncResult) PgConnectOptions(io.vertx.pgclient.PgConnectOptions) Handler(io.vertx.core.Handler) NetSocketInternal(io.vertx.core.net.impl.NetSocketInternal) SslMode(io.vertx.pgclient.SslMode) NetSocket(io.vertx.core.net.NetSocket) SocketAddress(io.vertx.core.net.SocketAddress) QueryTracer(io.vertx.sqlclient.impl.tracing.QueryTracer) ContextInternal(io.vertx.core.impl.ContextInternal) SqlConnection(io.vertx.sqlclient.SqlConnection)

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