public class CurrentTransaction
extends java.lang.Object
TransactionRunner
class. However, both methods of transaction control manage per-thread
transactions.Modifier and Type | Class and Description |
---|---|
(package private) static class |
CurrentTransaction.CdbCursors |
Modifier and Type | Method and Description |
---|---|
Transaction |
abortTransaction()
Aborts the transaction that is active for the current thread for this
environment and makes the parent transaction (if any) the current
transaction.
|
Transaction |
beginTransaction(TransactionConfig config)
Begins a new transaction for this environment and associates it with
the current thread.
|
(package private) void |
closeCursor(Cursor cursor)
Closes a cursor.
|
Transaction |
commitTransaction()
Commits the transaction that is active for the current thread for this
environment and makes the parent transaction (if any) the current
transaction.
|
(package private) Cursor |
dupCursor(Cursor cursor,
boolean writeCursor,
boolean samePosition)
Duplicates a cursor for a given database.
|
Environment |
getEnvironment()
Returns the underlying Berkeley DB environment.
|
static CurrentTransaction |
getInstance(Environment env)
Gets the CurrentTransaction accessor for a specified Berkeley DB
environment.
|
(package private) static CurrentTransaction |
getInstanceInternal(Environment env)
Gets the CurrentTransaction accessor for a specified Berkeley DB
environment.
|
Transaction |
getTransaction()
Returns the transaction associated with the current thread for this
environment, or null if no transaction is active.
|
(package private) LockMode |
getWriteLockMode()
Return the LockMode.RMW or null, depending on whether locking is
enabled.
|
(package private) boolean |
isAutoCommitAllowed()
Returns whether auto-commit may be performed by the collections API.
|
(package private) boolean |
isCDBCursorOpen(Database db)
Returns true if a CDB cursor is open and therefore a Database write
operation should not be attempted since a self-deadlock may result.
|
(package private) boolean |
isCdbMode()
Returns whether this is a Concurrent Data Store environment.
|
(package private) boolean |
isLockingMode()
Returns whether environment is configured for locking.
|
(package private) boolean |
isReadUncommitted()
Returns whether the current transaction is a readUncommitted
transaction.
|
(package private) boolean |
isTxnMode()
Returns whether this is a transactional environment.
|
(package private) Cursor |
openCursor(Database db,
CursorConfig cursorConfig,
boolean writeCursor,
Transaction txn)
Opens a cursor for a given database, dup'ing an existing CDB cursor if
one is open for the current thread.
|
public static CurrentTransaction getInstance(Environment env)
env
- is an open Berkeley DB environment.static CurrentTransaction getInstanceInternal(Environment env)
env
- is an open Berkeley DB environment.final boolean isLockingMode()
final boolean isTxnMode()
final boolean isCdbMode()
final LockMode getWriteLockMode()
public final Environment getEnvironment()
public final Transaction getTransaction()
boolean isAutoCommitAllowed() throws DatabaseException
DatabaseException
public final Transaction beginTransaction(TransactionConfig config) throws DatabaseException
config
- the transaction configuration used for calling
Environment.beginTransaction(com.sleepycat.je.Transaction, com.sleepycat.je.TransactionConfig)
, or null to use the default
configuration.InsufficientReplicasException
- if the Master
in a replicated environment could not contact a quorum of replicas as
determined by the Durability.ReplicaAckPolicy
.ReplicaConsistencyException
- if a replica
in a replicated environment cannot become consistent within the timeout
period.EnvironmentFailureException
- if an unexpected, internal or
environment-wide failure occurs.
DatabaseException
- if the transaction cannot be started, in which
case any existing transaction is not affected.java.lang.IllegalStateException
- if a transaction is already active and
nested transactions are not supported by the environment.public final Transaction commitTransaction() throws DatabaseException, java.lang.IllegalStateException
InsufficientReplicasException
- if the master
in a replicated environment could not contact a quorum of replicas as
determined by the Durability.ReplicaAckPolicy
.
The application must abort the transaction and can choose to retry it.InsufficientAcksException
- if the master in
a replicated environment did not receive enough replica acknowledgments,
although the commit succeeded locally.ReplicaWriteException
- if a write operation
was performed with this transaction, but this node is now a Replica.OperationFailureException
- if this exception occurred earlier and
caused the transaction to be invalidated.EnvironmentFailureException
- if an unexpected, internal or
environment-wide failure occurs.
DatabaseException
- if an error occurs committing the transaction.
The transaction will still be closed and the parent transaction will
become the current transaction.java.lang.IllegalStateException
- if no transaction is active for the
current thread for this environment.public final Transaction abortTransaction() throws DatabaseException, java.lang.IllegalStateException
EnvironmentFailureException
- if an unexpected, internal or
environment-wide failure occurs.
DatabaseException
- if an error occurs aborting the transaction.
The transaction will still be closed and the parent transaction will
become the current transaction.java.lang.IllegalStateException
- if no transaction is active for the
current thread for this environment.final boolean isReadUncommitted()
Cursor openCursor(Database db, CursorConfig cursorConfig, boolean writeCursor, Transaction txn) throws DatabaseException
DatabaseException
Cursor dupCursor(Cursor cursor, boolean writeCursor, boolean samePosition) throws DatabaseException
writeCursor
- true to open a write cursor in a CDB environment, and
ignored for other environments.samePosition
- is passed through to Cursor.dup().DatabaseException
- if a database problem occurs.void closeCursor(Cursor cursor) throws DatabaseException
cursor
- the cursor to close.DatabaseException
- if a database problem occurs.boolean isCDBCursorOpen(Database db)
Copyright (c) 2004-2012 Oracle. All rights reserved.