use of io.vertx.mysqlclient.MySQLConnectOptions in project vertx-sql-client by eclipse-vertx.
the class MySQLRule method startServer.
public synchronized MySQLConnectOptions startServer() throws Exception {
initServer();
server.start();
return new MySQLConnectOptions().setPort(server.getMappedPort(3306)).setHost(server.getContainerIpAddress()).setDatabase("testschema").setUser("mysql").setPassword("password");
}
use of io.vertx.mysqlclient.MySQLConnectOptions in project vertx-sql-client by eclipse-vertx.
the class MySQLConnectionAutoRetryTest method initialConnector.
@Override
protected void initialConnector(int proxyPort) {
SqlConnectOptions proxyOptions = new MySQLConnectOptions(options);
proxyOptions.setPort(proxyPort);
proxyOptions.setHost("localhost");
connectionConnector = ClientConfig.CONNECT.connect(vertx, proxyOptions);
poolConnector = ClientConfig.POOLED.connect(vertx, proxyOptions);
}
use of io.vertx.mysqlclient.MySQLConnectOptions 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;
}
use of io.vertx.mysqlclient.MySQLConnectOptions in project vertx-sql-client by eclipse-vertx.
the class MySQLDataTypeTestBase method setup.
@Before
public void setup() {
vertx = Vertx.vertx();
options = new MySQLConnectOptions(MySQLTestBase.options);
}
use of io.vertx.mysqlclient.MySQLConnectOptions in project vertx-sql-client by eclipse-vertx.
the class MySQLConnectionFactory method initializeConfiguration.
@Override
protected void initializeConfiguration(SqlConnectOptions connectOptions) {
if (!(connectOptions instanceof MySQLConnectOptions)) {
throw new IllegalArgumentException("mismatched connect options type");
}
MySQLConnectOptions options = (MySQLConnectOptions) connectOptions;
MySQLCollation collation;
if (options.getCollation() != null) {
// override the collation if configured
collation = MySQLCollation.valueOfName(options.getCollation());
charsetEncoding = Charset.forName(collation.mappedJavaCharsetName());
} else {
String charset = options.getCharset();
if (charset == null) {
collation = MySQLCollation.DEFAULT_COLLATION;
} else {
collation = MySQLCollation.valueOfName(MySQLCollation.getDefaultCollationFromCharsetName(charset));
}
String characterEncoding = options.getCharacterEncoding();
if (characterEncoding == null) {
charsetEncoding = Charset.defaultCharset();
} else {
charsetEncoding = Charset.forName(options.getCharacterEncoding());
}
}
this.collation = collation;
this.useAffectedRows = options.isUseAffectedRows();
this.sslMode = options.isUsingDomainSocket() ? SslMode.DISABLED : options.getSslMode();
this.authenticationPlugin = options.getAuthenticationPlugin();
// server RSA public key
Buffer serverRsaPublicKey = null;
if (options.getServerRsaPublicKeyValue() != null) {
serverRsaPublicKey = options.getServerRsaPublicKeyValue();
} else {
if (options.getServerRsaPublicKeyPath() != null) {
serverRsaPublicKey = vertx.fileSystem().readFileBlocking(options.getServerRsaPublicKeyPath());
}
}
this.serverRsaPublicKey = serverRsaPublicKey;
// check the SSLMode here
switch(sslMode) {
case VERIFY_IDENTITY:
String hostnameVerificationAlgorithm = options.getHostnameVerificationAlgorithm();
if (hostnameVerificationAlgorithm == null || hostnameVerificationAlgorithm.isEmpty()) {
throw new IllegalArgumentException("Host verification algorithm must be specified under VERIFY_IDENTITY ssl-mode.");
}
case VERIFY_CA:
TrustOptions trustOptions = options.getTrustOptions();
if (trustOptions == null) {
throw new IllegalArgumentException("Trust options must be specified under " + sslMode.name() + " ssl-mode.");
}
break;
}
}
Aggregations