mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add stat CachedPreparedStatementMissCount
This commit is contained in:
@@ -187,7 +187,8 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
|
||||
protected final AtomicLong preparedStatementCount = new AtomicLong();
|
||||
protected final AtomicLong closedPreparedStatementCount = new AtomicLong();
|
||||
protected final AtomicLong cachedPreparedStatementCount = new AtomicLong();
|
||||
protected final AtomicLong cachedPreparedStatementDeleteCount = new AtomicLong();
|
||||
protected final AtomicLong cachedPreparedStatementDeleteCount = new AtomicLong();
|
||||
protected final AtomicLong cachedPreparedStatementMissCount = new AtomicLong();
|
||||
|
||||
protected final Histogram transactionHistogram = new Histogram(
|
||||
10,
|
||||
@@ -255,11 +256,19 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
|
||||
public void decrementCachedPreparedStatementCount() {
|
||||
cachedPreparedStatementCount.decrementAndGet();
|
||||
}
|
||||
|
||||
|
||||
public void incrementCachedPreparedStatementDeleteCount() {
|
||||
cachedPreparedStatementDeleteCount.incrementAndGet();
|
||||
}
|
||||
|
||||
public void incrementCachedPreparedStatementMissCount() {
|
||||
cachedPreparedStatementMissCount.incrementAndGet();
|
||||
}
|
||||
|
||||
public long getCachedPreparedStatementMissCount() {
|
||||
return cachedPreparedStatementMissCount.get();
|
||||
}
|
||||
|
||||
public long getCachedPreparedStatementDeleteCount() {
|
||||
return cachedPreparedStatementDeleteCount.get();
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ public class PreparedStatementPool {
|
||||
|
||||
if (holder != null) {
|
||||
holder.incrementReusedCount();
|
||||
} else {
|
||||
dataSource.incrementCachedPreparedStatementMissCount();
|
||||
}
|
||||
|
||||
return holder;
|
||||
@@ -90,6 +92,7 @@ public class PreparedStatementPool {
|
||||
if (remove) {
|
||||
dataSource.closePreapredStatement(eldest.getValue());
|
||||
dataSource.decrementCachedPreparedStatementCount();
|
||||
dataSource.incrementCachedPreparedStatementDeleteCount();
|
||||
}
|
||||
|
||||
return remove;
|
||||
|
||||
@@ -201,6 +201,8 @@ public class DruidDataSourceStatManager implements DruidDataSourceStatManagerMBe
|
||||
map.put("LastError", JMXUtils.getErrorCompositeData(dataSource.getLastError()));
|
||||
map.put("LastCreateError", JMXUtils.getErrorCompositeData(dataSource.getCreateError()));
|
||||
map.put("PreparedStatementCacheDeleteCount", dataSource.getCachedPreparedStatementDeleteCount());
|
||||
|
||||
map.put("PreparedStatementCacheMissCount", dataSource.getCachedPreparedStatementMissCount());
|
||||
map.put("Version", dataSource.getVersion());
|
||||
|
||||
return new CompositeDataSupport(rowType, map);
|
||||
@@ -223,7 +225,7 @@ public class DruidDataSourceStatManager implements DruidDataSourceStatManagerMBe
|
||||
SimpleType.STRING, SimpleType.INTEGER, SimpleType.STRING, SimpleType.STRING, SimpleType.LONG, //
|
||||
SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG//
|
||||
, SimpleType.LONG, SimpleType.LONG, JMXUtils.getThrowableCompositeType(), JMXUtils.getThrowableCompositeType(), SimpleType.LONG //
|
||||
, SimpleType.STRING
|
||||
, SimpleType.LONG, SimpleType.STRING
|
||||
//
|
||||
};
|
||||
|
||||
@@ -242,7 +244,7 @@ public class DruidDataSourceStatManager implements DruidDataSourceStatManagerMBe
|
||||
"NotEmptyWaitCount", "NotEmptyWaitNanos", "ErrorCount", "ReusePreparedStatementCount",
|
||||
"StartTransactionCount", //
|
||||
"CommitCount", "RollbackCount", "LastError", "LastCreateError", "PreparedStatementCacheDeleteCount" //
|
||||
, "Version"
|
||||
, "CachedPreparedStatementMissCount", "Version"
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user