mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
JMX增强
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@683 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -79,4 +79,6 @@ public interface DruidAbstractDataSourceMBean {
|
||||
long getTimeBetweenConnectErrorMillis();
|
||||
|
||||
int getMaxOpenPreparedStatements();
|
||||
|
||||
long getRemoveAbandonedCount();
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
private long recycleCount = 0L;
|
||||
private long createConnectionCount = 0L;
|
||||
private long destroyCount = 0L;
|
||||
private long removeAbandonedCount = 0L;
|
||||
|
||||
// store
|
||||
private ConnectionHolder[] connections;
|
||||
@@ -100,6 +101,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
recycleCount = 0;
|
||||
createConnectionCount = 0;
|
||||
destroyCount = 0;
|
||||
removeAbandonedCount = 0;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
@@ -644,6 +646,10 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
return activeCount;
|
||||
}
|
||||
|
||||
public long getRemoveAbandonedCount() {
|
||||
return removeAbandonedCount;
|
||||
}
|
||||
|
||||
public class CreateConnectionThread extends Thread {
|
||||
|
||||
public CreateConnectionThread(String name){
|
||||
@@ -702,7 +708,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
if (breakAfterAcquireFailure) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
Thread.sleep(timeBetweenConnectErrorMillis);
|
||||
} catch (InterruptedException interruptEx) {
|
||||
@@ -774,6 +780,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
if (timeMillis >= removeAbandonedTimeoutMillis) {
|
||||
PoolableConnection pooledConnection = entry.getKey();
|
||||
JdbcUtils.close(pooledConnection);
|
||||
removeAbandonedCount++;
|
||||
|
||||
if (isLogAbandoned()) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
@@ -95,6 +95,7 @@ public class DruidDataSourceStatManager implements DruidDataSourceStatManagerMBe
|
||||
map.put("ValidationQueryTimeout", dataSource.getValidationQueryTimeout());
|
||||
map.put("DriverClassName", dataSource.getDriverClassName());
|
||||
map.put("Username", dataSource.getUsername());
|
||||
map.put("RemoveAbandonedCount", dataSource.getRemoveAbandonedCount());
|
||||
|
||||
return new CompositeDataSupport(rowType, map);
|
||||
}
|
||||
@@ -113,7 +114,7 @@ public class DruidDataSourceStatManager implements DruidDataSourceStatManagerMBe
|
||||
SimpleType.LONG, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, //
|
||||
SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.BOOLEAN, SimpleType.BOOLEAN, //
|
||||
SimpleType.BOOLEAN, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.STRING, //
|
||||
SimpleType.STRING, SimpleType.INTEGER, SimpleType.STRING, SimpleType.STRING,
|
||||
SimpleType.STRING, SimpleType.INTEGER, SimpleType.STRING, SimpleType.STRING, SimpleType.LONG,
|
||||
//
|
||||
};
|
||||
|
||||
@@ -123,7 +124,7 @@ public class DruidDataSourceStatManager implements DruidDataSourceStatManagerMBe
|
||||
"CloseCount", "ActiveCount", "PoolingCount", "LockQueueLength", "WaitThreadCount", //
|
||||
"InitialSize", "MaxActive", "MinIdle", "PoolPreparedStatements", "TestOnBorrow", //
|
||||
"TestOnReturn", "MinEvictableIdleTimeMillis", "ConnectErrorCount", "CreateTimespanMillis", "DbType", //
|
||||
"ValidationQuery", "ValidationQueryTimeout", "DriverClassName", "Username"
|
||||
"ValidationQuery", "ValidationQueryTimeout", "DriverClassName", "Username", "RemoveAbandonedCount"
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user