public class Txn extends Locker implements Loggable
| Modifier and Type | Field and Description |
|---|---|
static int |
ACCUMULATED_LIMIT |
protected long |
firstLoggedLsn |
protected long |
lastLoggedLsn |
protected ReplicationContext |
repContext |
protected java.util.Map<DatabaseId,DatabaseImpl> |
undoDatabases |
defaultNoWait, deleteInfo, envImpl, handleLockToHandleMap, handleToHandleLockMap, id, lockManager, readUncommittedDefault, thread| Modifier | Constructor and Description |
|---|---|
|
Txn()
Constructor for reading from log.
|
protected |
Txn(EnvironmentImpl envImpl,
TransactionConfig config)
Create a transaction from Environment.txnBegin.
|
protected |
Txn(EnvironmentImpl envImpl,
TransactionConfig config,
boolean noAPIReadLock,
long mandatedId)
This is only for use by subtypes which arbitrarily impose a transaction
id value onto the transaction.
|
|
Txn(EnvironmentImpl envImpl,
TransactionConfig config,
ReplicationContext repContext)
Create a Txn for use in a unit test, where we won't need a auto Txn or a
com.sleepycat.je.Transaction.
|
| Modifier and Type | Method and Description |
|---|---|
long |
abort(boolean forceFlush)
Abort this transaction.
|
void |
abort(javax.transaction.xa.Xid xid) |
protected void |
addLock(java.lang.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.
|
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 |
close(boolean isCommit) |
LockStats |
collectStats(LockStats stats)
stats
|
long |
commit()
Call commit() with the default sync configuration property.
|
long |
commit(Durability durability)
Commit this transaction
1.
|
void |
commit(javax.transaction.xa.Xid xid) |
static Txn |
createAutoTxn(EnvironmentImpl envImpl,
TransactionConfig config,
boolean noAPIReadLock,
ReplicationContext repContext) |
boolean |
createdNode(long nodeId) |
(package private) static Txn |
createTxn(EnvironmentImpl envImpl,
TransactionConfig config) |
static Txn |
createTxn(EnvironmentImpl envImpl,
TransactionConfig config,
ReplicationContext repContext) |
void |
dumpLog(java.lang.StringBuffer 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.
|
Durability |
getDefaultDurability()
Returns the durability associated the transaction at the time it's first
created.
|
boolean |
getExplicitDurabilityConfigured() |
boolean |
getExplicitSyncConfigured() |
(package private) long |
getFirstActiveLsn() |
long |
getLastLsn()
Access to last LSN.
|
int |
getLogSize() |
boolean |
getOnlyAbortable()
Get the state of a transaction's ONLY_ABORTABLE.
|
boolean |
getPrepared() |
protected int |
getReplicatorNodeId() |
long |
getTransactionId() |
Txn |
getTxnLocker()
This is a transactional locker.
|
WriteLockInfo |
getWriteLockInfo(long nodeId) |
boolean |
isAutoTxn()
Determines whether this is an auto transaction.
|
boolean |
isClosed() |
boolean |
isHandleLockTransferrable() |
boolean |
isReadCommittedIsolation()
Is read-committed isolation if so configured.
|
boolean |
isSerializableIsolation()
Is serializable isolation if so configured.
|
boolean |
isSuspended() |
boolean |
isTransactional()
Is always transactional.
|
(package private) 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()
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(javax.transaction.xa.Xid xid) |
void |
readFromLog(java.nio.ByteBuffer logBuffer,
byte entryVersion)
Initialize this object from the data in itemBuf.
|
void |
registerCursor(CursorImpl cursor)
Cursors operating under this transaction are added to the collection.
|
void |
releaseNonTxnLocks()
This locker holds no non-transactional locks.
|
(package private) void |
removeLock(long nodeId)
Remove the lock from the set owned by this transaction.
|
void |
setHandleLockOwner(boolean operationOK,
Database dbHandle,
boolean dbIsClosing)
We're at the end of an operation.
|
void |
setOnlyAbortable()
Set the state of a transaction to ONLY_ABORTABLE.
|
void |
setPrepared(boolean prepared) |
void |
setRepContext(ReplicationContext repContext)
Different subclasses find a repContext at different times, depending on
when they have the context to know whether a transaction should be
replicated.
|
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()
Rollback the changes to this txn's write locked nodes.
|
void |
unRegisterCursor(CursorImpl cursor)
Remove a cursor from the collection.
|
void |
writeToLog(java.nio.ByteBuffer logBuffer)
Serialize this object into the buffer.
|
addDeleteInfo, addToHandleMaps, close, demoteLock, dumpLockTable, getDefaultNoWait, getId, getLockTimeout, getTxnStartMillis, getTxnTimeout, getWaitingFor, initApiReadLock, isReadUncommittedDefault, isTimedOut, lock, nonBlockingLock, operationEnd, operationEnd, releaseLock, setLockTimeout, setTxnTimeout, setWaitingFor, sharesLocksWith, toString, transferHandleLock, transferHandleLockToHandle, unregisterHandleprotected java.util.Map<DatabaseId,DatabaseImpl> undoDatabases
protected long lastLoggedLsn
protected long firstLoggedLsn
public static int ACCUMULATED_LIMIT
protected ReplicationContext repContext
public Txn()
protected Txn(EnvironmentImpl envImpl, TransactionConfig config) throws DatabaseException
DatabaseExceptionprotected Txn(EnvironmentImpl envImpl, TransactionConfig config, boolean noAPIReadLock, long mandatedId) throws DatabaseException
DatabaseExceptionpublic Txn(EnvironmentImpl envImpl, TransactionConfig config, ReplicationContext repContext) throws DatabaseException
DatabaseExceptionstatic Txn createTxn(EnvironmentImpl envImpl, TransactionConfig config) throws DatabaseException
DatabaseExceptionpublic static Txn createTxn(EnvironmentImpl envImpl, TransactionConfig config, ReplicationContext repContext) throws DatabaseException
DatabaseExceptionpublic static Txn createAutoTxn(EnvironmentImpl envImpl, TransactionConfig config, boolean noAPIReadLock, ReplicationContext repContext) throws DatabaseException
DatabaseExceptionprotected 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()
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 LockNotGrantedException if the lock
cannot be granted without waiting.database - is the database containing nodeId.DeadlockException - if acquiring a blocking lock would result in a
deadlock.DatabaseExceptionLocker.lockInternal(long, com.sleepycat.je.txn.LockType, boolean, com.sleepycat.je.dbi.DatabaseImpl)public int prepare(javax.transaction.xa.Xid xid)
throws DatabaseException
DatabaseExceptionpublic 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
DatabaseExceptionpublic long abort(boolean forceFlush)
throws DatabaseException
DatabaseExceptionprotected void undo()
throws DatabaseException
DatabaseExceptionpublic void addLogInfo(long lastLsn)
throws DatabaseException
DatabaseExceptionlong getFirstActiveLsn()
throws DatabaseException
DatabaseExceptionpublic void markDeleteAtTxnEnd(DatabaseImpl dbImpl, boolean deleteAtCommit) throws DatabaseException
LockermarkDeleteAtTxnEnd 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.DatabaseExceptionprotected void cleanupDatabaseImpls(boolean isCommit)
throws DatabaseException
DatabaseExceptionprotected void addLock(java.lang.Long nodeId,
LockType type,
LockGrantType grantStatus)
throws DatabaseException
addLock in class LockerDatabaseExceptionvoid removeLock(long nodeId)
throws DatabaseException
removeLock in class LockerDatabaseExceptionvoid moveWriteToReadLock(long nodeId,
Lock lock)
moveWriteToReadLock in class Lockerint getBudgetedMemorySize()
public boolean createdNode(long nodeId)
throws DatabaseException
createdNode in class LockerDatabaseExceptionpublic long getAbortLsn(long nodeId)
throws DatabaseException
getAbortLsn in class LockerDatabaseExceptionpublic WriteLockInfo getWriteLockInfo(long nodeId) throws DatabaseException
getWriteLockInfo in class LockerDatabaseExceptionpublic 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() throws DatabaseException
newNonTxnLocker in class LockerDatabaseExceptionpublic void releaseNonTxnLocks()
throws DatabaseException
releaseNonTxnLocks in class LockerDatabaseExceptionpublic void nonTxnOperationEnd()
throws DatabaseException
nonTxnOperationEnd in class LockerDatabaseExceptionpublic 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 setHandleLockOwner(boolean operationOK,
Database dbHandle,
boolean dbIsClosing)
throws DatabaseException
LockersetHandleLockOwner in class LockerDatabaseExceptionpublic void registerCursor(CursorImpl cursor) throws DatabaseException
registerCursor in class LockerDatabaseExceptionpublic void unRegisterCursor(CursorImpl cursor) throws DatabaseException
unRegisterCursor in class LockerDatabaseExceptionpublic boolean isHandleLockTransferrable()
isHandleLockTransferrable in class Lockerpublic LockStats collectStats(LockStats stats) throws DatabaseException
collectStats in class LockerDatabaseExceptionpublic void setOnlyAbortable()
setOnlyAbortable in class Lockerpublic boolean getOnlyAbortable()
protected void checkState(boolean calledByAbort)
throws DatabaseException
checkState in class LockerDatabaseExceptionpublic void setRepContext(ReplicationContext repContext)
protected void close(boolean isCommit)
throws DatabaseException
DatabaseExceptionpublic boolean isClosed()
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 bufferLoggable.writeToLog(java.nio.ByteBuffer)public void readFromLog(java.nio.ByteBuffer logBuffer,
byte entryVersion)
LoggablereadFromLog in interface LoggableIt's ok for FindBugs to whine about id not being synchronized.public void dumpLog(java.lang.StringBuffer sb,
boolean verbose)
LoggabledumpLog in interface Loggablesb - destination string bufferverbose - if true, dump the full, verbose versionLoggable.dumpLog(java.lang.StringBuffer, 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 txnDatabaseExceptionprotected void preLogCommitHook()
throws DatabaseException
txn - the transaction being committedDatabaseException - if there was a problem and that the transaction
should be aborted.protected void postLogCommitHook()
throws DatabaseException
DatabaseException - to indicate that there was a replication
related problem that needs to be communicated back to the application.protected void postLogAbortHook()
Copyright (c) 2004,2008 Oracle. All rights reserved.