事务时间直方图

git-svn-id: http://code.alibabatech.com/svn/druid/trunk@847 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-09-19 02:00:12 +00:00
parent 7d60b388da
commit 9d0c7d6ee7
3 changed files with 138 additions and 37 deletions
@@ -140,6 +140,7 @@ public class PoolableConnection implements PooledConnection, Connection {
this.holder = null;
conn = null;
startTransactionTimeMillis = 0;
}
// ////////////////////
@@ -566,12 +567,16 @@ public class PoolableConnection implements PooledConnection, Connection {
public void commit() throws SQLException {
checkOpen();
holder.getDataSource().incrementCommitCount();
DruidAbstractDataSource dataSource = holder.getDataSource();
dataSource.incrementCommitCount();
try {
conn.commit();
} catch (SQLException ex) {
handleException(ex);
} finally {
long transactionMillis = System.currentTimeMillis() - startTransactionTimeMillis;
dataSource.getTransactionHistogram().recode(transactionMillis);
startTransactionTimeMillis = 0;
}
}
@@ -584,14 +589,62 @@ public class PoolableConnection implements PooledConnection, Connection {
public void rollback() throws SQLException {
checkOpen();
holder.getDataSource().incrementRollbackCount();
DruidAbstractDataSource dataSource = holder.getDataSource();
dataSource.incrementRollbackCount();
try {
conn.rollback();
} catch (SQLException ex) {
handleException(ex);
} finally {
long transactionMillis = System.currentTimeMillis() - startTransactionTimeMillis;
dataSource.getTransactionHistogram().recode(transactionMillis);
startTransactionTimeMillis = 0;
}
}
@Override
public Savepoint setSavepoint(String name) throws SQLException {
checkOpen();
return conn.setSavepoint(name);
}
@Override
public void rollback(Savepoint savepoint) throws SQLException {
checkOpen();
DruidAbstractDataSource dataSource = holder.getDataSource();
dataSource.incrementRollbackCount();
try {
conn.rollback(savepoint);
} catch (SQLException ex) {
handleException(ex);
} finally {
long transactionMillis = System.currentTimeMillis() - startTransactionTimeMillis;
dataSource.getTransactionHistogram().recode(transactionMillis);
startTransactionTimeMillis = 0;
}
}
@Override
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
checkOpen();
try {
conn.releaseSavepoint(savepoint);
} catch (SQLException ex) {
handleException(ex);
}
}
@Override
public Clob createClob() throws SQLException {
checkOpen();
return conn.createClob();
}
@Override
public boolean isClosed() throws SQLException {
if (holder == null) {
@@ -699,40 +752,6 @@ public class PoolableConnection implements PooledConnection, Connection {
return conn.setSavepoint();
}
@Override
public Savepoint setSavepoint(String name) throws SQLException {
checkOpen();
return conn.setSavepoint(name);
}
@Override
public void rollback(Savepoint savepoint) throws SQLException {
checkOpen();
try {
conn.rollback(savepoint);
} catch (SQLException ex) {
handleException(ex);
}
}
@Override
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
checkOpen();
try {
conn.releaseSavepoint(savepoint);
} catch (SQLException ex) {
handleException(ex);
}
}
@Override
public Clob createClob() throws SQLException {
checkOpen();
return conn.createClob();
}
@Override
public Blob createBlob() throws SQLException {
checkOpen();