|
Berkeley DB version 4.2.52 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sleepycat.bdb.TransactionRunner
Starts a transaction, calls TransactionWorker.doWork()
, and handles
transaction retry and exceptions.
Constructor Summary | |
TransactionRunner(DbEnv env)
Creates a transaction runner for a given Berkeley DB environment. |
|
TransactionRunner(DbEnv env,
int maxRetries)
Creates a transaction runner for a given Berkeley DB environment and with a given number of maximum retries. |
Method Summary | |
boolean |
getDirtyRead()
Returns whether transactions will read data that is modified by another transaction but not committed. |
int |
getMaxRetries()
Returns the maximum number of retries that will be performed when deadlocks are detected. |
boolean |
getNoWait()
Returns whether transactions will throw DbLockNotGrantedException instead of blocking when trying to access data that is locked by another transaction. |
void |
run(TransactionWorker worker)
Calls the TransactionWorker.doWork() method and, for transactional
environments, begins and ends a transaction. |
void |
setDirtyRead(boolean dirtyRead)
Changes whether transactions will read data that is modified by another transaction but not committed. |
void |
setMaxRetries(int maxRetries)
Changes the maximum number of retries that will be performed when deadlocks are detected. |
void |
setNoWait(boolean noWait)
Changes whether transactions will throw DbLockNotGrantedException instead of blocking when trying to access data that is locked by another transaction. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TransactionRunner(DbEnv env)
env
- is the environment for running transactions.public TransactionRunner(DbEnv env, int maxRetries)
env
- is the environment for running transactions.maxRetries
- is the maximum number of retries that will be performed
when deadlocks are detected.Method Detail |
public int getMaxRetries()
public void setMaxRetries(int maxRetries)
public boolean getDirtyRead()
public void setDirtyRead(boolean dirtyRead)
public boolean getNoWait()
public void setNoWait(boolean noWait)
public void run(TransactionWorker worker) throws DbException, Exception
TransactionWorker.doWork()
method and, for transactional
environments, begins and ends a transaction. If the environment given
is non-transactional, a transaction will not be used but the doWork()
method will still be called.
In a transactional environment, a new transaction is started before calling doWork(). This will start a nested transaction if one is already active. If DbDeadlockException is thrown by doWork(), the transaction will be aborted and the process will be repeated up to the maximum number of retries specified. If another exception is thrown by doWork() or the maximum number of retries has occurred, the transaction will be aborted and the exception will be rethrown by this method. If no exception is thrown by doWork(), the transaction will be committed. This method will not attempt to commit or abort a transaction if it has already been committed or aborted by doWork().
DbDeadlockException
- when it is thrown by doWork() and the
maximum number of retries has occurred. The transaction will have been
aborted by this method.
Exception
- when any other exception is thrown by doWork(). The
exception will first be unwrapped by calling ExceptionUnwrapper.unwrap(java.lang.Exception)
. The transaction will have been aborted by
this method.
DbException
|
Berkeley DB version 4.2.52 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |