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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user