Search in sources :

Example 1 with BackendConCreateHandler

use of io.mycat.proxy.handler.backend.BackendConCreateHandler in project Mycat2 by MyCATApache.

the class MySQLDatasourcePool method innerCreateCon.

private Future<MySQLClientSession> innerCreateCon() {
    PromiseInternal<MySQLClientSession> promise = VertxUtil.newPromise();
    new BackendConCreateHandler(this, promise);
    return promise.flatMap(session -> {
        synchronized (allSessions) {
            allSessions.add(session);
        }
        MySQLDatasource datasource = session.getDatasource();
        String sql = datasource.getInitSqlForProxy();
        if (!StringUtil.isEmpty(sql)) {
            PromiseInternal<MySQLClientSession> promiseInternal = VertxUtil.newPromise();
            ResultSetHandler.DEFAULT.request(session, COM_QUERY, sql.getBytes(StandardCharsets.UTF_8), promiseInternal);
            return promiseInternal.onFailure(event -> {
                session.close(false, "initSql fail");
            });
        } else {
            return Future.succeededFuture(session);
        }
    });
}
Also used : BackendConCreateHandler(io.mycat.proxy.handler.backend.BackendConCreateHandler) MySQLDatasource(io.mycat.beans.MySQLDatasource) MySQLClientSession(io.mycat.proxy.session.MySQLClientSession)

Aggregations

MySQLDatasource (io.mycat.beans.MySQLDatasource)1 BackendConCreateHandler (io.mycat.proxy.handler.backend.BackendConCreateHandler)1 MySQLClientSession (io.mycat.proxy.session.MySQLClientSession)1