mirror of
https://github.com/actiontech/dble.git
synced 2026-01-07 21:30:22 -06:00
#1064 correct active into totalCount in physicalDatasource
This commit is contained in:
@@ -376,7 +376,7 @@ public class PhysicalDBPool {
|
||||
// long timeOut = start + 5000 * 1000L;
|
||||
boolean hasConnectionInPool = false;
|
||||
try {
|
||||
if (ds.getActiveCount() <= 0) {
|
||||
if (ds.getTotalConCount() <= 0) {
|
||||
ds.initMinConnection(null, true, getConHandler, null);
|
||||
} else {
|
||||
LOGGER.info("connection with null schema do not create,because testConnection in pool");
|
||||
|
||||
@@ -184,22 +184,14 @@ public abstract class PhysicalDatasource {
|
||||
|
||||
//the following is about the idle connection number control
|
||||
int idleCons = getIdleCount();
|
||||
int activeCons = this.getActiveCount();
|
||||
int totalCount = this.getTotalConCount();
|
||||
int createCount = (hostConfig.getMinCon() - idleCons) / 3;
|
||||
|
||||
// create if idle too little
|
||||
if ((createCount > 0) && (idleCons + activeCons < size)) {
|
||||
if ((createCount > 0) && totalCount < size) {
|
||||
createByIdleLittle(idleCons, createCount);
|
||||
} else if (idleCons > hostConfig.getMinCon()) {
|
||||
closeByIdleMany(idleCons - hostConfig.getMinCon(), idleCons);
|
||||
} else {
|
||||
int activeCount = this.getActiveCount();
|
||||
if (activeCount > size) {
|
||||
String s = "DATASOURCE EXCEED [name=" + name +
|
||||
",active=" + activeCount +
|
||||
",size=" + size + ']';
|
||||
LOGGER.info(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,15 +243,14 @@ public abstract class PhysicalDatasource {
|
||||
|
||||
final String[] schemas = dbPool.getSchemas();
|
||||
for (int i = 0; i < createCount; i++) {
|
||||
if (this.getActiveCount() + this.getIdleCount() >= size) {
|
||||
break;
|
||||
}
|
||||
NewConnectionRespHandler simpleHandler = new NewConnectionRespHandler();
|
||||
try {
|
||||
if (this.createNewCount()) {
|
||||
// creat new connection
|
||||
this.createNewConnection(simpleHandler, null, schemas[i % schemas.length]);
|
||||
simpleHandler.getBackConn().release();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
if (ToResolveContainer.CREATE_CONN_FAIL.contains(this.getHostConfig().getName() + "-" + this.getConfig().getHostName())) {
|
||||
Map<String, String> labels = AlertUtil.genSingleLabel("data_host", this.getHostConfig().getName() + "-" + this.getConfig().getHostName());
|
||||
@@ -277,7 +268,7 @@ public abstract class PhysicalDatasource {
|
||||
}
|
||||
}
|
||||
|
||||
public int getActiveCount() {
|
||||
public int getTotalConCount() {
|
||||
return this.connectionCount.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -144,12 +144,13 @@ public final class ShowDataSource {
|
||||
String charset) {
|
||||
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
|
||||
//row.add(StringUtil.encode(dataNode, charset));
|
||||
int idleCount = ds.getIdleCount();
|
||||
row.add(StringUtil.encode(ds.getName(), charset));
|
||||
row.add(StringUtil.encode(ds.getConfig().getIp(), charset));
|
||||
row.add(IntegerUtil.toBytes(ds.getConfig().getPort()));
|
||||
row.add(StringUtil.encode(ds.isReadNode() ? "R" : "W", charset));
|
||||
row.add(IntegerUtil.toBytes(ds.getActiveCount()));
|
||||
row.add(IntegerUtil.toBytes(ds.getIdleCount()));
|
||||
row.add(IntegerUtil.toBytes(ds.getTotalConCount() - idleCount));
|
||||
row.add(IntegerUtil.toBytes(idleCount));
|
||||
row.add(IntegerUtil.toBytes(ds.getSize()));
|
||||
row.add(LongUtil.toBytes(ds.getExecuteCount()));
|
||||
row.add(LongUtil.toBytes(ds.getReadCount()));
|
||||
|
||||
Reference in New Issue
Block a user