public abstract class Locker extends Object
| Modifier and Type | Field and Description |
|---|---|
TestHook<Object> |
afterWaiterHook
Hook called by lock manager after adding this locker as a waiter.
|
protected EnvironmentImpl |
envImpl |
protected long |
id |
protected LockManager |
lockManager |
protected Thread |
thread
The thread that created this locker.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Locker(EnvironmentImpl envImpl,
boolean readUncommittedDefault,
boolean noWait,
long mandatedId)
Create a locker id.
|
| Modifier and Type | Method and Description |
|---|---|
abstract void |
addDbCleanup(DbCleanup cleanup)
Database operations like remove, truncate and rename require that
DatabaseImpls are deleted or updated at transaction commit or abort.
|
void |
addDeleteInfo(BIN bin)
Add delete information, to be added to the inCompressor queue when the
transaction ends.
|
protected abstract void |
addLock(Long lsn,
LockType type,
LockGrantType grantStatus)
Add a lock to set owned by this transaction.
|
void |
addOpenedDatabase(Database dbHandle) |
boolean |
allowReleaseLockAfterLsnChange() |
void |
checkPreempted(Locker allowPreemptedLocker)
Called when obtaining a lock to cause a LockPreemptedException to be
thrown if a lock was preempted earlier.
|
protected abstract void |
checkState(boolean ignoreCalledByAbort) |
abstract StatGroup |
collectStats()
Get lock count, for per transaction lock stats, for internal debugging.
|
void |
demoteLock(long lsn)
Revert this lock from a write lock to a read lock.
|
void |
disallowReplicaWrite()
Throws ReplicaWriteException if called for a locker on a Replica.
|
void |
dumpLockTable()
Dump lock table, for debugging
|
protected abstract long |
generateId(TxnManager txnManager,
long mandatedId)
A Locker has to generate its next id.
|
boolean |
getDefaultNoWait() |
EnvironmentImpl |
getEnvironment() |
long |
getId() |
boolean |
getImportunate()
Get the state of a transaction's IMPORTUNATE bit.
|
protected long |
getInitialLockTimeout() |
long |
getLockTimeout()
Get the lock timeout period for this locker, in milliseconds
WARNING: Be sure to always access the timeout with this accessor, since
it is overridden in BuddyLocker.
|
boolean |
getPreemptable()
Returns whether my locks can be stolen/preemted.
|
Transaction |
getTransaction()
Returns a Transaction if the locker is transctional, or null otherwise.
|
abstract Txn |
getTxnLocker()
Returns the underlying Txn if the locker is transactional, or null if
the locker is non-transactional.
|
long |
getTxnTimeout()
Get the transaction timeout period for this locker, in milliseconds
public for jca/ra/JELocalTransaction.
|
abstract WriteLockInfo |
getWriteLockInfo(long lsn) |
boolean |
isLocalWrite()
Returns true if writes may only be to non-replicated DBs using this
locker, or false if writes may only be to replicated DBs.
|
abstract boolean |
isReadCommittedIsolation()
Returns whether the isolation level of this locker is read-committed.
|
boolean |
isReadOnly()
Returns whether writes are prohibited using this locker.
|
boolean |
isReadUncommittedDefault() |
boolean |
isReplicated()
Returns whether a transaction is method indicates whether the txn is
part of the rep stream.
|
boolean |
isRolledBack() |
abstract boolean |
isSerializableIsolation()
Returns whether the isolation level of this locker is serializable.
|
boolean |
isTimedOut() |
abstract boolean |
isTransactional()
Returns whether this locker is transactional.
|
boolean |
isValid()
Used to determine whether the locker is usable.
|
LockResult |
lock(long lsn,
LockType lockType,
boolean noWait,
DatabaseImpl database)
Request a blocking or non-blocking lock of the given type on the given
LSN.
|
void |
lockAfterLsnChange(long oldLsn,
long newLsn,
DatabaseImpl dbImpl)
Called when an LN is logged by an operation that will not hold the lock
such as eviction/checkpoint deferred-write logging or cleaner LN
migration.
|
abstract boolean |
lockingRequired()
Returns true if locking is required for this Locker.
|
abstract Locker |
newNonTxnLocker()
Creates a fresh non-transactional locker, while retaining any
transactional locks held by this locker.
|
LockResult |
nonBlockingLock(long lsn,
LockType lockType,
boolean jumpAheadOfWaiters,
DatabaseImpl database)
Request a non-blocking lock of the given type on the given LSN.
|
abstract void |
nonTxnOperationEnd()
Releases locks and closes the locker at the end of a non-transactional
cursor operation.
|
void |
openCursorHook(DatabaseImpl dbImpl)
Overridden to perform actions in a non-transactional cursor when it is
opened, for example, ReplicaThreadLocker performs consistency checks.
|
void |
operationEnd()
The equivalent of calling operationEnd(true).
|
abstract void |
operationEnd(boolean operationOK)
Different types of transactions do different things when the operation
ends.
|
void |
operationEnd(OperationStatus status)
A SUCCESS status equals operationOk.
|
abstract void |
preLogWithoutLock(DatabaseImpl database)
In the case where logging occurs before locking, allow lockers to reject
the operation (e.g., if writing on a replica) and also prepare to undo
in the (very unlikely) event that logging succeeds but locking fails.
|
abstract void |
registerCursor(CursorImpl cursor)
Tell this transaction about a cursor.
|
boolean |
releaseLock(long lsn)
Release the lock on this LN and remove from the transaction's owning
set.
|
abstract void |
releaseNonTxnLocks()
Releases any non-transactional locks held by this locker.
|
void |
setClosingLocker(Locker closingLocker)
This method is called to set the closingLocker when a cursor has been
duplicated prior to being moved.
|
void |
setDefaultNoWait(boolean noWait) |
void |
setImportunate(boolean importunate)
Set the state of a transaction's IMPORTUNATE bit.
|
void |
setLockTimeout(long timeout)
Set the lock timeout period for any locks in this transaction,
in milliseconds.
|
void |
setOnlyAbortable(OperationFailureException cause)
Set the state of a transaction to abort-only.
|
void |
setPreemptable(boolean preemptable)
Allows/disallows my locks from being stolen/preemted.
|
void |
setPreempted()
Called when a lock is stolen from this locker by the HA replayer.
|
void |
setTxnTimeout(long timeout)
Set the timeout period for this transaction, in milliseconds.
|
boolean |
sharesLocksWith(Locker other)
Returns whether this locker can share locks with the given locker.
|
String |
toString()
This method is safe to call without synchronizing and this fact is
relied on by LockManager when creating exception messages.
|
abstract void |
unRegisterCursor(CursorImpl cursor)
Remove a cursor from this txn.
|
protected EnvironmentImpl envImpl
protected LockManager lockManager
protected long id
protected Thread thread
protected Locker(EnvironmentImpl envImpl, boolean readUncommittedDefault, boolean noWait, long mandatedId)
readUncommittedDefault - if true, this transaction does
read-uncommitted by defaultnoWait - if true, non-blocking lock requests are used.protected long getInitialLockTimeout()
public EnvironmentImpl getEnvironment()
protected abstract long generateId(TxnManager txnManager, long mandatedId)
public long getId()
public boolean getDefaultNoWait()
public void setDefaultNoWait(boolean noWait)
public long getLockTimeout()
public void setLockTimeout(long timeout)
timeout - The timeout value for the transaction lifetime, in
milliseconds. A value of 0 disables timeouts for the transaction.IllegalArgumentException - via Transaction.setLockTimeoutpublic void setTxnTimeout(long timeout)
timeout - The timeout value for the transaction lifetime, in
microseconds. A value of 0 disables timeouts for the transaction.IllegalArgumentException - via Transaction.setLockTimeoutpublic boolean isReadUncommittedDefault()
public void setOnlyAbortable(OperationFailureException cause)
public void setImportunate(boolean importunate)
public boolean getImportunate()
public void setPreemptable(boolean preemptable)
public boolean getPreemptable()
public void setPreempted()
public void checkPreempted(Locker allowPreemptedLocker) throws OperationFailureException
allowPreemptedLocker - 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 setClosingLocker(Locker closingLocker)
closingLocker - the old locker that will be closed if the new
cursor (using this locker) is moved successfully.protected abstract void checkState(boolean ignoreCalledByAbort)
throws DatabaseException
DatabaseExceptionpublic void openCursorHook(DatabaseImpl dbImpl)
public boolean isReplicated()
public boolean isLocalWrite()
public boolean isReadOnly()
public LockResult lock(long lsn, LockType lockType, boolean noWait, DatabaseImpl database) throws LockNotAvailableException, LockConflictException
lsn - 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 lsn.LockNotAvailableException - if a non-blocking lock was denied.LockConflictException - if a blocking lock could not be acquired.public LockResult nonBlockingLock(long lsn, LockType lockType, boolean jumpAheadOfWaiters, DatabaseImpl database)
Unlike lock(), this method returns LockGrantType.DENIED if the lock is denied rather than throwing LockNotAvailableException. This method should therefore not be used as the final lock for a user operation, since in that case LockNotAvailableException should be thrown for a denied lock. It is normally used only to probe for a lock internally, and other recourse is taken if the lock is denied.
lsn - is the node to lock.lockType - is the type of lock to request.jumpAheadOfWaiters - grant the lock before other waiters, if any.database - is the database containing LSN.public boolean releaseLock(long lsn)
throws DatabaseException
DatabaseExceptionpublic void demoteLock(long lsn)
throws DatabaseException
DatabaseExceptionpublic void lockAfterLsnChange(long oldLsn,
long newLsn,
DatabaseImpl dbImpl)
public abstract void preLogWithoutLock(DatabaseImpl database)
public void disallowReplicaWrite()
public abstract boolean isTransactional()
public abstract boolean isSerializableIsolation()
public abstract boolean isReadCommittedIsolation()
public abstract Txn getTxnLocker()
public Transaction getTransaction()
public abstract Locker newNonTxnLocker() throws DatabaseException
This method must return a locker that shares locks with this locker, e.g., a ThreadLocker.
In general, transactional lockers return 'this' when this method is called, while non-transactional lockers return a new instance.
DatabaseExceptionpublic abstract void releaseNonTxnLocks()
throws DatabaseException
In general, transactional lockers do nothing when this method is called, while non-transactional lockers release all locks as if operationEnd were called.
DatabaseExceptionpublic abstract void nonTxnOperationEnd()
throws DatabaseException
DatabaseExceptionpublic boolean sharesLocksWith(Locker other)
public final void operationEnd()
throws DatabaseException
DatabaseExceptionpublic final void operationEnd(OperationStatus status) throws DatabaseException
DatabaseExceptionpublic abstract void operationEnd(boolean operationOK)
throws DatabaseException
operationOK - is whether the operation succeeded, since
that may impact ending behavior. (i.e for an auto Txn)DatabaseExceptionpublic boolean isValid()
public void addOpenedDatabase(Database dbHandle)
public boolean allowReleaseLockAfterLsnChange()
public abstract void registerCursor(CursorImpl cursor)
public abstract void unRegisterCursor(CursorImpl cursor)
public abstract boolean lockingRequired()
public abstract WriteLockInfo getWriteLockInfo(long lsn)
public abstract void addDbCleanup(DbCleanup cleanup)
public void addDeleteInfo(BIN bin)
protected abstract void addLock(Long lsn, LockType type, LockGrantType grantStatus) throws DatabaseException
DatabaseExceptionpublic abstract StatGroup collectStats() throws DatabaseException
DatabaseExceptionpublic boolean isTimedOut()
public long getTxnTimeout()
public boolean isRolledBack()
public String toString()
public void dumpLockTable()
throws DatabaseException
DatabaseExceptionCopyright © 2024. All rights reserved.