Search in sources :

Example 1 with MySQLConnectOptions

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");
}
Also used : MySQLConnectOptions(io.vertx.mysqlclient.MySQLConnectOptions)

Example 2 with MySQLConnectOptions

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);
}
Also used : SqlConnectOptions(io.vertx.sqlclient.SqlConnectOptions) MySQLConnectOptions(io.vertx.mysqlclient.MySQLConnectOptions)

Example 3 with MySQLConnectOptions

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;
}
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 4 with MySQLConnectOptions

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);
}
Also used : MySQLConnectOptions(io.vertx.mysqlclient.MySQLConnectOptions) Before(org.junit.Before)

Example 5 with MySQLConnectOptions

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;
    }
}
Also used : Buffer(io.vertx.core.buffer.Buffer) MySQLConnectOptions(io.vertx.mysqlclient.MySQLConnectOptions)

Aggregations

MySQLConnectOptions (io.vertx.mysqlclient.MySQLConnectOptions)17 PoolOptions (io.vertx.sqlclient.PoolOptions)9 MySQLPool (io.vertx.mysqlclient.MySQLPool)4 Before (org.junit.Before)4 io.vertx.core (io.vertx.core)2 Buffer (io.vertx.core.buffer.Buffer)2 MySQLConnectionImpl (io.vertx.mysqlclient.impl.MySQLConnectionImpl)2 SqlConnectOptions (io.vertx.sqlclient.SqlConnectOptions)2 List (java.util.List)2 SQLUtils (com.alibaba.druid.sql.SQLUtils)1 SQLReplaceable (com.alibaba.druid.sql.ast.SQLReplaceable)1 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)1 SQLVariantRefExpr (com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr)1 MySqlASTVisitorAdapter (com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitorAdapter)1 ImmutableList (com.google.common.collect.ImmutableList)1 RowBaseIterator (io.mycat.api.collector.RowBaseIterator)1 MycatTest (io.mycat.assemble.MycatTest)1 MycatMySQLRowMetaData (io.mycat.beans.mycat.MycatMySQLRowMetaData)1 MycatRelDataType (io.mycat.beans.mycat.MycatRelDataType)1 MycatRowMetaData (io.mycat.beans.mycat.MycatRowMetaData)1