public abstract class Locker
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected boolean |
defaultNoWait |
protected java.util.Map<java.lang.Long,BINReference> |
deleteInfo |
protected EnvironmentImpl |
envImpl |
protected java.util.Map<java.lang.Long,java.util.Set<Database>> |
handleLockToHandleMap |
protected java.util.Map<Database,java.lang.Long> |
handleToHandleLockMap |
protected long |
id |
protected LockManager |
lockManager |
protected boolean |
readUncommittedDefault |
protected java.lang.Thread |
thread
The thread that created this locker.
|
Modifier | Constructor and Description |
---|---|
protected |
Locker(EnvironmentImpl envImpl,
boolean readUncommittedDefault,
boolean noWait,
boolean noAPIReadLock,
long mandatedId)
Create a locker id.
|
protected |
Locker(EnvironmentImpl envImpl,
boolean readUncommittedDefault,
boolean noWait,
long mandatedId)
Create a locker id.
|
Modifier and Type | Method and Description |
---|---|
void |
addDeleteInfo(BIN bin,
Key deletedKey)
Add delete information, to be added to the inCompressor queue
when the transaction ends.
|
protected abstract void |
addLock(java.lang.Long nodeId,
LockType type,
LockGrantType grantStatus)
Add a lock to set owned by this transaction.
|
void |
addToHandleMaps(java.lang.Long handleLockId,
Database databaseHandle)
Remember how handle locks and handles match up.
|
protected abstract void |
checkState(boolean ignoreCalledByAbort) |
abstract LockStats |
collectStats(LockStats stats)
Get lock count, for per transaction lock stats, for internal debugging.
|
abstract boolean |
createdNode(long nodeId) |
void |
demoteLock(long nodeId)
Revert this lock from a write lock to a read lock.
|
void |
dumpLockTable()
Dump lock table, for debugging
|
protected abstract long |
generateId(TxnManager txnManager,
long mandatedId)
A Locker has to generate its next id.
|
abstract long |
getAbortLsn(long nodeId) |
boolean |
getDefaultNoWait() |
long |
getId() |
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.
|
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 nodeId) |
void |
initApiReadLock() |
boolean |
isHandleLockTransferrable() |
abstract boolean |
isReadCommittedIsolation()
Returns whether the isolation level of this locker is read-committed.
|
boolean |
isReadUncommittedDefault() |
abstract boolean |
isSerializableIsolation()
Returns whether the isolation level of this locker is serializable.
|
boolean |
isTimedOut() |
abstract boolean |
isTransactional()
Returns whether this locker is transactional.
|
LockResult |
lock(long nodeId,
LockType lockType,
boolean noWait,
DatabaseImpl database)
Request a blocking or non-blocking lock of the given type on the given
nodeId.
|
abstract void |
markDeleteAtTxnEnd(DatabaseImpl db,
boolean deleteAtCommit)
Database operations like remove and truncate leave behind
residual DatabaseImpls that must be purged at transaction
commit or abort.
|
abstract Locker |
newNonTxnLocker()
Creates a fresh non-transactional locker, while retaining any
transactional locks held by this locker.
|
LockResult |
nonBlockingLock(long nodeId,
LockType lockType,
DatabaseImpl database)
Request a non-blocking lock of the given type on the given nodeId.
|
abstract void |
nonTxnOperationEnd()
Releases locks and closes the locker at the end of a non-transactional
cursor operation.
|
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 |
registerCursor(CursorImpl cursor)
Tell this transaction about a cursor.
|
boolean |
releaseLock(long nodeId)
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.
|
abstract void |
setHandleLockOwner(boolean operationOK,
Database dbHandle,
boolean dbIsClosing)
We're at the end of an operation.
|
void |
setLockTimeout(long timeout)
Set the lock timeout period for any locks in this transaction,
in milliseconds.
|
void |
setOnlyAbortable()
Set the state of a transaction to ONLY_ABORTABLE.
|
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.
|
java.lang.String |
toString() |
void |
transferHandleLock(Database dbHandle,
Locker destLocker,
boolean demoteToRead) |
abstract void |
unRegisterCursor(CursorImpl cursor)
Remove a cursor from this txn.
|
protected EnvironmentImpl envImpl
protected LockManager lockManager
protected long id
protected boolean readUncommittedDefault
protected boolean defaultNoWait
protected java.util.Map<java.lang.Long,BINReference> deleteInfo
protected java.util.Map<java.lang.Long,java.util.Set<Database>> handleLockToHandleMap
protected java.util.Map<Database,java.lang.Long> handleToHandleLockMap
protected java.lang.Thread thread
protected Locker(EnvironmentImpl envImpl, boolean readUncommittedDefault, boolean noWait, long mandatedId) throws DatabaseException
lockManager
- lock manager for this environmentreadUncommittedDefault
- if true, this transaction does
read-uncommitted by defaultnoWait
- if true, non-blocking lock requests are used.DatabaseException
protected Locker(EnvironmentImpl envImpl, boolean readUncommittedDefault, boolean noWait, boolean noAPIReadLock, long mandatedId) throws DatabaseException
lockManager
- lock manager for this environmentreadUncommittedDefault
- if true, this transaction does
read-uncommitted by defaultnoWait
- if true, non-blocking lock requests are used.noAPIReadLock
- if true, the API read lock is not acquired.DatabaseException
protected abstract long generateId(TxnManager txnManager, long mandatedId)
public long getId()
public boolean getDefaultNoWait()
public long getLockTimeout()
public void setLockTimeout(long timeout)
timeout
- The timeout value for the transaction lifetime, in
microseconds. A value of 0 disables timeouts for the transaction.java.lang.IllegalArgumentException
- If the value of timeout is negativepublic void setTxnTimeout(long timeout)
timeout
- The timeout value for the transaction lifetime, in
microseconds. A value of 0 disables timeouts for the transaction.java.lang.IllegalArgumentException
- If the value of timeout is negative.public boolean isReadUncommittedDefault()
public void setOnlyAbortable()
public void initApiReadLock() throws DatabaseException
DatabaseException
protected abstract void checkState(boolean ignoreCalledByAbort) throws DatabaseException
DatabaseException
public LockResult lock(long nodeId, LockType lockType, boolean noWait, DatabaseImpl database) throws LockNotGrantedException, DeadlockException, DatabaseException
nodeId
- 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.LockNotGrantedException
- if a non-blocking lock was denied.DeadlockException
- if acquiring a blocking lock would result in a
deadlock.DatabaseException
public LockResult nonBlockingLock(long nodeId, LockType lockType, DatabaseImpl database) throws DatabaseException
Unlike lock(), this method returns LockGrantType.DENIED if the lock is denied rather than throwing LockNotGrantedException. This method should therefore not be used as the final lock for a user operation, since in that case LockNotGrantedException should be thrown for a denied lock. It is normally used only to probe for a lock, and other recourse is taken if the lock is denied.
nodeId
- is the node to lock.lockType
- is the type of lock to request.database
- is the database containing nodeId.DatabaseException
public boolean releaseLock(long nodeId) throws DatabaseException
DatabaseException
public void demoteLock(long nodeId) throws DatabaseException
DatabaseException
public abstract boolean isTransactional()
public abstract boolean isSerializableIsolation()
public abstract boolean isReadCommittedIsolation()
public abstract Txn getTxnLocker()
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.
DatabaseException
public 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.
DatabaseException
public abstract void nonTxnOperationEnd() throws DatabaseException
DatabaseException
public boolean sharesLocksWith(Locker other)
All lockers share locks with a BuddyLocker whose buddy is this locker. To support BuddyLocker when overriding this method, always return true if this implementation (super.sharesLocksWith(...)) returns true.
public final void operationEnd() throws DatabaseException
DatabaseException
public final void operationEnd(OperationStatus status) throws DatabaseException
DatabaseException
public 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)DatabaseException
public abstract void setHandleLockOwner(boolean operationOK, Database dbHandle, boolean dbIsClosing) throws DatabaseException
DatabaseException
public abstract void registerCursor(CursorImpl cursor) throws DatabaseException
DatabaseException
public abstract void unRegisterCursor(CursorImpl cursor) throws DatabaseException
DatabaseException
public abstract long getAbortLsn(long nodeId) throws DatabaseException
DatabaseException
public abstract WriteLockInfo getWriteLockInfo(long nodeId) throws DatabaseException
DatabaseException
public abstract void markDeleteAtTxnEnd(DatabaseImpl db, boolean deleteAtCommit) throws DatabaseException
DatabaseException
public void addDeleteInfo(BIN bin, Key deletedKey) throws DatabaseException
DatabaseException
protected abstract void addLock(java.lang.Long nodeId, LockType type, LockGrantType grantStatus) throws DatabaseException
DatabaseException
public abstract boolean createdNode(long nodeId) throws DatabaseException
DatabaseException
public abstract LockStats collectStats(LockStats stats) throws DatabaseException
DatabaseException
public boolean isTimedOut() throws DatabaseException
DatabaseException
public long getTxnTimeout()
public void addToHandleMaps(java.lang.Long handleLockId, Database databaseHandle)
public boolean isHandleLockTransferrable()
public void transferHandleLock(Database dbHandle, Locker destLocker, boolean demoteToRead) throws DatabaseException
DatabaseException
public java.lang.String toString()
toString
in class java.lang.Object
public void dumpLockTable() throws DatabaseException
DatabaseException