增强监控

git-svn-id: http://code.alibabatech.com/svn/druid/trunk@930 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-10-09 03:40:19 +00:00
parent 3d2f627b11
commit 6820a7f52b
5 changed files with 57 additions and 27 deletions
@@ -181,6 +181,8 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
protected final AtomicLong startTransactionCount = new AtomicLong();
protected final AtomicLong rollbackCount = new AtomicLong();
protected final AtomicLong reusePreparedStatement = new AtomicLong();
protected final AtomicLong preparedStatementCount = new AtomicLong();
protected final AtomicLong closedPreparedStatementCount = new AtomicLong();
protected final Histogram transactionHistogram = new Histogram(
10,
@@ -192,8 +194,20 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
public Histogram getTransactionHistogram() {
return transactionHistogram;
}
public void incrementClosedPreparedStatementCount() {
closedPreparedStatementCount.incrementAndGet();
}
public void incrementPreparedStatementCount() {
preparedStatementCount.incrementAndGet();
}
public long getPreparedStatementCount() {
return preparedStatementCount.get();
}
public void incrementReusePreparedStatementCount() {
reusePreparedStatement.incrementAndGet();
}
@@ -1309,4 +1323,13 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
throw new SQLFeatureNotSupportedException();
}
public void closePreapredStatement(PreparedStatementHolder stmtHolder) {
if (stmtHolder == null) {
return;
}
closedPreparedStatementCount.incrementAndGet();
JdbcUtils.close(stmtHolder.getStatement());
}
}