mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add blob open count stat
This commit is contained in:
@@ -507,7 +507,7 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
if (index != 0) {
|
||||
out.writeComma();
|
||||
}
|
||||
|
||||
|
||||
Object value = parameter.getValue();
|
||||
if (value == null) {
|
||||
out.writeNull();
|
||||
@@ -685,6 +685,30 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
return clob;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Blob callableStatement_getBlob(FilterChain chain, CallableStatementProxy statement, int parameterIndex)
|
||||
throws SQLException {
|
||||
Blob blob = chain.callableStatement_getBlob(statement, parameterIndex);
|
||||
|
||||
if (blob != null) {
|
||||
blobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, blob);
|
||||
}
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Blob callableStatement_getBlob(FilterChain chain, CallableStatementProxy statement, String parameterName)
|
||||
throws SQLException {
|
||||
Blob blob = chain.callableStatement_getBlob(statement, parameterName);
|
||||
|
||||
if (blob != null) {
|
||||
blobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, blob);
|
||||
}
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Clob callableStatement_getClob(FilterChain chain, CallableStatementProxy statement, int parameterIndex)
|
||||
throws SQLException {
|
||||
@@ -776,6 +800,10 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
clobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, (ClobProxy) obj);
|
||||
}
|
||||
|
||||
if (obj instanceof Blob) {
|
||||
blobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, (Blob) obj);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -788,6 +816,10 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
clobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, (ClobProxy) obj);
|
||||
}
|
||||
|
||||
if (obj instanceof Blob) {
|
||||
blobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, (Blob) obj);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -801,6 +833,10 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
clobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, (ClobProxy) obj);
|
||||
}
|
||||
|
||||
if (obj instanceof Blob) {
|
||||
blobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, (Blob) obj);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -808,6 +844,10 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
clobOpenAfter(dataSourceStat, rs.getStatementProxy(), clob);
|
||||
}
|
||||
|
||||
private void blobOpenAfter(JdbcDataSourceStat dataSourceStat, StatementProxy stmt, Blob blob) {
|
||||
dataSourceStat.incrementBlobOpenCount();
|
||||
}
|
||||
|
||||
private void clobOpenAfter(JdbcDataSourceStat dataSourceStat, StatementProxy stmt, ClobProxy clob) {
|
||||
dataSourceStat.incrementClobOpenCount();
|
||||
|
||||
|
||||
@@ -815,7 +815,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
discardConnection(holder.getConnection());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final long lastActiveTimeMillis = System.currentTimeMillis();
|
||||
lock.lockInterruptibly();
|
||||
try {
|
||||
@@ -1774,6 +1774,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
dataMap.put("ConnectionHoldTimeHistogram", this.getDataSourceStat().getConnectionHoldHistogram().toArray());
|
||||
dataMap.put("RemoveAbandoned", this.isRemoveAbandoned());
|
||||
dataMap.put("ClobOpenCount", this.getDataSourceStat().getClobOpenCount());
|
||||
dataMap.put("BlobOpenCount", this.getDataSourceStat().getBlobOpenCount());
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
@@ -68,6 +68,8 @@ public class JdbcDataSourceStat implements JdbcDataSourceStatMBean {
|
||||
|
||||
private final AtomicLong clobOpenCount = new AtomicLong();
|
||||
|
||||
private final AtomicLong blobOpenCount = new AtomicLong();
|
||||
|
||||
public JdbcDataSourceStat(String name, String url){
|
||||
this(name, url, null);
|
||||
}
|
||||
@@ -101,6 +103,7 @@ public class JdbcDataSourceStat implements JdbcDataSourceStatMBean {
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
blobOpenCount.set(0);
|
||||
clobOpenCount.set(0);
|
||||
|
||||
connectionStat.reset();
|
||||
@@ -318,4 +321,12 @@ public class JdbcDataSourceStat implements JdbcDataSourceStatMBean {
|
||||
clobOpenCount.incrementAndGet();
|
||||
}
|
||||
|
||||
public long getBlobOpenCount() {
|
||||
return blobOpenCount.get();
|
||||
}
|
||||
|
||||
public void incrementBlobOpenCount() {
|
||||
blobOpenCount.incrementAndGet();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
"NotEmptyWaitMillis", "WaitThreadCount", "StartTransactionCount", "TransactionHistogram", "PoolingCount", "PoolingPeak",
|
||||
"PoolingPeakTime", "ActiveCount", "ActivePeak", "ActivePeakTime", "LogicConnectCount", "LogicCloseCount", "LogicConnectErrorCount",
|
||||
"PhysicalConnectCount", "PhysicalCloseCount", "PhysicalConnectErrorCount", "ExecuteCount", "ErrorCount", "CommitCount",
|
||||
"RollbackCount", "PSCacheAccessCount", "PSCacheHitCount", "PSCacheMissCount", "ConnectionHoldTimeHistogram"]
|
||||
"RollbackCount", "PSCacheAccessCount", "PSCacheHitCount", "PSCacheMissCount", "ConnectionHoldTimeHistogram",
|
||||
"ClobOpenCount", "BlobOpenCount"
|
||||
]
|
||||
var descs = ["Specify the username used when creating a new connection.",
|
||||
"The JDBC driver connection URL", "database type", "The fully qualifed name of the JDBC driver class",
|
||||
"All the fully qualifed name of the filter classes", " Test or not when borrow a connection", "Test or not when return a connection",
|
||||
@@ -42,7 +44,9 @@
|
||||
"The usefull connection peak time", "The current active connection count", "The current active connection peak count", "The active connection peak time",
|
||||
"Total connect times from datasource", "Total close connect times from datasource", "Total connect error times",
|
||||
"Create physical connnection count", "Close physical connnection count", "Total physical connect error times", "", "", "",
|
||||
"", "PerpareStatement access count", "PerpareStatement hit count", "PerpareStatement miss count", "The histogram values of connection hold time, [0-1 ms, 1-10 ms, 10-100 ms, 100ms-1s, 1-10 s, 10-100 s, 100-1000 s, >1000 s]"]
|
||||
"", "PerpareStatement access count", "PerpareStatement hit count", "PerpareStatement miss count", "The histogram values of connection hold time, [0-1 ms, 1-10 ms, 10-100 ms, 100ms-1s, 1-10 s, 10-100 s, 100-1000 s, >1000 s]",
|
||||
"", ""
|
||||
]
|
||||
return {
|
||||
init : function() {
|
||||
druid.common.buildHead(1);
|
||||
|
||||
Reference in New Issue
Block a user