Search in sources :

Example 1 with MySQLDatasourcePool

use of io.mycat.proxy.MySQLDatasourcePool in project Mycat2 by MyCATApache.

the class NativeDatasourcePoolImpl method getAvailableNumber.

@Override
public Integer getAvailableNumber() {
    NativeMycatServer nativeMycatServer = MetaClusterCurrent.wrapper(NativeMycatServer.class);
    MySQLDatasourcePool sqlDatasourcePool = nativeMycatServer.getDatasource(targetName);
    return sqlDatasourcePool.getSessionLimitCount() - sqlDatasourcePool.currentSessionCount();
}
Also used : MySQLDatasourcePool(io.mycat.proxy.MySQLDatasourcePool) NativeMycatServer(io.mycat.NativeMycatServer)

Example 2 with MySQLDatasourcePool

use of io.mycat.proxy.MySQLDatasourcePool in project Mycat2 by MyCATApache.

the class NativeDatasourcePoolImpl method close.

@Override
public void close() {
    NativeMycatServer nativeMycatServer = MetaClusterCurrent.wrapper(NativeMycatServer.class);
    MySQLDatasourcePool sqlDatasourcePool = nativeMycatServer.getDatasource(targetName);
    sqlDatasourcePool.close();
}
Also used : MySQLDatasourcePool(io.mycat.proxy.MySQLDatasourcePool) NativeMycatServer(io.mycat.NativeMycatServer)

Example 3 with MySQLDatasourcePool

use of io.mycat.proxy.MySQLDatasourcePool in project Mycat2 by MyCATApache.

the class NativeDatasourcePoolImpl method getUsedNumber.

@Override
public Integer getUsedNumber() {
    NativeMycatServer nativeMycatServer = MetaClusterCurrent.wrapper(NativeMycatServer.class);
    MySQLDatasourcePool sqlDatasourcePool = nativeMycatServer.getDatasource(targetName);
    return sqlDatasourcePool.currentSessionCount();
}
Also used : MySQLDatasourcePool(io.mycat.proxy.MySQLDatasourcePool) NativeMycatServer(io.mycat.NativeMycatServer)

Example 4 with MySQLDatasourcePool

use of io.mycat.proxy.MySQLDatasourcePool in project Mycat2 by MyCATApache.

the class NativeMycatServer method getDatasource.

public MySQLDatasourcePool getDatasource(String name) {
    MySQLDatasourcePool datasource = datasourceMap.get(name);
    if (datasource != null) {
        return datasource;
    }
    DatasourceConfig datasourceConfig = Objects.requireNonNull(datasourceConfigProvider.get()).get(name);
    if (datasourceConfig != null && "mysql".equalsIgnoreCase(datasourceConfig.getDbType())) {
        return datasourceMap.computeIfAbsent(name, s -> {
            MySQLDatasourcePool mySQLDatasource = new MySQLDatasourcePool(name, datasourceConfigProvider, this);
            return mySQLDatasource;
        });
    }
    return null;
}
Also used : MySQLDatasourcePool(io.mycat.proxy.MySQLDatasourcePool)

Aggregations

MySQLDatasourcePool (io.mycat.proxy.MySQLDatasourcePool)4 NativeMycatServer (io.mycat.NativeMycatServer)3