Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions .github/workflows/ci-4.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ jobs:
- os: ubuntu-latest
jdk: 8
profile: 'MariaDB-10.4'
- os: ubuntu-latest
jdk: 8
profile: 'MSSQL-2017-latest'
- os: ubuntu-latest
jdk: 8
profile: 'MSSQL-2019-latest'
# Currently does not pass in CI due to a container issue
# - os: ubuntu-latest
# jdk: 8
# profile: 'MSSQL-2017-latest'
# - os: ubuntu-latest
# jdk: 8
# profile: 'MSSQL-2019-latest'
- os: ubuntu-latest
jdk: 8
profile: 'DB2-11.5'
Expand All @@ -49,9 +50,10 @@ jobs:
- os: ubuntu-latest
jdk: 17
profile: 'MariaDB-10.4'
- os: ubuntu-latest
jdk: 17
profile: 'MSSQL-2019-latest'
# Currently does not pass in CI due to a container issue
# - os: ubuntu-latest
# jdk: 17
# profile: 'MSSQL-2019-latest'
- os: ubuntu-latest
jdk: 17
profile: 'Oracle-23'
Expand Down
20 changes: 11 additions & 9 deletions .github/workflows/ci-5.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ jobs:
- os: ubuntu-latest
jdk: 11
profile: 'MariaDB-10.4'
- os: ubuntu-latest
jdk: 11
profile: 'MSSQL-2017-latest'
- os: ubuntu-latest
jdk: 11
profile: 'MSSQL-2019-latest'
# Currently does not pass in CI due to a container issue
# - os: ubuntu-latest
# jdk: 11
# profile: 'MSSQL-2017-latest'
# - os: ubuntu-latest
# jdk: 11
# profile: 'MSSQL-2019-latest'
- os: ubuntu-latest
jdk: 11
profile: 'DB2-11.5'
Expand All @@ -55,9 +56,10 @@ jobs:
- os: ubuntu-latest
jdk: 17
profile: 'MariaDB-10.4'
- os: ubuntu-latest
jdk: 17
profile: 'MSSQL-2019-latest'
# Currently does not pass in CI due to a container issue
# - os: ubuntu-latest
# jdk: 17
# profile: 'MSSQL-2019-latest'
- os: ubuntu-latest
jdk: 17
profile: 'Oracle-23'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ public DB2ConnectOptions setSslOptions(ClientSSLOptions sslOptions) {
protected void init() {
this.setHost(DEFAULT_HOST);
this.setPort(DEFAULT_PORT);
this.setMetricsName(DEFAULT_METRICS_NAME);
this.setProperties(new HashMap<>(DEFAULT_CONNECTION_ATTRIBUTES));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.vertx.core.Promise;
import io.vertx.core.internal.ContextInternal;
import io.vertx.core.internal.VertxInternal;
import io.vertx.core.net.NetClientOptions;
import io.vertx.core.net.SocketAddress;
import io.vertx.core.internal.net.NetSocketInternal;
import io.vertx.core.spi.metrics.ClientMetrics;
Expand All @@ -38,6 +39,10 @@ public DB2ConnectionFactory(VertxInternal vertx) {
super(vertx);
}

public DB2ConnectionFactory(VertxInternal vertx, NetClientOptions tcpOptions) {
super(vertx, tcpOptions);
}

@Override
protected Future<Connection> doConnectInternal(DB2ConnectOptions options, ContextInternal context) {
SocketAddress server = options.getSocketAddress();
Expand All @@ -51,7 +56,7 @@ protected Future<Connection> doConnectInternal(DB2ConnectOptions options, Contex
int pipeliningLimit = options.getPipeliningLimit();
return client.connect(server).flatMap(so -> {
VertxMetrics vertxMetrics = vertx.metricsSPI();
ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(options.getSocketAddress(), "sql", tcpOptions.getMetricsName()) : null;
ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(options.getSocketAddress(), "sql", options.getMetricsName()) : null;
DB2SocketConnection conn = new DB2SocketConnection((NetSocketInternal) so, metrics, options, cachePreparedStatements,
preparedStatementCacheSize, preparedStatementCacheSqlFilter, pipeliningLimit, context);
conn.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public boolean acceptsOptions(SqlConnectOptions options) {

@Override
public ConnectionFactory<DB2ConnectOptions> createConnectionFactory(Vertx vertx, NetClientOptions transportOptions) {
return new DB2ConnectionFactory((VertxInternal) vertx);
return new DB2ConnectionFactory((VertxInternal) vertx, transportOptions);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ protected void init() {
this.setUser(DEFAULT_USER);
this.setPassword(DEFAULT_PASSWORD);
this.setDatabase(DEFAULT_DATABASE);
this.setMetricsName(DEFAULT_METRICS_NAME);
this.setProperties(new HashMap<>(DEFAULT_PROPERTIES));
packetSize = DEFAULT_PACKET_SIZE;
ssl = DEFAULT_SSL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private Future<Connection> connectOrRedirect(MSSQLConnectOptions options, Contex

private MSSQLSocketConnection createSocketConnection(NetSocket so, MSSQLConnectOptions options, ContextInternal context) {
VertxMetrics vertxMetrics = vertx.metricsSPI();
ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(options.getSocketAddress(), "sql", tcpOptions.getMetricsName()) : null;
ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(options.getSocketAddress(), "sql", options.getMetricsName()) : null;
MSSQLSocketConnection conn = new MSSQLSocketConnection((NetSocketInternal) so, sslContextManager, metrics, options, false, 0, sql -> true, 1, context);
conn.init();
return conn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@

package io.vertx.mssqlclient.tck;

import io.vertx.core.Vertx;
import io.vertx.mssqlclient.MSSQLBuilder;
import io.vertx.mssqlclient.junit.MSSQLRule;
import io.vertx.sqlclient.ClientBuilder;
import io.vertx.sqlclient.Pool;
import io.vertx.sqlclient.SqlConnectOptions;
import io.vertx.sqlclient.tck.MetricsTestBase;
import org.junit.ClassRule;

Expand All @@ -24,8 +25,13 @@ public class MSSQLMetricsTest extends MetricsTestBase {
public static MSSQLRule rule = MSSQLRule.SHARED_INSTANCE;

@Override
protected Pool createPool(Vertx vertx) {
return MSSQLBuilder.pool(builder -> builder.connectingTo(rule.options()).using(vertx));
protected SqlConnectOptions connectOptions() {
return rule.options();
}

@Override
protected ClientBuilder<Pool> poolBuilder() {
return MSSQLBuilder.pool();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ protected void init() {
this.setUser(DEFAULT_USER);
this.setPassword(DEFAULT_PASSWORD);
this.setDatabase(DEFAULT_SCHEMA);
this.setMetricsName(DEFAULT_METRICS_NAME);
this.setProperties(new HashMap<>(DEFAULT_CONNECTION_ATTRIBUTES));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private Future<Connection> doConnect(MySQLConnectOptions options, SslMode sslMod
Future<NetSocket> fut = client.connect(connectOptions);
return fut.flatMap(so -> {
VertxMetrics vertxMetrics = vertx.metricsSPI();
ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(options.getSocketAddress(), "sql", tcpOptions.getMetricsName()) : null;
ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(options.getSocketAddress(), "sql", options.getMetricsName()) : null;
MySQLSocketConnection conn = new MySQLSocketConnection((NetSocketInternal) so, metrics, options, cachePreparedStatements, preparedStatementCacheMaxSize, preparedStatementCacheSqlFilter, pipeliningLimit, context);
conn.init();
return Future.future(promise -> conn.sendStartupMessage(username, password, database, collation, serverRsaPublicKey, properties, sslMode, sslOptions, initialCapabilitiesFlags, charsetEncoding, authenticationPlugin, promise));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ protected void init() {
this.setUser(DEFAULT_USER);
this.setPassword(DEFAULT_PASSWORD);
this.setDatabase(DEFAULT_DATABASE);
this.setMetricsName(DEFAULT_METRICS_NAME);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private OracleDataSource getDatasource(SqlConnectOptions options) {
public Future<SqlConnection> connect(Context context, OracleConnectOptions options) {
OracleDataSource datasource = getDatasource(options);
VertxMetrics vertxMetrics = ((VertxInternal)context.owner()).metricsSPI();
ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(options.getSocketAddress(), "sql", null) : null;
ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(options.getSocketAddress(), "sql", options.getMetricsName()) : null;
ContextInternal ctx = (ContextInternal) context;
return executeBlocking(context, () -> {
OracleConnection orac = datasource.createConnectionBuilder().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@

package io.vertx.oracleclient.test.tck;

import io.vertx.core.Vertx;
import io.vertx.ext.unit.TestContext;
import io.vertx.oracleclient.OracleBuilder;
import io.vertx.oracleclient.test.junit.OracleRule;
import io.vertx.sqlclient.ClientBuilder;
import io.vertx.sqlclient.Pool;
import io.vertx.sqlclient.SqlConnectOptions;
import io.vertx.sqlclient.tck.MetricsTestBase;
import org.junit.ClassRule;
import org.junit.Ignore;
Expand All @@ -27,10 +28,13 @@ public class OracleMetricsTest extends MetricsTestBase {
public static OracleRule rule = OracleRule.SHARED_INSTANCE;

@Override
protected Pool createPool(Vertx vertx) {
return OracleBuilder.pool(builder -> builder
.connectingTo(rule.options())
.using(vertx));
protected SqlConnectOptions connectOptions() {
return rule.options();
}

@Override
protected ClientBuilder<Pool> poolBuilder() {
return OracleBuilder.pool();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ protected void init() {
this.setUser(DEFAULT_USER);
this.setPassword(DEFAULT_PASSWORD);
this.setDatabase(DEFAULT_DATABASE);
this.setMetricsName(DEFAULT_METRICS_NAME);
this.setProperties(new HashMap<>(DEFAULT_PROPERTIES));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private PgSocketConnection newSocketConnection(ContextInternal context, NetSocke
int pipeliningLimit = options.getPipeliningLimit();
boolean useLayer7Proxy = options.getUseLayer7Proxy();
VertxMetrics vertxMetrics = vertx.metricsSPI();
ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(options.getSocketAddress(), "sql", tcpOptions.getMetricsName()) : null;
ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(options.getSocketAddress(), "sql", options.getMetricsName()) : null;
PgSocketConnection conn = new PgSocketConnection(socket, metrics, options, cachePreparedStatements, preparedStatementCacheMaxSize, preparedStatementCacheSqlFilter, pipeliningLimit, useLayer7Proxy, context);
return conn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@

package io.vertx.pgclient;

import io.vertx.core.Vertx;
import io.vertx.pgclient.junit.ContainerPgRule;
import io.vertx.sqlclient.ClientBuilder;
import io.vertx.sqlclient.Pool;
import io.vertx.sqlclient.SqlConnectOptions;
import io.vertx.sqlclient.tck.MetricsTestBase;
import org.junit.ClassRule;

Expand All @@ -23,8 +24,12 @@ public class PgMetricsTest extends MetricsTestBase {
public static ContainerPgRule rule = new ContainerPgRule();

@Override
protected Pool createPool(Vertx vertx) {
return PgBuilder.pool().connectingTo(rule.options()).using(vertx).build();
protected SqlConnectOptions connectOptions() {
return rule.options();
}

protected ClientBuilder<Pool> poolBuilder() {
return PgBuilder.pool();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.vertx.codegen.annotations.GenIgnore;
import io.vertx.codegen.json.annotations.JsonGen;
import io.vertx.core.json.JsonObject;
import io.vertx.core.net.ClientOptionsBase;
import io.vertx.core.net.ClientSSLOptions;
import io.vertx.core.net.SocketAddress;
import io.vertx.core.tracing.TracingPolicy;
Expand Down Expand Up @@ -70,6 +71,7 @@ public static SqlConnectOptions fromUri(String connectionUri) throws IllegalArgu
public static final int DEFAULT_PREPARED_STATEMENT_CACHE_MAX_SIZE = 256;
public static final int DEFAULT_PREPARED_STATEMENT_CACHE_SQL_LIMIT = 2048;
public static final Predicate<String> DEFAULT_PREPARED_STATEMENT_CACHE_FILTER = sql -> sql.length() < DEFAULT_PREPARED_STATEMENT_CACHE_SQL_LIMIT;
public static final String DEFAULT_METRICS_NAME = "";

private String host;
private int port;
Expand All @@ -83,6 +85,7 @@ public static SqlConnectOptions fromUri(String connectionUri) throws IllegalArgu
private TracingPolicy tracingPolicy;
private int reconnectAttempts;
private long reconnectInterval;
private String metricsName;
private ClientSSLOptions sslOptions;

public SqlConnectOptions() {
Expand All @@ -109,6 +112,7 @@ public SqlConnectOptions(SqlConnectOptions other) {
this.tracingPolicy = other.tracingPolicy;
this.reconnectAttempts = other.reconnectAttempts;
this.reconnectInterval = other.reconnectInterval;
this.metricsName = other.metricsName;
ClientSSLOptions sslOptions = other.sslOptions;
this.sslOptions = sslOptions != null ? sslOptions.copy() : null;
}
Expand Down Expand Up @@ -398,6 +402,25 @@ public SqlConnectOptions setReconnectInterval(long interval) {
return this;
}

/**
* @return the metrics name identifying the reported metrics.
*/
public String getMetricsName() {
return metricsName;
}

/**
* Set the metrics name identifying the reported metrics, useful for grouping metrics
* with the same name.
*
* @param metricsName the metrics name
* @return a reference to this, so the API can be used fluently
*/
public SqlConnectOptions setMetricsName(String metricsName) {
this.metricsName = metricsName;
return this;
}

public ClientSSLOptions getSslOptions() {
return sslOptions;
}
Expand Down
Loading