diff options
author | Bernard Normier <bernard@zeroc.com> | 2004-11-03 16:37:42 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2004-11-03 16:37:42 +0000 |
commit | 7b1808f457ddc1597ac00c89bf4d95190496ce01 (patch) | |
tree | 2ba4ca2aa350b307d9a0a086827eeeed5e7be096 /java/src/Freeze/TransactionI.java | |
parent | Added Freeze.Trace.Transaction (diff) | |
download | ice-7b1808f457ddc1597ac00c89bf4d95190496ce01.tar.bz2 ice-7b1808f457ddc1597ac00c89bf4d95190496ce01.tar.xz ice-7b1808f457ddc1597ac00c89bf4d95190496ce01.zip |
Added Freeze.Trace.Transaction tracing
Diffstat (limited to 'java/src/Freeze/TransactionI.java')
-rwxr-xr-x | java/src/Freeze/TransactionI.java | 263 |
1 files changed, 169 insertions, 94 deletions
diff --git a/java/src/Freeze/TransactionI.java b/java/src/Freeze/TransactionI.java index bf2f7c4d7e9..766e7febae5 100755 --- a/java/src/Freeze/TransactionI.java +++ b/java/src/Freeze/TransactionI.java @@ -7,97 +7,172 @@ // // ********************************************************************** -
-package Freeze;
-
-class TransactionI extends Ice.LocalObjectImpl implements Transaction
-{
- public void
- commit()
- {
- try
- {
- _connection.closeAllIterators();
- _txn.commit(0);
- }
- catch(com.sleepycat.db.DbDeadlockException e)
- {
- DeadlockException ex = new DeadlockException();
- ex.initCause(e);
- ex.message = _errorPrefix + "DbTxn.commit: " + e.getMessage();
- throw ex;
- }
- catch(com.sleepycat.db.DbException e)
- {
- DatabaseException ex = new DatabaseException();
- ex.initCause(e);
- ex.message = _errorPrefix + "DbTxn.commit: " + e.getMessage();
- throw ex;
- }
- finally
- {
- _connection.clearTransaction();
- _connection = null;
- _txn = null;
- }
- }
-
- public void
- rollback()
- {
- try
- {
- _connection.closeAllIterators();
- _txn.abort();
- }
- catch(com.sleepycat.db.DbDeadlockException e)
- {
- DeadlockException ex = new DeadlockException();
- ex.initCause(e);
- ex.message = _errorPrefix + "DbTxn.abort: " + e.getMessage();
- throw ex;
- }
- catch(com.sleepycat.db.DbException e)
- {
- DatabaseException ex = new DatabaseException();
- ex.initCause(e);
- ex.message = _errorPrefix + "DbTxn.abort: " + e.getMessage();
- throw ex;
- }
- finally
- {
- _connection.clearTransaction();
- _connection = null;
- _txn = null;
- }
- }
-
- TransactionI(ConnectionI connection)
- {
- _connection = connection;
- _errorPrefix = "Freeze DB DbEnv(\"" + _connection.envName() + "\") :";
-
- try
- {
- _txn = _connection.dbEnv().txnBegin(null, 0);
- }
- catch(com.sleepycat.db.DbException e)
- {
- DatabaseException ex = new DatabaseException();
- ex.initCause(e);
- ex.message = _errorPrefix + "txn_begin: " + e.getMessage();
- throw ex;
- }
- }
-
- com.sleepycat.db.DbTxn
- dbTxn()
- {
- return _txn;
- }
-
- private ConnectionI _connection;
- private com.sleepycat.db.DbTxn _txn;
-
- private String _errorPrefix;
-}
+ +package Freeze; + +class TransactionI extends Ice.LocalObjectImpl implements Transaction +{ + public void + commit() + { + String txnId = null; + + try + { + _connection.closeAllIterators(); + + if(_txTrace >= 1) + { + txnId = Long.toHexString((_txn.id() & 0x7FFFFFFF) + 0x80000000L); + } + + _txn.commit(0); + + if(_txTrace >= 1) + { + _connection.communicator().getLogger().trace + ("Freeze.Map", _errorPrefix + "successfully committed transaction " + txnId); + } + + } + catch(com.sleepycat.db.DbDeadlockException e) + { + if(_txTrace >= 1) + { + _connection.communicator().getLogger().trace + ("Freeze.Map", _errorPrefix + "failed to commit transaction " + txnId + + ": " + e.getMessage()); + } + + DeadlockException ex = new DeadlockException(); + ex.initCause(e); + ex.message = _errorPrefix + "DbTxn.commit: " + e.getMessage(); + throw ex; + } + catch(com.sleepycat.db.DbException e) + { + if(_txTrace >= 1) + { + _connection.communicator().getLogger().trace + ("Freeze.Map", _errorPrefix + "failed to commit transaction " + txnId + + ": " + e.getMessage()); + } + + DatabaseException ex = new DatabaseException(); + ex.initCause(e); + ex.message = _errorPrefix + "DbTxn.commit: " + e.getMessage(); + throw ex; + } + finally + { + _connection.clearTransaction(); + _connection = null; + _txn = null; + } + } + + public void + rollback() + { + String txnId = null; + + try + { + _connection.closeAllIterators(); + + if(_txTrace >= 1) + { + txnId = Long.toHexString((_txn.id() & 0x7FFFFFFF) + 0x80000000L); + } + + _txn.abort(); + + if(_txTrace >= 1) + { + _connection.communicator().getLogger().trace + ("Freeze.Map", _errorPrefix + "successfully rolled back transaction " + txnId); + } + + } + catch(com.sleepycat.db.DbDeadlockException e) + { + if(_txTrace >= 1) + { + _connection.communicator().getLogger().trace + ("Freeze.Map", _errorPrefix + "failed to rollback transaction " + txnId + + ": " + e.getMessage()); + } + + DeadlockException ex = new DeadlockException(); + ex.initCause(e); + ex.message = _errorPrefix + "DbTxn.abort: " + e.getMessage(); + throw ex; + } + catch(com.sleepycat.db.DbException e) + { + if(_txTrace >= 1) + { + _connection.communicator().getLogger().trace + ("Freeze.Map", _errorPrefix + "failed to rollback transaction " + txnId + + ": " + e.getMessage()); + } + + DatabaseException ex = new DatabaseException(); + ex.initCause(e); + ex.message = _errorPrefix + "DbTxn.abort: " + e.getMessage(); + throw ex; + } + finally + { + _connection.clearTransaction(); + _connection = null; + _txn = null; + } + } + + TransactionI(ConnectionI connection) + { + _connection = connection; + _txTrace = connection.txTrace(); + _errorPrefix = "Freeze DB DbEnv(\"" + _connection.envName() + "\"): "; + + try + { + _txn = _connection.dbEnv().txnBegin(null, 0); + + if(_txTrace >= 1) + { + String txnId = Long.toHexString((_txn.id() & 0x7FFFFFFF) + 0x80000000L); + + _connection.communicator().getLogger().trace + ("Freeze.Map", _errorPrefix + "successfully started transaction " + txnId); + } + + } + catch(com.sleepycat.db.DbException e) + { + if(_txTrace >= 1) + { + _connection.communicator().getLogger().trace + ("Freeze.Map", _errorPrefix + "failed to start transaction: " + e.getMessage()); + } + + DatabaseException ex = new DatabaseException(); + ex.initCause(e); + ex.message = _errorPrefix + "txn_begin: " + e.getMessage(); + throw ex; + } + } + + com.sleepycat.db.DbTxn + dbTxn() + { + return _txn; + } + + private ConnectionI _connection; + private int _txTrace; + private com.sleepycat.db.DbTxn _txn; + + private String _errorPrefix; +} |