Skip to content

Commit 167d208

Browse files
committed
Adapt to context internal changes
1 parent eca6207 commit 167d208

File tree

11 files changed

+30
-37
lines changed

11 files changed

+30
-37
lines changed

vertx-db2-client/src/main/java/io/vertx/db2client/impl/DB2ConnectionFactory.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import io.vertx.core.Future;
2020
import io.vertx.core.Promise;
2121
import io.vertx.core.impl.ContextInternal;
22-
import io.vertx.core.impl.EventLoopContext;
2322
import io.vertx.core.impl.VertxInternal;
2423
import io.vertx.core.net.NetClient;
2524
import io.vertx.core.net.SocketAddress;
@@ -43,7 +42,7 @@ public DB2ConnectionFactory(VertxInternal vertx, Supplier<? extends Future<? ext
4342
}
4443

4544
@Override
46-
protected Future<Connection> doConnectInternal(SqlConnectOptions options, EventLoopContext context) {
45+
protected Future<Connection> doConnectInternal(SqlConnectOptions options, ContextInternal context) {
4746
DB2ConnectOptions db2Options = DB2ConnectOptions.wrap(options);
4847
SocketAddress server = options.getSocketAddress();
4948
boolean cachePreparedStatements = options.getCachePreparedStatements();

vertx-db2-client/src/main/java/io/vertx/db2client/impl/DB2SocketConnection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import io.vertx.core.AsyncResult;
2323
import io.vertx.core.Handler;
2424
import io.vertx.core.Promise;
25-
import io.vertx.core.impl.EventLoopContext;
25+
import io.vertx.core.impl.ContextInternal;
2626
import io.vertx.core.net.impl.NetSocketInternal;
2727
import io.vertx.core.spi.metrics.ClientMetrics;
2828
import io.vertx.db2client.DB2ConnectOptions;
@@ -54,7 +54,7 @@ public DB2SocketConnection(NetSocketInternal socket,
5454
int preparedStatementCacheSize,
5555
Predicate<String> preparedStatementCacheSqlFilter,
5656
int pipeliningLimit,
57-
EventLoopContext context) {
57+
ContextInternal context) {
5858
super(socket, clientMetrics, cachePreparedStatements, preparedStatementCacheSize, preparedStatementCacheSqlFilter, pipeliningLimit, context);
5959
this.connectOptions = connectOptions;
6060
}

vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/MSSQLConnectionFactory.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import io.vertx.core.Future;
1616
import io.vertx.core.Promise;
1717
import io.vertx.core.impl.ContextInternal;
18-
import io.vertx.core.impl.EventLoopContext;
1918
import io.vertx.core.impl.VertxInternal;
2019
import io.vertx.core.net.NetClient;
2120
import io.vertx.core.net.NetClientOptions;
@@ -42,11 +41,11 @@ public MSSQLConnectionFactory(VertxInternal vertx, Supplier<? extends Future<? e
4241
}
4342

4443
@Override
45-
protected Future<Connection> doConnectInternal(SqlConnectOptions options, EventLoopContext context) {
44+
protected Future<Connection> doConnectInternal(SqlConnectOptions options, ContextInternal context) {
4645
return connectOrRedirect(MSSQLConnectOptions.wrap(options), context, 0);
4746
}
4847

49-
private Future<Connection> connectOrRedirect(MSSQLConnectOptions options, EventLoopContext context, int redirections) {
48+
private Future<Connection> connectOrRedirect(MSSQLConnectOptions options, ContextInternal context, int redirections) {
5049
if (redirections > 1) {
5150
return context.failedFuture("The client can be redirected only once");
5251
}
@@ -72,15 +71,15 @@ private Future<Connection> connectOrRedirect(MSSQLConnectOptions options, EventL
7271
});
7372
}
7473

75-
private MSSQLSocketConnection createSocketConnection(NetSocket so, MSSQLConnectOptions options, int desiredPacketSize, EventLoopContext context) {
74+
private MSSQLSocketConnection createSocketConnection(NetSocket so, MSSQLConnectOptions options, int desiredPacketSize, ContextInternal context) {
7675
VertxMetrics vertxMetrics = vertx.metricsSPI();
7776
ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(options.getSocketAddress(), "sql", options.getMetricsName()) : null;
7877
MSSQLSocketConnection conn = new MSSQLSocketConnection((NetSocketInternal) so, metrics, options, desiredPacketSize, false, 0, sql -> true, 1, context);
7978
conn.init();
8079
return conn;
8180
}
8281

83-
private Future<Connection> login(MSSQLSocketConnection conn, MSSQLConnectOptions options, Byte encryptionLevel, EventLoopContext context) {
82+
private Future<Connection> login(MSSQLSocketConnection conn, MSSQLConnectOptions options, Byte encryptionLevel, ContextInternal context) {
8483
boolean clientSslConfig = options.isSsl();
8584
if (clientSslConfig && encryptionLevel != ENCRYPT_ON && encryptionLevel != ENCRYPT_REQ) {
8685
Promise<Void> closePromise = context.promise();

vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/MSSQLSocketConnection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import io.vertx.core.AsyncResult;
1818
import io.vertx.core.Future;
1919
import io.vertx.core.Handler;
20-
import io.vertx.core.impl.EventLoopContext;
20+
import io.vertx.core.impl.ContextInternal;
2121
import io.vertx.core.impl.future.PromiseInternal;
2222
import io.vertx.core.net.SocketAddress;
2323
import io.vertx.core.net.impl.NetSocketInternal;
@@ -59,7 +59,7 @@ public class MSSQLSocketConnection extends SocketConnectionBase {
5959
int preparedStatementCacheSize,
6060
Predicate<String> preparedStatementCacheSqlFilter,
6161
int pipeliningLimit,
62-
EventLoopContext context) {
62+
ContextInternal context) {
6363
super(socket, clientMetrics, cachePreparedStatements, preparedStatementCacheSize, preparedStatementCacheSqlFilter, pipeliningLimit, context);
6464
this.connectOptions = connectOptions;
6565
this.packetSize = packetSize;

vertx-mysql-client/src/main/java/io/vertx/mysqlclient/impl/MySQLConnectionFactory.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import io.vertx.core.Promise;
1717
import io.vertx.core.buffer.Buffer;
1818
import io.vertx.core.impl.ContextInternal;
19-
import io.vertx.core.impl.EventLoopContext;
2019
import io.vertx.core.impl.VertxInternal;
2120
import io.vertx.core.net.NetClientOptions;
2221
import io.vertx.core.net.NetSocket;
@@ -47,7 +46,7 @@ public MySQLConnectionFactory(VertxInternal vertx, Supplier<? extends Future<? e
4746
}
4847

4948
@Override
50-
protected Future<Connection> doConnectInternal(SqlConnectOptions options, EventLoopContext context) {
49+
protected Future<Connection> doConnectInternal(SqlConnectOptions options, ContextInternal context) {
5150
MySQLConnectOptions mySQLOptions = MySQLConnectOptions.wrap(options);
5251
SslMode sslMode = mySQLOptions.isUsingDomainSocket() ? SslMode.DISABLED : mySQLOptions.getSslMode();
5352
switch (sslMode) {
@@ -86,7 +85,7 @@ private int capabilitiesFlags(MySQLConnectOptions options) {
8685
return capabilitiesFlags;
8786
}
8887

89-
private Future<Connection> doConnect(MySQLConnectOptions options, SslMode sslMode, int initialCapabilitiesFlags, EventLoopContext context) {
88+
private Future<Connection> doConnect(MySQLConnectOptions options, SslMode sslMode, int initialCapabilitiesFlags, ContextInternal context) {
9089
String username = options.getUser();
9190
String password = options.getPassword();
9291
String database = options.getDatabase();

vertx-mysql-client/src/main/java/io/vertx/mysqlclient/impl/MySQLSocketConnection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import io.vertx.core.Handler;
2323
import io.vertx.core.Promise;
2424
import io.vertx.core.buffer.Buffer;
25-
import io.vertx.core.impl.EventLoopContext;
25+
import io.vertx.core.impl.ContextInternal;
2626
import io.vertx.core.net.impl.NetSocketInternal;
2727
import io.vertx.core.spi.metrics.ClientMetrics;
2828
import io.vertx.mysqlclient.MySQLAuthenticationPlugin;
@@ -61,7 +61,7 @@ public MySQLSocketConnection(NetSocketInternal socket,
6161
int preparedStatementCacheSize,
6262
Predicate<String> preparedStatementCacheSqlFilter,
6363
int pipeliningLimit,
64-
EventLoopContext context) {
64+
ContextInternal context) {
6565
super(socket, clientMetrics, cachePreparedStatements, preparedStatementCacheSize, preparedStatementCacheSqlFilter, pipeliningLimit, context);
6666
this.connectOptions = connectOptions;
6767
}

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/PgConnectionFactory.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import io.vertx.core.Future;
2323
import io.vertx.core.Handler;
2424
import io.vertx.core.impl.ContextInternal;
25-
import io.vertx.core.impl.EventLoopContext;
2625
import io.vertx.core.impl.VertxInternal;
2726
import io.vertx.core.impl.future.PromiseInternal;
2827
import io.vertx.core.net.NetSocket;
@@ -69,7 +68,7 @@ private void checkSslMode(PgConnectOptions options) {
6968
}
7069

7170
@Override
72-
protected Future<Connection> doConnectInternal(SqlConnectOptions options, EventLoopContext context) {
71+
protected Future<Connection> doConnectInternal(SqlConnectOptions options, ContextInternal context) {
7372
PgConnectOptions pgOptions = PgConnectOptions.wrap(options);
7473
try {
7574
checkSslMode(pgOptions);
@@ -100,7 +99,7 @@ public void cancelRequest(PgConnectOptions options, int processId, int secretKey
10099
});
101100
}
102101

103-
private Future<Connection> doConnect(SocketAddress server, EventLoopContext context, PgConnectOptions options) {
102+
private Future<Connection> doConnect(SocketAddress server, ContextInternal context, PgConnectOptions options) {
104103
SslMode sslMode = options.isUsingDomainSocket() ? SslMode.DISABLE : options.getSslMode();
105104
Future<Connection> connFuture;
106105
switch (sslMode) {
@@ -124,7 +123,7 @@ private Future<Connection> doConnect(SocketAddress server, EventLoopContext cont
124123
return connFuture;
125124
}
126125

127-
private Future<Connection> doConnect(SocketAddress server, EventLoopContext context, boolean ssl, PgConnectOptions options) {
126+
private Future<Connection> doConnect(SocketAddress server, ContextInternal context, boolean ssl, PgConnectOptions options) {
128127
Future<NetSocket> soFut;
129128
try {
130129
soFut = netClient(options).connect(server, (String) null);
@@ -166,7 +165,7 @@ public Future<SqlConnection> connect(Context context, SqlConnectOptions options)
166165
return promise.future();
167166
}
168167

169-
private PgSocketConnection newSocketConnection(EventLoopContext context, NetSocketInternal socket, PgConnectOptions options) {
168+
private PgSocketConnection newSocketConnection(ContextInternal context, NetSocketInternal socket, PgConnectOptions options) {
170169
boolean cachePreparedStatements = options.getCachePreparedStatements();
171170
int preparedStatementCacheMaxSize = options.getPreparedStatementCacheMaxSize();
172171
Predicate<String> preparedStatementCacheSqlFilter = options.getPreparedStatementCacheSqlFilter();

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/PgSocketConnection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import io.vertx.core.Handler;
2525
import io.vertx.core.Promise;
2626
import io.vertx.core.buffer.Buffer;
27-
import io.vertx.core.impl.EventLoopContext;
27+
import io.vertx.core.impl.ContextInternal;
2828
import io.vertx.core.net.impl.NetSocketInternal;
2929
import io.vertx.core.spi.metrics.ClientMetrics;
3030
import io.vertx.pgclient.PgConnectOptions;
@@ -66,7 +66,7 @@ public PgSocketConnection(NetSocketInternal socket,
6666
Predicate<String> preparedStatementCacheSqlFilter,
6767
int pipeliningLimit,
6868
boolean useLayer7Proxy,
69-
EventLoopContext context) {
69+
ContextInternal context) {
7070
super(socket, metrics, cachePreparedStatements, preparedStatementCacheSize, preparedStatementCacheSqlFilter, pipeliningLimit, context);
7171
this.connectOptions = connectOptions;
7272
this.useLayer7Proxy = useLayer7Proxy;

vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/ConnectionFactoryBase.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import io.vertx.core.Promise;
1616
import io.vertx.core.impl.CloseFuture;
1717
import io.vertx.core.impl.ContextInternal;
18-
import io.vertx.core.impl.EventLoopContext;
1918
import io.vertx.core.impl.VertxInternal;
2019
import io.vertx.core.impl.future.PromiseInternal;
2120
import io.vertx.core.json.JsonObject;
@@ -71,15 +70,15 @@ protected NetClient netClient(NetClientOptions options) {
7170
return client;
7271
}
7372

74-
public static EventLoopContext asEventLoopContext(ContextInternal ctx) {
75-
if (ctx instanceof EventLoopContext) {
76-
return (EventLoopContext) ctx;
73+
public static ContextInternal asEventLoopContext(ContextInternal ctx) {
74+
if (ctx.isEventLoopContext()) {
75+
return ctx;
7776
} else {
7877
return ctx.owner().createEventLoopContext(ctx.nettyEventLoop(), ctx.workerPool(), ctx.classLoader());
7978
}
8079
}
8180

82-
public Future<Connection> connect(EventLoopContext context, SqlConnectOptions options) {
81+
public Future<Connection> connect(ContextInternal context, SqlConnectOptions options) {
8382
PromiseInternal<Connection> promise = context.promise();
8483
context.emit(promise, p -> doConnectWithRetry(options, p, options.getReconnectAttempts()));
8584
return promise.future();
@@ -96,7 +95,7 @@ public void close(Promise<Void> promise) {
9695
}
9796

9897
private void doConnectWithRetry(SqlConnectOptions options, PromiseInternal<Connection> promise, int remainingAttempts) {
99-
EventLoopContext ctx = (EventLoopContext) promise.context();
98+
ContextInternal ctx = promise.context();
10099
doConnectInternal(options, ctx).onComplete(ar -> {
101100
if (ar.succeeded()) {
102101
promise.complete(ar.result());
@@ -115,6 +114,6 @@ private void doConnectWithRetry(SqlConnectOptions options, PromiseInternal<Conne
115114
/**
116115
* Establish a connection to the server.
117116
*/
118-
protected abstract Future<Connection> doConnectInternal(SqlConnectOptions options, EventLoopContext context);
117+
protected abstract Future<Connection> doConnectInternal(SqlConnectOptions options, ContextInternal context);
119118

120119
}

vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/SocketConnectionBase.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import io.vertx.core.Vertx;
3030
import io.vertx.core.VertxException;
3131
import io.vertx.core.impl.ContextInternal;
32-
import io.vertx.core.impl.EventLoopContext;
3332
import io.vertx.core.impl.NoStackTraceThrowable;
3433
import io.vertx.core.impl.logging.Logger;
3534
import io.vertx.core.impl.logging.LoggerFactory;
@@ -64,7 +63,7 @@ public enum Status {
6463

6564
private final ClientMetrics metrics;
6665
protected final PreparedStatementCache psCache;
67-
protected final EventLoopContext context;
66+
protected final ContextInternal context;
6867
private final Predicate<String> preparedStatementCacheSqlFilter;
6968
private Holder holder;
7069
private final int pipeliningLimit;
@@ -84,7 +83,7 @@ public SocketConnectionBase(NetSocketInternal socket,
8483
int preparedStatementCacheSize,
8584
Predicate<String> preparedStatementCacheSqlFilter,
8685
int pipeliningLimit,
87-
EventLoopContext context) {
86+
ContextInternal context) {
8887
this.socket = socket;
8988
this.context = context;
9089
this.pipeliningLimit = pipeliningLimit;

0 commit comments

Comments
 (0)