| java.lang.Object com.sleepycat.je.txn.Locker
All known Subclasses: com.sleepycat.je.txn.Txn, com.sleepycat.je.txn.BasicLocker,
Locker | abstract public class Locker (Code) | | Locker instances are JE's route to locking and transactional support. This
class is the abstract base class for BasicLocker, ThreadLocker, Txn and
AutoTxn. Locker instances are in fact only a transaction shell to get to
the lock manager, and don't guarantee transactional semantics. Txn and
AutoTxn instances are both truely transactional, but have different ending
behaviors.
|
Constructor Summary | |
public | Locker(EnvironmentImpl envImpl, boolean readUncommittedDefault, boolean noWait) Create a locker id. | | Locker() For reading from the log. |
Method Summary | |
public void | addDeleteInfo(BIN bin, Key deletedKey) Add delete information, to be added to the inCompressor queue
when the transaction ends. | abstract void | addLock(Long nodeId, LockType type, LockGrantType grantStatus) Add a lock to set owned by this transaction. | public void | addToHandleMaps(Long handleLockId, Database databaseHandle) Remember how handle locks and handles match up. | abstract protected void | checkState(boolean ignoreCalledByAbort) | abstract public LockStats | collectStats(LockStats stats) Get lock count, for per transaction lock stats, for internal debugging. | abstract public boolean | createdNode(long nodeId) | public void | demoteLock(long nodeId) Revert this lock from a write lock to a read lock. | public void | dumpLockTable() | abstract protected long | generateId(TxnManager txnManager) A Locker has to generate its next id. | abstract public long | getAbortLsn(long nodeId) | public boolean | getDefaultNoWait() | public long | getId() | public synchronized long | getLockTimeout() | abstract public Txn | getTxnLocker() Returns the underlying Txn if the locker is transactional, or null if
the locker is non-transactional. | long | getTxnStartMillis() | public long | getTxnTimeOut() | Lock | getWaitingFor() | abstract public WriteLockInfo | getWriteLockInfo(long nodeId) | public boolean | isHandleLockTransferrable() | abstract public boolean | isReadCommittedIsolation() Returns whether the isolation level of this locker is read-committed. | public boolean | isReadUncommittedDefault() | abstract public boolean | isSerializableIsolation() Returns whether the isolation level of this locker is serializable. | public boolean | isTimedOut() | abstract public boolean | isTransactional() Returns whether this locker is transactional. | public 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.
Parameters: nodeId - is the node to lock. Parameters: lockType - is the type of lock to request. Parameters: noWait - is true to override the defaultNoWait setting. | abstract LockResult | lockInternal(long nodeId, LockType lockType, boolean noWait, DatabaseImpl database) Abstract method to a blocking or non-blocking lock of the given type on
the given nodeId. | abstract public 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 void | moveWriteToReadLock(long nodeId, Lock lock) A lock is being demoted. | abstract public Locker | newNonTxnLocker() Creates a fresh non-transactional locker, while retaining any
transactional locks held by this locker. | public LockResult | nonBlockingLock(long nodeId, LockType lockType, DatabaseImpl database) Request a non-blocking lock of the given type on the given nodeId.
Unlike lock(), this method returns LockGrantType.DENIED if the lock
is denied rather than throwing LockNotGrantedException. | abstract public void | operationEnd() The equivalent of calling operationEnd(true). | abstract public void | operationEnd(boolean operationOK) Different types of transactions do different things when the operation
ends. | public void | operationEnd(OperationStatus status) A SUCCESS status equals operationOk. | abstract public void | registerCursor(CursorImpl cursor) Tell this transaction about a cursor. | public void | releaseLock(long nodeId) Release the lock on this LN and remove from the transaction's owning
set. | abstract public void | releaseNonTxnLocks() Releases any non-transactional locks held by this locker. | abstract void | removeLock(long nodeId) Remove the lock from the set owned by this transaction. | abstract public void | setHandleLockOwner(boolean operationOK, Database dbHandle, boolean dbIsClosing) We're at the end of an operation. | public synchronized void | setLockTimeout(long timeout) Set the lock timeout period for any locks in this transaction,
in milliseconds.
Parameters: timeout - The timeout value for the transaction lifetime, inmilliseconds. | void | setOnlyAbortable() Set the state of a transaction to ONLY_ABORTABLE. | public synchronized void | setTxnTimeout(long timeout) Set the timeout period for this transaction, in milliseconds.
Parameters: timeout - The timeout value for the transaction lifetime, inmilliseconds. | void | setWaitingFor(Lock lock) | public boolean | sharesLocksWith(Locker other) Returns whether this locker can share locks with the given locker.
All lockers share locks with a BuddyLocker whose buddy is this
locker. | public String | toString() | public void | transferHandleLock(Database dbHandle, Locker destLocker, boolean demoteToRead) | void | transferHandleLockToHandle(Database dbHandle) The currentTxn passes responsiblity for this db handle lock to a txn
owned by the Database object. | abstract public void | unRegisterCursor(CursorImpl cursor) Remove a cursor from this txn. | void | unregisterHandle(Database dbHandle) |
defaultNoWait | protected boolean defaultNoWait(Code) | | |
handleLockToHandleMap | protected Map handleLockToHandleMap(Code) | | |
handleToHandleLockMap | protected Map handleToHandleLockMap(Code) | | |
lockTimeOutMillis | protected long lockTimeOutMillis(Code) | | |
readUncommittedDefault | protected boolean readUncommittedDefault(Code) | | |
thread | protected Thread thread(Code) | | The thread that created this locker. Used for debugging, and by the
ThreadLocker subclass. Note that thread may be null if the Locker is
instantiated by reading the log.
|
Locker | public Locker(EnvironmentImpl envImpl, boolean readUncommittedDefault, boolean noWait) throws DatabaseException(Code) | | Create a locker id. This constructor is called very often, so it should
be as streamlined as possible.
Parameters: lockManager - lock manager for this environment Parameters: readUncommittedDefault - if true, this transaction doesread-uncommitted by default Parameters: noWait - if true, non-blocking lock requests are used. |
Locker | Locker()(Code) | | For reading from the log.
|
addDeleteInfo | public void addDeleteInfo(BIN bin, Key deletedKey) throws DatabaseException(Code) | | Add delete information, to be added to the inCompressor queue
when the transaction ends.
|
addToHandleMaps | public void addToHandleMaps(Long handleLockId, Database databaseHandle)(Code) | | Remember how handle locks and handles match up.
|
createdNode | abstract public boolean createdNode(long nodeId) throws DatabaseException(Code) | | true if this transaction created this node,for a operation with transactional semantics. |
demoteLock | public void demoteLock(long nodeId) throws DatabaseException(Code) | | Revert this lock from a write lock to a read lock.
|
generateId | abstract protected long generateId(TxnManager txnManager)(Code) | | A Locker has to generate its next id. Some subtypes, like BasicLocker,
have a single id for all instances because they are never used for
recovery. Other subtypes ask the txn manager for an id.
|
getAbortLsn | abstract public long getAbortLsn(long nodeId) throws DatabaseException(Code) | | the abort LSN for this node. |
getDefaultNoWait | public boolean getDefaultNoWait()(Code) | | the default no-wait (non-blocking) setting. |
getId | public long getId()(Code) | | the transaction's id. |
getLockTimeout | public synchronized long getLockTimeout()(Code) | | Get the lock timeout period for this transaction, in milliseconds
|
getTxnLocker | abstract public Txn getTxnLocker()(Code) | | Returns the underlying Txn if the locker is transactional, or null if
the locker is non-transactional. For a Txn-based locker, this method
returns 'this'. For a BuddyLocker, this method may returns the buddy.
|
getTxnStartMillis | long getTxnStartMillis()(Code) | | |
getTxnTimeOut | public long getTxnTimeOut()(Code) | | |
isHandleLockTransferrable | public boolean isHandleLockTransferrable()(Code) | | true if this txn is willing to give up the handle lock toanother txn before this txn ends. |
isReadCommittedIsolation | abstract public boolean isReadCommittedIsolation()(Code) | | Returns whether the isolation level of this locker is read-committed.
|
isReadUncommittedDefault | public boolean isReadUncommittedDefault()(Code) | | true if transaction was created with read-uncommitted as adefault. |
isSerializableIsolation | abstract public boolean isSerializableIsolation()(Code) | | Returns whether the isolation level of this locker is serializable.
|
isTransactional | abstract public boolean isTransactional()(Code) | | Returns whether this locker is transactional.
|
lock | public LockResult lock(long nodeId, LockType lockType, boolean noWait, DatabaseImpl database) throws LockNotGrantedException, DeadlockException, DatabaseException(Code) | | Request a blocking or non-blocking lock of the given type on the given
nodeId.
Parameters: nodeId - is the node to lock. Parameters: lockType - is the type of lock to request. Parameters: noWait - is true to override the defaultNoWait setting. If true,or if defaultNoWait is true, throws LockNotGrantedException if the lockcannot be granted without waiting. Parameters: database - is the database containing nodeId. throws: LockNotGrantedException - if a non-blocking lock was denied. throws: DeadlockException - if acquiring a blocking lock would result in adeadlock. |
lockInternal | abstract LockResult lockInternal(long nodeId, LockType lockType, boolean noWait, DatabaseImpl database) throws DeadlockException, DatabaseException(Code) | | Abstract method to a blocking or non-blocking lock of the given type on
the given nodeId. Unlike the lock() method, this method does not throw
LockNotGrantedException and can therefore be used by nonBlockingLock to
probe for a lock without the overhead of an exception stack trace.
Parameters: nodeId - is the node to lock. Parameters: lockType - is the type of lock to request. Parameters: noWait - is true to override the defaultNoWait setting. If true,or if defaultNoWait is true, throws LockNotGrantedException if the lockcannot be granted without waiting. Parameters: database - is the database containing nodeId. throws: DeadlockException - if acquiring a blocking lock would result in adeadlock. |
markDeleteAtTxnEnd | abstract public void markDeleteAtTxnEnd(DatabaseImpl db, boolean deleteAtCommit) throws DatabaseException(Code) | | Database operations like remove and truncate leave behind
residual DatabaseImpls that must be purged at transaction
commit or abort.
|
moveWriteToReadLock | abstract void moveWriteToReadLock(long nodeId, Lock lock)(Code) | | A lock is being demoted. Move it from the write collection into the read
collection.
|
newNonTxnLocker | abstract public Locker newNonTxnLocker() throws DatabaseException(Code) | | Creates a fresh non-transactional locker, while retaining any
transactional locks held by this locker. This method is called when the
cursor for this locker is cloned.
In general, transactional lockers return 'this' when this method is
called, while non-transactional lockers return a new instance.
|
nonBlockingLock | public LockResult nonBlockingLock(long nodeId, LockType lockType, DatabaseImpl database) throws DatabaseException(Code) | | Request a non-blocking lock of the given type on the given nodeId.
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.
Parameters: nodeId - is the node to lock. Parameters: lockType - is the type of lock to request. Parameters: database - is the database containing nodeId. |
operationEnd | abstract public void operationEnd() throws DatabaseException(Code) | | The equivalent of calling operationEnd(true).
|
operationEnd | abstract public void operationEnd(boolean operationOK) throws DatabaseException(Code) | | Different types of transactions do different things when the operation
ends. Txns do nothing, AutoTxns commit or abort, and BasicLockers and
ThreadLockers just release locks.
Parameters: operationOK - is whether the operation succeeded, sincethat may impact ending behavior. (i.e for AutoTxn) |
releaseLock | public void releaseLock(long nodeId) throws DatabaseException(Code) | | Release the lock on this LN and remove from the transaction's owning
set.
|
releaseNonTxnLocks | abstract public void releaseNonTxnLocks() throws DatabaseException(Code) | | Releases any non-transactional locks held by this locker. This method
is called when the cursor moves to a new position or is closed.
In general, transactional lockers do nothing when this method is
called, while non-transactional lockers release all locks as if
operationEnd were called.
|
removeLock | abstract void removeLock(long nodeId) throws DatabaseException(Code) | | Remove the lock from the set owned by this transaction. If specified to
LockManager.release, the lock manager will call this when its releasing
a lock.
|
setHandleLockOwner | abstract public void setHandleLockOwner(boolean operationOK, Database dbHandle, boolean dbIsClosing) throws DatabaseException(Code) | | We're at the end of an operation. Move this handle lock to the
appropriate owner.
|
setLockTimeout | public synchronized void setLockTimeout(long timeout)(Code) | | Set the lock timeout period for any locks in this transaction,
in milliseconds.
Parameters: timeout - The timeout value for the transaction lifetime, inmilliseconds. A value of 0 disables timeouts for the transaction. throws: IllegalArgumentException - If the value of timeout is negative. |
setOnlyAbortable | void setOnlyAbortable()(Code) | | Set the state of a transaction to ONLY_ABORTABLE.
|
setTxnTimeout | public synchronized void setTxnTimeout(long timeout)(Code) | | Set the timeout period for this transaction, in milliseconds.
Parameters: timeout - The timeout value for the transaction lifetime, inmilliseconds. A value of 0 disables timeouts for the transaction. throws: IllegalArgumentException - If the value of timeout is negative. |
sharesLocksWith | public boolean sharesLocksWith(Locker other)(Code) | | Returns whether this locker can share locks with the given locker.
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.
|
transferHandleLockToHandle | void transferHandleLockToHandle(Database dbHandle) throws DatabaseException(Code) | | The currentTxn passes responsiblity for this db handle lock to a txn
owned by the Database object.
|
unregisterHandle | void unregisterHandle(Database dbHandle)(Code) | | Remove this Database from the protected Database handle set
|
|
|