Java Code Examples for io.vertx.core.impl.ContextInternal#tracer()

The following examples show how to use io.vertx.core.impl.ContextInternal#tracer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PgPoolImpl.java    From vertx-sql-client with Apache License 2.0 5 votes vote down vote up
public static PgPoolImpl create(ContextInternal context, boolean closeVertx, PgConnectOptions connectOptions, PoolOptions poolOptions) {
  QueryTracer tracer = context.tracer() == null ? null : new QueryTracer(context.tracer(), connectOptions);
  VertxMetrics vertxMetrics = context.owner().metricsSPI();
  ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(connectOptions.getSocketAddress(), "sql", connectOptions.getMetricsName()) : null;
  PgPoolImpl pool = new PgPoolImpl(context, new PgConnectionFactory(context.owner(), context, connectOptions), tracer, metrics, poolOptions);
  CloseFuture closeFuture = pool.closeFuture();
  if (closeVertx) {
    closeFuture.onComplete(ar -> context.owner().close());
  } else {
    context.addCloseHook(closeFuture);
  }
  return pool;
}
 
Example 2
Source File: DB2ConnectionImpl.java    From vertx-sql-client with Apache License 2.0 5 votes vote down vote up
public static Future<DB2Connection> connect(Vertx vertx, DB2ConnectOptions options) {
  ContextInternal ctx = (ContextInternal) vertx.getOrCreateContext();
  DB2ConnectionFactory client;
  try {
    client = new DB2ConnectionFactory(ctx, options);
  } catch (Exception e) {
    return ctx.failedFuture(e);
  }
  QueryTracer tracer = ctx.tracer() == null ? null : new QueryTracer(ctx.tracer(), options);
  Promise<DB2Connection> promise = ctx.promise();
  ctx.dispatch(null, v -> connect(client, ctx, tracer, promise));
  return promise.future();
}
 
Example 3
Source File: DB2PoolImpl.java    From vertx-sql-client with Apache License 2.0 5 votes vote down vote up
public static DB2PoolImpl create(ContextInternal context, boolean closeVertx, DB2ConnectOptions connectOptions,
                                 PoolOptions poolOptions) {
  QueryTracer tracer = context.tracer() == null ? null : new QueryTracer(context.tracer(), connectOptions);
  VertxMetrics vertxMetrics = context.owner().metricsSPI();
  ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(connectOptions.getSocketAddress(), "sql", connectOptions.getMetricsName()) : null;
  DB2PoolImpl pool = new DB2PoolImpl(context, poolOptions, new DB2ConnectionFactory(context, connectOptions), tracer, metrics);
  CloseFuture closeFuture = pool.closeFuture();
  if (closeVertx) {
    closeFuture.onComplete(ar -> context.owner().close());
  } else {
    context.addCloseHook(closeFuture);
  }
  return pool;
}
 
Example 4
Source File: MSSQLPoolImpl.java    From vertx-sql-client with Apache License 2.0 5 votes vote down vote up
public static MSSQLPoolImpl create(ContextInternal context, boolean closeVertx, MSSQLConnectOptions connectOptions, PoolOptions poolOptions) {
  QueryTracer tracer = context.tracer() == null ? null : new QueryTracer(context.tracer(), connectOptions);
  VertxMetrics vertxMetrics = context.owner().metricsSPI();
  ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(connectOptions.getSocketAddress(), "sql", connectOptions.getMetricsName()) : null;
  MSSQLPoolImpl pool = new MSSQLPoolImpl(context, new MSSQLConnectionFactory(context, connectOptions), tracer, metrics, poolOptions);
  CloseFuture closeFuture = pool.closeFuture();
  if (closeVertx) {
    closeFuture.onComplete(ar -> context.owner().close());
  } else {
    context.addCloseHook(closeFuture);
  }
  return pool;
}
 
Example 5
Source File: MSSQLConnectionImpl.java    From vertx-sql-client with Apache License 2.0 5 votes vote down vote up
public static Future<MSSQLConnection> connect(Vertx vertx, MSSQLConnectOptions options) {
  ContextInternal ctx = (ContextInternal) vertx.getOrCreateContext();
  QueryTracer tracer = ctx.tracer() == null ? null : new QueryTracer(ctx.tracer(), options);
  PromiseInternal<MSSQLConnection> promise = ctx.promise();
  MSSQLConnectionFactory client = new MSSQLConnectionFactory(ctx, options);
  ctx.dispatch(null, v -> {
    client.connect()
      .<MSSQLConnection>map(conn -> {
        MSSQLConnectionImpl msConn = new MSSQLConnectionImpl(client, ctx, conn, tracer, null);
        conn.init(msConn);
        return msConn;
      }).onComplete(promise);
  });
  return promise.future();
}
 
Example 6
Source File: MySQLConnectionImpl.java    From vertx-sql-client with Apache License 2.0 5 votes vote down vote up
public static Future<MySQLConnection> connect(Vertx vertx, MySQLConnectOptions options) {
  ContextInternal ctx = (ContextInternal) vertx.getOrCreateContext();
  MySQLConnectionFactory client;
  try {
    client = new MySQLConnectionFactory(ctx, options);
  } catch (Exception e) {
    return ctx.failedFuture(e);
  }
  QueryTracer tracer = ctx.tracer() == null ? null : new QueryTracer(ctx.tracer(), options);
  Promise<MySQLConnection> promise = ctx.promise();
  ctx.dispatch(null, v -> connect(client, ctx, tracer, null, promise));
  return promise.future();
}
 
Example 7
Source File: MySQLPoolImpl.java    From vertx-sql-client with Apache License 2.0 5 votes vote down vote up
public static MySQLPoolImpl create(ContextInternal context, boolean closeVertx, MySQLConnectOptions connectOptions, PoolOptions poolOptions) {
  QueryTracer tracer = context.tracer() == null ? null : new QueryTracer(context.tracer(), connectOptions);
  VertxMetrics vertxMetrics = context.owner().metricsSPI();
  ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(connectOptions.getSocketAddress(), "sql", connectOptions.getMetricsName()) : null;
  MySQLPoolImpl pool = new MySQLPoolImpl(context, new MySQLConnectionFactory(context, connectOptions), tracer, metrics, poolOptions);
  CloseFuture closeFuture = pool.closeFuture();
  if (closeVertx) {
    closeFuture.onComplete(ar -> context.owner().close());
  } else {
    context.addCloseHook(closeFuture);
  }
  return pool;
}