public class Txn extends Locker implements Loggable
| Modifier and Type | Field and Description |
|---|---|
(package private) long |
abortLsn |
static int |
ACCUMULATED_LIMIT |
protected long |
commitLsn |
protected java.util.Set<com.sleepycat.je.txn.Txn.DatabaseCleanupInfo> |
deletedDatabases |
protected long |
firstLoggedLsn |
protected long |
lastLoggedLsn |
protected java.util.Set<Database> |
openedDatabaseHandles |
protected ReplicationContext |
repContext |
protected java.util.Map<DatabaseId,DatabaseImpl> |
undoDatabases |
defaultNoWait, deleteInfo, envImpl, id, lockManager, readUncommittedDefault, thread| Modifier | Constructor and Description |
|---|---|
|
Txn()
Constructor for reading from log.
|
protected |
Txn(EnvironmentImpl envImpl,
TransactionConfig config,
ReplicationContext repContext) |
protected |
Txn(EnvironmentImpl envImpl,
TransactionConfig config,
ReplicationContext repContext,
long mandatedId)
A non-zero mandatedId is specified only by subtypes which arbitrarily
impose a transaction id value onto the transaction.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Abort this transaction.
|
long |
abort(boolean forceFlush)
Abort this transaction.
|
void |
abort(javax.transaction.xa.Xid xid) |
(package private) void |
addBuddy(BuddyLocker buddy)
By default the set of buddy lockers is not maintained.
|
protected void |
addLock(java.lang.Long lsn,
LockType type,
LockGrantType grantStatus)
Add lock to the appropriate queue.
|
void |
addLogInfo(long lastLsn)
Called by the recovery manager when logging a transaction aware object.
|
void |
addOpenedDatabase(Database dbHandle)
Called at the end of a database open operation to add the database
handle to a user txn.
|
void |
checkPreempted(Locker allowPreemptedLocker)
Checks for preemption in this locker and all its child buddies.
|
void |
checkState(boolean calledByAbort)
Throw an exception if the transaction is not open.
|
protected void |
cleanupDatabaseImpls(boolean isCommit)
Cleanup leftover databaseImpls that are a by-product of database
operations like removeDatabase(), truncateDatabase().
|
protected void |
clearWriteLocks(java.util.Set<java.lang.Long> retainedNodes)
Release any write locks that are not in the retainedNodes set.
|
protected void |
close(boolean isCommit)
Close and unregister this txn.
|
StatGroup |
collectStats()
stats
|
long |
commit()
Call commit() with the default sync configuration property.
|
long |
commit(Durability durability)
Commit this transaction; it involves the following logical steps:
1.
|
void |
commit(javax.transaction.xa.Xid xid) |
(package private) static Txn |
createAutoTxn(EnvironmentImpl envImpl,
TransactionConfig config,
ReplicationContext repContext) |
boolean |
createdNode(long lsn) |
static Txn |
createLocalAutoTxn(EnvironmentImpl envImpl,
TransactionConfig config) |
static Txn |
createLocalTxn(EnvironmentImpl envImpl,
TransactionConfig config) |
(package private) static Txn |
createUserTxn(EnvironmentImpl envImpl,
TransactionConfig config) |
void |
dumpLog(java.lang.StringBuilder sb,
boolean verbose)
Write the object into the string buffer for log dumping.
|
protected long |
generateId(TxnManager txnManager,
long ignore)
UserTxns get a new unique id for each instance.
|
(package private) int |
getBudgetedMemorySize()
Returns the amount of memory currently budgeted for this transaction.
|
Durability |
getCommitDurability()
Returns the durability used for the commit operation.
|
CommitToken |
getCommitToken()
Returns the CommitToken associated with a successful replicated commit.
|
Durability |
getDefaultDurability()
Returns the durability associated the transaction at the time it's first
created.
|
EnvironmentImpl |
getEnvironmentImpl() |
boolean |
getExplicitDurabilityConfigured() |
boolean |
getExplicitSyncConfigured() |
long |
getFirstActiveLsn()
[#16861] The firstLoggedLsn field is volatile to avoid making
getFirstActiveLsn synchronized, which causes a deadlock in HA.
|
boolean |
getImportunate()
Get the state of a transaction's IMPORTUNATE bit.
|
long |
getLastLsn()
Access to last LSN.
|
int |
getLogSize() |
boolean |
getPrepared() |
java.util.Set<java.lang.Long> |
getReadLockIds() |
protected int |
getReplicatorNodeId() |
Transaction.State |
getState() |
Transaction |
getTransaction()
Returns a Transaction is the locker is transctional, or null otherwise.
|
long |
getTransactionId() |
java.util.Set<DatabaseImpl> |
getTriggerDbs()
Returns the set of databases for which transaction commit/abort
triggers must be run.
|
Txn |
getTxnLocker()
This is a transactional locker.
|
java.util.Set<java.lang.Long> |
getWriteLockIds() |
WriteLockInfo |
getWriteLockInfo(long lsn) |
boolean |
isAutoTxn()
Determines whether this is an auto transaction.
|
boolean |
isClosed() |
boolean |
isOnlyAbortable() |
boolean |
isReadCommittedIsolation()
Is read-committed isolation if so configured.
|
boolean |
isRolledBack() |
boolean |
isSerializableIsolation()
Is serializable isolation if so configured.
|
boolean |
isSuspended() |
boolean |
isTransactional()
Is always transactional.
|
boolean |
isValid()
Used to determine whether the locker is usable.
|
boolean |
lockingRequired()
Returns true if locking is required for this Locker.
|
protected LockResult |
lockInternal(long lsn,
LockType lockType,
boolean noWait,
boolean jumpAheadOfWaiters,
DatabaseImpl database)
Gets a lock on this LSN and, if it is a write lock, saves an abort
LSN.
|
boolean |
logicalEquals(Loggable other) |
void |
markDeleteAtTxnEnd(DatabaseImpl dbImpl,
boolean deleteAtCommit)
Database operations like remove and truncate leave behind
residual DatabaseImpls that must be purged at transaction
commit or abort.
|
(package private) void |
moveWriteToReadLock(long lsn,
Lock lock)
A lock is being demoted.
|
Locker |
newNonTxnLocker()
Returns 'this', since this locker holds no non-transactional locks.
|
void |
nonTxnOperationEnd()
Created transactions do nothing at the end of the operation.
|
void |
noteTriggerDb(DatabaseImpl dbImpl)
Accumulates the set of databases for which transaction commit/abort
triggers must be run.
|
void |
operationEnd(boolean operationOK)
Different types of transactions do different things when the operation
ends.
|
protected void |
postLogAbortHook() |
protected void |
postLogCommitAbortHook()
Invoked if the transaction associated with the preLogCommitHook was
subsequently aborted, for example due to a lack of disk space.
|
protected void |
postLogCommitHook(LogItem commitItem)
This hook is invoked after the commit record has been written to the
log, but before write locks have been released, so that other
application cannot see the changes made by the transaction.
|
protected void |
preLogAbortHook() |
protected void |
preLogCommitHook()
This hook is invoked before the commit of a transaction that made
changes to a replicated environment.
|
void |
preLogWithoutLock(DatabaseImpl database)
If logging succeeds but locking fails, we need the database for undo.
|
int |
prepare(javax.transaction.xa.Xid xid) |
protected boolean |
propagatePostCommitException(DatabaseException postCommitException)
Identifies exceptions that may be propagated back to the caller during
the postCommit phase of a transaction commit.
|
void |
readFromLog(java.nio.ByteBuffer logBuffer,
int entryVersion)
Initialize this object from the data in itemBuf.
|
void |
registerCursor(CursorImpl cursor)
Increase the counter if a new Cursor is opened under this transaction.
|
void |
releaseNonTxnLocks()
This locker holds no non-transactional locks.
|
protected void |
releaseWriteLocks()
Releases all write locks, nulls the lock collection.
|
(package private) void |
removeBuddy(BuddyLocker buddy)
By default the set of buddy lockers is not maintained.
|
(package private) void |
removeLock(long lsn)
Remove the lock from the set owned by this transaction.
|
protected void |
setDeletedDatabaseState(boolean isCommit) |
void |
setImportunate(boolean importunate)
Set the state of a transaction's IMPORTUNATE bit.
|
void |
setOnlyAbortable(OperationFailureException cause)
Set the state of a transaction to abort-only.
|
void |
setPrepared(boolean prepared) |
protected void |
setRollback() |
void |
setSuspended(boolean suspended) |
void |
setTransaction(Transaction transaction) |
protected void |
txnBeginHook(TransactionConfig config)
A replicated environment introduces some new considerations when
entering a transaction scope via an Environment.transactionBegin()
operation.
|
protected void |
undo()
Undo write operations and release all resources held by the transaction.
|
void |
unRegisterCursor(CursorImpl cursor)
Decrease the counter if a Cursor is closed under this transaction.
|
protected boolean |
updateLoggedForTxn() |
void |
writeToLog(java.nio.ByteBuffer logBuffer)
Serialize this object into the buffer.
|
addDeleteInfo, allowReleaseLockAfterLsnChange, close, demoteLock, disallowReplicaWrite, dumpLockTable, getDefaultNoWait, getEnvironment, getId, getInitialLockTimeout, getLockTimeout, getPreemptable, getTxnStartMillis, getTxnTimeout, getWaitingFor, isPreempted, isReadUncommittedDefault, isReplicationDefined, isTimedOut, lock, lockAfterLsnChange, nonBlockingLock, openCursorHook, operationEnd, operationEnd, releaseLock, setAllowMultithreadedAccess, setClosingLocker, setLockTimeout, setPreemptable, setPreempted, setTxnTimeout, setWaitingFor, sharesLocksWith, throwIfPreempted, toStringprotected java.util.Set<com.sleepycat.je.txn.Txn.DatabaseCleanupInfo> deletedDatabases
protected java.util.Map<DatabaseId,DatabaseImpl> undoDatabases
protected java.util.Set<Database> openedDatabaseHandles
protected volatile long firstLoggedLsn
protected long lastLoggedLsn
protected long commitLsn
long abortLsn
public static int ACCUMULATED_LIMIT
protected ReplicationContext repContext
public Txn()
protected Txn(EnvironmentImpl envImpl, TransactionConfig config, ReplicationContext repContext)
protected Txn(EnvironmentImpl envImpl, TransactionConfig config, ReplicationContext repContext, long mandatedId) throws DatabaseException
DatabaseExceptionpublic static Txn createLocalTxn(EnvironmentImpl envImpl, TransactionConfig config)
public static Txn createLocalAutoTxn(EnvironmentImpl envImpl, TransactionConfig config)
static Txn createUserTxn(EnvironmentImpl envImpl, TransactionConfig config)
static Txn createAutoTxn(EnvironmentImpl envImpl, TransactionConfig config, ReplicationContext repContext) throws DatabaseException
DatabaseExceptionvoid addBuddy(BuddyLocker buddy)
Lockervoid removeBuddy(BuddyLocker buddy)
LockerremoveBuddy in class Lockerprotected long generateId(TxnManager txnManager, long ignore)
generateId in class Lockerpublic long getLastLsn()
public Durability getCommitDurability()
public Durability getDefaultDurability()
public boolean getPrepared()
public void setPrepared(boolean prepared)
public void setSuspended(boolean suspended)
public boolean isSuspended()
protected void setRollback()
public boolean isRolledBack()
isRolledBack in class Lockerprotected LockResult lockInternal(long lsn, LockType lockType, boolean noWait, boolean jumpAheadOfWaiters, DatabaseImpl database) throws DatabaseException
lockInternal in class Lockerlsn - is the node to lock.lockType - is the type of lock to request.noWait - is true to override the defaultNoWait setting. If true,
or if defaultNoWait is true, throws LockNotAvailableException if the
lock cannot be granted without waiting.jumpAheadOfWaiters - grant the lock before other waiters, if any.database - is the database containing lsn.java.lang.IllegalStateException - via API read/write methods if the txn is
closed, in theory. However, this should not occur from a user API call,
because the API methods first call Transaction.getLocker, which will
throw IllegalStateException if the txn is closed. It might occur,
however, if the transaction ends in the window between the call to
getLocker and the lock attempt.OperationFailureException - via API read/write methods if an
OperationFailureException occurred earlier and set the txn to
abort-only.LockConflictException - if a blocking lock could not be acquired.DatabaseExceptionLocker.lockInternal(long, com.sleepycat.je.txn.LockType, boolean, boolean, com.sleepycat.je.dbi.DatabaseImpl)public void preLogWithoutLock(DatabaseImpl database)
preLogWithoutLock in class Lockerpublic int prepare(javax.transaction.xa.Xid xid)
throws DatabaseException
java.lang.IllegalStateException - via XAResourceDatabaseExceptionpublic void commit(javax.transaction.xa.Xid xid)
throws DatabaseException
DatabaseExceptionpublic void abort(javax.transaction.xa.Xid xid)
throws DatabaseException
DatabaseExceptionpublic long commit()
throws DatabaseException
DatabaseExceptionpublic long commit(Durability durability) throws DatabaseException
java.lang.IllegalStateException - via Transaction.commit if cursors are
open.OperationFailureException - via Transaction.commit if an
OperationFailureException occurred earlier and set the txn to
abort-only.
Note that IllegalStateException should never be thrown by
Transaction.commit because of a closed txn, since Transaction.commit and
abort set the Transaction.txn to null and disallow subsequent method
calls (other than abort). So in a sense the call to checkState(true) in
this method is unnecessary, although perhaps a good safeguard.DatabaseExceptionprotected void releaseWriteLocks()
throws DatabaseException
DatabaseExceptionpublic void abort()
throws DatabaseException
DatabaseExceptionpublic long abort(boolean forceFlush)
throws DatabaseException
DatabaseExceptionprotected void undo()
throws DatabaseException
DatabaseExceptionprotected void clearWriteLocks(java.util.Set<java.lang.Long> retainedNodes)
throws DatabaseException
DatabaseExceptionpublic void addLogInfo(long lastLsn)
public long getFirstActiveLsn()
protected boolean updateLoggedForTxn()
public void markDeleteAtTxnEnd(DatabaseImpl dbImpl, boolean deleteAtCommit)
LockermarkDeleteAtTxnEnd in class LockerdbImpl - databaseImpl to removedeleteAtCommit - true if this databaseImpl should be cleaned on
commit, false if it should be cleaned on abort.protected void setDeletedDatabaseState(boolean isCommit)
protected void cleanupDatabaseImpls(boolean isCommit)
throws DatabaseException
DatabaseExceptionprotected void addLock(java.lang.Long lsn,
LockType type,
LockGrantType grantStatus)
void removeLock(long lsn)
removeLock in class Lockervoid moveWriteToReadLock(long lsn,
Lock lock)
moveWriteToReadLock in class Lockerint getBudgetedMemorySize()
public boolean createdNode(long lsn)
createdNode in class Lockerpublic WriteLockInfo getWriteLockInfo(long lsn)
getWriteLockInfo in class Lockerpublic boolean isTransactional()
isTransactional in class Lockerpublic boolean isAutoTxn()
public boolean isSerializableIsolation()
isSerializableIsolation in class Lockerpublic boolean isReadCommittedIsolation()
isReadCommittedIsolation in class Lockerpublic boolean getExplicitSyncConfigured()
public boolean getExplicitDurabilityConfigured()
public Txn getTxnLocker()
getTxnLocker in class Lockerpublic Locker newNonTxnLocker()
newNonTxnLocker in class Lockerpublic void releaseNonTxnLocks()
releaseNonTxnLocks in class Lockerpublic void nonTxnOperationEnd()
nonTxnOperationEnd in class Lockerpublic void operationEnd(boolean operationOK)
throws DatabaseException
LockeroperationEnd in class LockeroperationOK - is whether the operation succeeded, since
that may impact ending behavior. (i.e for an auto Txn)DatabaseExceptionpublic void addOpenedDatabase(Database dbHandle)
addOpenedDatabase in class LockerHandleLockerpublic void registerCursor(CursorImpl cursor)
registerCursor in class Lockerpublic void unRegisterCursor(CursorImpl cursor)
unRegisterCursor in class Lockerpublic boolean lockingRequired()
LockerlockingRequired in class Lockerpublic StatGroup collectStats()
collectStats in class Lockerpublic void setOnlyAbortable(OperationFailureException cause)
setOnlyAbortable in class Lockerpublic void setImportunate(boolean importunate)
setImportunate in class Lockerpublic boolean getImportunate()
getImportunate in class Lockerpublic void checkPreempted(Locker allowPreemptedLocker) throws OperationFailureException
checkPreempted in class LockerallowPreemptedLocker - is a locker that is being closed as the
result of a cursor move operation. If the operation is successful then
allowPreemptedLocker will be closed, and the fact that a lock has been
stolen from allowPreemptedLocker can be ignored.OperationFailureExceptionpublic void checkState(boolean calledByAbort)
throws DatabaseException
checkState in class LockerDatabaseExceptionprotected void close(boolean isCommit)
public Transaction.State getState()
public boolean isValid()
Lockerpublic boolean isClosed()
public boolean isOnlyAbortable()
protected int getReplicatorNodeId()
public int getLogSize()
getLogSize in interface LoggableLoggable.getLogSize()public void writeToLog(java.nio.ByteBuffer logBuffer)
LoggablewriteToLog in interface LoggablelogBuffer - is the destination bufferIt's ok for FindBugs to whine about id not being synchronized.public void readFromLog(java.nio.ByteBuffer logBuffer,
int entryVersion)
LoggablereadFromLog in interface LoggableIt's ok for FindBugs to whine about id not being synchronized.public void dumpLog(java.lang.StringBuilder sb,
boolean verbose)
LoggabledumpLog in interface Loggablesb - destination string bufferverbose - if true, dump the full, verbose versionLoggable.dumpLog(java.lang.StringBuilder, boolean)public long getTransactionId()
getTransactionId in interface LoggableLoggable.getTransactionId()public boolean logicalEquals(Loggable other)
logicalEquals in interface LoggableLoggable.logicalEquals(com.sleepycat.je.log.Loggable)protected void txnBeginHook(TransactionConfig config) throws DatabaseException
config - the transaction config that applies to the txnDatabaseException - if there is a failureprotected void preLogCommitHook()
throws DatabaseException
txn - the transaction being committedDatabaseException - if there was a problem and that the
transaction should be aborted.protected void postLogCommitHook(LogItem commitItem) throws DatabaseException
commitItem - the commit item that was just loggedDatabaseException - to indicate that there was a replication
related problem that needs to be communicated back to the application.protected void preLogAbortHook()
throws DatabaseException
DatabaseExceptionprotected void postLogCommitAbortHook()
protected void postLogAbortHook()
public CommitToken getCommitToken()
Transaction.getCommitToken()protected boolean propagatePostCommitException(DatabaseException postCommitException)
postCommitException - the exception being evaluatedpublic void noteTriggerDb(DatabaseImpl dbImpl)
dbImpl - the database that associated with the triggerpublic java.util.Set<DatabaseImpl> getTriggerDbs()
public java.util.Set<java.lang.Long> getWriteLockIds()
public java.util.Set<java.lang.Long> getReadLockIds()
public EnvironmentImpl getEnvironmentImpl()
public void setTransaction(Transaction transaction)
public Transaction getTransaction()
LockergetTransaction in class LockerCopyright (c) 2004-2012 Oracle. All rights reserved.