|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.sleepycat.je.txn.Locker
com.sleepycat.je.txn.Txn
public class Txn
A Txn is the internal representation of a transaction created by a call to Environment.txnBegin. This class must support multi-threaded use.
| Field Summary | |
|---|---|
(package private) long |
abortLsn
|
static int |
ACCUMULATED_LIMIT
|
protected long |
commitLsn
|
protected Set<com.sleepycat.je.txn.Txn.DatabaseCleanupInfo> |
deletedDatabases
|
protected long |
firstLoggedLsn
|
protected long |
lastLoggedLsn
|
protected ReplicationContext |
repContext
|
protected Map<DatabaseId,DatabaseImpl> |
undoDatabases
|
| Fields inherited from class com.sleepycat.je.txn.Locker |
|---|
defaultNoWait, deleteInfo, envImpl, handleLockToHandleMap, handleToHandleLockMap, id, lockManager, readUncommittedDefault, thread |
| Constructor Summary | |
|---|---|
|
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. |
| Method Summary | |
|---|---|
void |
abort()
Abort this transaction. |
long |
abort(boolean forceFlush)
Abort this transaction. |
void |
abort(Xid xid)
|
(package private) void |
addBuddy(BuddyLocker buddy)
By default the set of buddy lockers is not maintained. |
protected void |
addLock(Long nodeId,
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. |
(package private) void |
checkPreempted(Locker allowPreemptedLocker)
Checks for preemption in this locker and all its child buddies. |
protected 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(Set<Long> retainedNodes)
Release any write locks that are not in the retainedNodes set. |
protected void |
close(boolean isCommit)
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(Xid xid)
|
(package private) static Txn |
createAutoTxn(EnvironmentImpl envImpl,
TransactionConfig config,
ReplicationContext repContext)
|
boolean |
createdNode(long nodeId)
|
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(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. |
long |
getAbortLsn(long nodeId)
|
(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. |
boolean |
getExplicitDurabilityConfigured()
|
boolean |
getExplicitSyncConfigured()
|
long |
getFirstActiveLsn()
|
boolean |
getImportunate()
Get the state of a transaction's IMPORTUNATE bit. |
long |
getLastLsn()
Access to last LSN. |
int |
getLogSize()
|
boolean |
getPrepared()
|
Set<Long> |
getReadLockIds()
|
protected int |
getReplicatorNodeId()
|
long |
getTransactionId()
|
Txn |
getTxnLocker()
This is a transactional locker. |
Set<Long> |
getWriteLockIds()
|
WriteLockInfo |
getWriteLockInfo(long nodeId)
|
boolean |
isAutoTxn()
Determines whether this is an auto transaction. |
boolean |
isClosed()
|
boolean |
isHandleLockTransferrable()
|
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()
|
boolean |
lockingRequired()
Returns true if locking is required for this Locker. |
protected LockResult |
lockInternal(long nodeId,
LockType lockType,
boolean noWait,
DatabaseImpl database)
Gets a lock on this nodeId 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 nodeId,
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 |
operationEnd(boolean operationOK)
Different types of transactions do different things when the operation ends. |
protected void |
postLogAbortHook()
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 |
preLogCommitHook()
This hook is invoked before the commit of a transaction that made changes to a replicated environment. |
int |
prepare(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(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 nodeId)
Remove the lock from the set owned by this transaction. |
protected void |
setDeletedDatabaseState(boolean isCommit)
|
void |
setHandleLockOwner(boolean operationOK,
Database dbHandle,
boolean dbIsClosing)
We're at the end of an operation. |
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)
|
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(ByteBuffer logBuffer)
Serialize this object into the buffer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Set<com.sleepycat.je.txn.Txn.DatabaseCleanupInfo> deletedDatabases
protected Map<DatabaseId,DatabaseImpl> undoDatabases
protected volatile long firstLoggedLsn
protected long lastLoggedLsn
protected long commitLsn
long abortLsn
public static int ACCUMULATED_LIMIT
protected ReplicationContext repContext
| Constructor Detail |
|---|
public Txn()
protected Txn(EnvironmentImpl envImpl,
TransactionConfig config,
ReplicationContext repContext)
protected Txn(EnvironmentImpl envImpl,
TransactionConfig config,
ReplicationContext repContext,
long mandatedId)
throws DatabaseException
DatabaseException| Method Detail |
|---|
public 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)
Locker
addBuddy in class Lockervoid removeBuddy(BuddyLocker buddy)
Locker
removeBuddy in class Locker
protected 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 Locker
protected LockResult lockInternal(long nodeId,
LockType lockType,
boolean noWait,
DatabaseImpl database)
throws DatabaseException
lockInternal in class LockernodeId - 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.database - is the database containing nodeId.
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, com.sleepycat.je.dbi.DatabaseImpl)
public int prepare(Xid xid)
throws DatabaseException
IllegalStateException - via XAResource
DatabaseException
public void commit(Xid xid)
throws DatabaseException
DatabaseException
public void abort(Xid xid)
throws DatabaseException
DatabaseException
public long commit()
throws DatabaseException
DatabaseException
public long commit(Durability durability)
throws DatabaseException
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.
DatabaseException
protected void releaseWriteLocks()
throws DatabaseException
DatabaseException
public void abort()
throws DatabaseException
DatabaseException
public long abort(boolean forceFlush)
throws DatabaseException
DatabaseException
protected void undo()
throws DatabaseException
DatabaseException
protected void clearWriteLocks(Set<Long> retainedNodes)
throws DatabaseException
DatabaseExceptionpublic void addLogInfo(long lastLsn)
public long getFirstActiveLsn()
protected boolean updateLoggedForTxn()
public void markDeleteAtTxnEnd(DatabaseImpl dbImpl,
boolean deleteAtCommit)
Locker
markDeleteAtTxnEnd in class LockerdbImpl - databaseImpl to removedeleteAtCommit - true if this databaseImpl should be cleaned on
commit, false if it should be cleaned on abort.mb - environment memory budget.protected void setDeletedDatabaseState(boolean isCommit)
protected void cleanupDatabaseImpls(boolean isCommit)
throws DatabaseException
DatabaseException
protected void addLock(Long nodeId,
LockType type,
LockGrantType grantStatus)
addLock in class Lockervoid removeLock(long nodeId)
removeLock in class Locker
void moveWriteToReadLock(long nodeId,
Lock lock)
moveWriteToReadLock in class Lockerint getBudgetedMemorySize()
public boolean createdNode(long nodeId)
createdNode in class Lockerpublic long getAbortLsn(long nodeId)
getAbortLsn in class Lockerpublic WriteLockInfo getWriteLockInfo(long nodeId)
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 Locker
public void operationEnd(boolean operationOK)
throws DatabaseException
Locker
operationEnd in class LockeroperationOK - is whether the operation succeeded, since
that may impact ending behavior. (i.e for an auto Txn)
DatabaseException
public void setHandleLockOwner(boolean operationOK,
Database dbHandle,
boolean dbIsClosing)
throws DatabaseException
Locker
setHandleLockOwner in class LockerDatabaseExceptionpublic void registerCursor(CursorImpl cursor)
registerCursor in class Lockerpublic void unRegisterCursor(CursorImpl cursor)
unRegisterCursor in class Lockerpublic boolean lockingRequired()
Locker
lockingRequired in class Lockerpublic boolean isHandleLockTransferrable()
isHandleLockTransferrable 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 Locker
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.
OperationFailureException
protected void checkState(boolean calledByAbort)
throws DatabaseException
checkState in class LockerDatabaseException
protected void close(boolean isCommit)
throws DatabaseException
DatabaseExceptionpublic boolean isValid()
public boolean isClosed()
public boolean isOnlyAbortable()
protected int getReplicatorNodeId()
public int getLogSize()
getLogSize in interface LoggableLoggable.getLogSize()public void writeToLog(ByteBuffer logBuffer)
Loggable
writeToLog in interface LoggablelogBuffer - is the destination bufferIt's ok for FindBugs to whine about id not being synchronized.
public void readFromLog(ByteBuffer logBuffer,
int entryVersion)
Loggable
readFromLog in interface LoggableIt's ok for FindBugs to whine about id not being synchronized.
public void dumpLog(StringBuilder sb,
boolean verbose)
Loggable
dumpLog 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 txn
DatabaseException - if there is a failure
protected void preLogCommitHook()
throws DatabaseException
txn - the transaction being committed
DatabaseException - 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 logged
DatabaseException - to indicate that there was a replication
related problem that needs to be communicated back to the application.protected void postLogAbortHook()
public CommitToken getCommitToken()
Transaction.getCommitToken()protected boolean propagatePostCommitException(DatabaseException postCommitException)
postCommitException - the exception being evaluated
public Set<Long> getWriteLockIds()
public Set<Long> getReadLockIds()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||