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) |
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) |
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() |
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.
|
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.
|
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.
|
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, demoteLock, dumpLockTable, getDefaultNoWait, getId, getLockTimeout, getTxnTimeout, initApiReadLock, isReadUncommittedDefault, isTimedOut, lock, nonBlockingLock, operationEnd, operationEnd, releaseLock, setLockTimeout, setTxnTimeout, sharesLocksWith, toString, transferHandleLock
protected 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
DatabaseException
protected Txn(EnvironmentImpl envImpl, TransactionConfig config, boolean noAPIReadLock, long mandatedId) throws DatabaseException
DatabaseException
public Txn(EnvironmentImpl envImpl, TransactionConfig config, ReplicationContext repContext) throws DatabaseException
DatabaseException
public static Txn createTxn(EnvironmentImpl envImpl, TransactionConfig config, ReplicationContext repContext) throws DatabaseException
DatabaseException
public static Txn createAutoTxn(EnvironmentImpl envImpl, TransactionConfig config, boolean noAPIReadLock, ReplicationContext repContext) throws DatabaseException
DatabaseException
protected long generateId(TxnManager txnManager, long ignore)
generateId
in class Locker
public long getLastLsn()
public Durability getCommitDurability()
public Durability getDefaultDurability()
public boolean getPrepared()
public void setPrepared(boolean prepared)
public void setSuspended(boolean suspended)
public boolean isSuspended()
public int prepare(javax.transaction.xa.Xid xid) throws DatabaseException
DatabaseException
public void commit(javax.transaction.xa.Xid xid) throws DatabaseException
DatabaseException
public void abort(javax.transaction.xa.Xid xid) throws DatabaseException
DatabaseException
public long commit() throws DatabaseException
DatabaseException
public long commit(Durability durability) throws DatabaseException
DatabaseException
public long abort(boolean forceFlush) throws DatabaseException
DatabaseException
protected void undo() throws DatabaseException
DatabaseException
public void addLogInfo(long lastLsn) throws DatabaseException
DatabaseException
public void markDeleteAtTxnEnd(DatabaseImpl dbImpl, boolean deleteAtCommit) throws DatabaseException
Locker
markDeleteAtTxnEnd
in class Locker
dbImpl
- databaseImpl to removedeleteAtCommit
- true if this databaseImpl should be cleaned on
commit, false if it should be cleaned on abort.mb
- environment memory budget.DatabaseException
protected void cleanupDatabaseImpls(boolean isCommit) throws DatabaseException
DatabaseException
protected void addLock(java.lang.Long nodeId, LockType type, LockGrantType grantStatus) throws DatabaseException
addLock
in class Locker
DatabaseException
public boolean createdNode(long nodeId) throws DatabaseException
createdNode
in class Locker
DatabaseException
public long getAbortLsn(long nodeId) throws DatabaseException
getAbortLsn
in class Locker
DatabaseException
public WriteLockInfo getWriteLockInfo(long nodeId) throws DatabaseException
getWriteLockInfo
in class Locker
DatabaseException
public boolean isTransactional()
isTransactional
in class Locker
public boolean isAutoTxn()
public boolean isSerializableIsolation()
isSerializableIsolation
in class Locker
public boolean isReadCommittedIsolation()
isReadCommittedIsolation
in class Locker
public boolean getExplicitSyncConfigured()
public boolean getExplicitDurabilityConfigured()
public Txn getTxnLocker()
getTxnLocker
in class Locker
public Locker newNonTxnLocker() throws DatabaseException
newNonTxnLocker
in class Locker
DatabaseException
public void releaseNonTxnLocks() throws DatabaseException
releaseNonTxnLocks
in class Locker
DatabaseException
public void nonTxnOperationEnd() throws DatabaseException
nonTxnOperationEnd
in class Locker
DatabaseException
public void operationEnd(boolean operationOK) throws DatabaseException
Locker
operationEnd
in class Locker
operationOK
- 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 Locker
DatabaseException
public void registerCursor(CursorImpl cursor) throws DatabaseException
registerCursor
in class Locker
DatabaseException
public void unRegisterCursor(CursorImpl cursor) throws DatabaseException
unRegisterCursor
in class Locker
DatabaseException
public boolean isHandleLockTransferrable()
isHandleLockTransferrable
in class Locker
public LockStats collectStats(LockStats stats) throws DatabaseException
collectStats
in class Locker
DatabaseException
public void setOnlyAbortable()
setOnlyAbortable
in class Locker
public boolean getOnlyAbortable()
protected void checkState(boolean calledByAbort) throws DatabaseException
checkState
in class Locker
DatabaseException
public void setRepContext(ReplicationContext repContext)
protected void close(boolean isCommit) throws DatabaseException
DatabaseException
public boolean isClosed()
protected int getReplicatorNodeId()
public int getLogSize()
getLogSize
in interface Loggable
Loggable.getLogSize()
public void writeToLog(java.nio.ByteBuffer logBuffer)
Loggable
writeToLog
in interface Loggable
logBuffer
- is the destination bufferLoggable.writeToLog(java.nio.ByteBuffer)
public void readFromLog(java.nio.ByteBuffer logBuffer, byte entryVersion)
Loggable
readFromLog
in interface Loggable
It's ok for FindBugs to whine about id not being synchronized.
public void dumpLog(java.lang.StringBuffer sb, boolean verbose)
Loggable
dumpLog
in interface Loggable
sb
- destination string bufferverbose
- if true, dump the full, verbose versionLoggable.dumpLog(java.lang.StringBuffer, boolean)
public long getTransactionId()
getTransactionId
in interface Loggable
Loggable.getTransactionId()
public boolean logicalEquals(Loggable other)
logicalEquals
in interface Loggable
Loggable.logicalEquals(com.sleepycat.je.log.Loggable)
protected void txnBeginHook(TransactionConfig config) throws DatabaseException
config
- the transaction config that applies to the txnDatabaseException
protected 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()