use of com.actiontech.dble.backend.mysql.nio.handler.NewConnectionRespHandler in project dble by actiontech.
the class PhysicalDatasource method getConnection.
public BackendConnection getConnection(String schema, boolean autocommit) throws IOException {
BackendConnection con = this.conMap.tryTakeCon(schema, autocommit);
if (con == null) {
// the max active
int activeCons = this.getActiveCount();
if (activeCons + 1 > size) {
LOGGER.warn(AlarmCode.CORE_PERFORMANCE_WARN + "the max activeConnnections size can not be max than maxconnections");
throw new IOException("the max activeConnnections size can not be max than maxconnections");
} else {
// create connection
LOGGER.info("no ilde connection in pool,create new connection for " + this.name + " of schema " + schema);
NewConnectionRespHandler simpleHandler = new NewConnectionRespHandler();
this.createNewConnection(simpleHandler, schema);
con = simpleHandler.getBackConn();
}
}
return takeCon(con, schema);
}
use of com.actiontech.dble.backend.mysql.nio.handler.NewConnectionRespHandler in project dble by actiontech.
the class PhysicalDatasource method createByIdleLittle.
private void createByIdleLittle(int idleCons, int createCount) {
LOGGER.info("create connections ,because idle connection not enough ,cur is " + idleCons + ", minCon is " + hostConfig.getMinCon() + " for " + name);
final String[] schemas = dbPool.getSchemas();
for (int i = 0; i < createCount; i++) {
if (this.getActiveCount() + this.getIdleCount() >= size) {
break;
}
NewConnectionRespHandler simpleHandler = new NewConnectionRespHandler();
try {
// creat new connection
this.createNewConnection(simpleHandler, null, schemas[i % schemas.length]);
simpleHandler.getBackConn().release();
} catch (IOException e) {
LOGGER.info("create connection err " + e);
}
}
}
Aggregations