private class InMemoryLockManager.LockStatus
extends java.lang.Object
RecordIdentifier
object which uniquely identifies
the locked record.
RecordIdentifier
objects.Modifier and Type | Field and Description |
---|---|
private RecordIdentifier |
ident
Unique identifier of record associated with this status object
|
private long |
lockAdminTime
Timestamp at which lock was first obtained, for admin purposes
|
private java.util.Set<SessionToken> |
lockers
The set of IDs of the lockers of the record
|
private LockType |
lockType
The type of lock being held on the record
|
private long |
lockWarnTime
Timestamp at which lock was first obtained, for warning purposes
|
Constructor and Description |
---|
LockStatus(RecordIdentifier ident,
LockType lockType)
Constructor.
|
LockStatus(RecordIdentifier ident,
LockType lockType,
SessionToken locker)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
(package private) boolean |
addLocker(SessionToken locker)
Add a locking context to the set of contexts which currently hold
locks on the backing record.
|
(package private) int |
getLockerCount()
Determine the number of contexts which currently hold a lock on the
backing record.
|
(package private) RecordLockInfo |
getLockInfo()
Store this object's information within a
RecordLockInfo object for
administrative purposes. |
(package private) LockType |
getLockType()
Retrieve the current lock type applied to the backing record.
|
(package private) RecordIdentifier |
getRecordIdentifier()
Retrieve the object which uniquely identifies the record represented
by this lock status object.
|
(package private) boolean |
isLockedBy(SessionToken locker)
Indicate whether the specified locking context is among those which
currently lock the backing record.
|
(package private) boolean |
isOnlyLocker(SessionToken locker)
Determine whether the specified locker is the only context which
currently holds a lock on the backing record.
|
(package private) java.util.Iterator<SessionToken> |
lockers()
Get an iterator on the lockers currently holding this lock.
|
(package private) void |
logContention(LockType requested)
Log debugging information about a lock acquisition request which
causes contention with one or more existing lock holders.
|
private void |
recordOrReportTime(LockType oldType,
LockType newType)
Given an old lock type and a new lock type, either record the current
time, or check whether the elapsed time since the last recorded time
exceeds the reporting threshold, and write a warning to the log.
|
protected void |
removeLocker(SessionToken locker)
Remove a locking context from the set of contexts which currently
hold locks on the backing record.
|
(package private) boolean |
setLockType(LockType lockType)
Set the current lock type applied to the backing record.
|
java.lang.String |
toString()
Compose a string representation of this object for assistance in
debugging and testing.
|
protected java.lang.String |
toStringVerbose()
Compose a string representation of this object for assistance in
debugging and testing.
|
private final RecordIdentifier ident
private final java.util.Set<SessionToken> lockers
private LockType lockType
private long lockAdminTime
private long lockWarnTime
LockStatus(RecordIdentifier ident, LockType lockType)
ident
- Unique identifier of record associated with this status
object.lockType
- Type of lock initially held on the record.java.lang.NullPointerException
- if locker
is null
.LockStatus(RecordIdentifier ident, LockType lockType, SessionToken locker)
ident
- Unique identifier of record associated with this status
object.lockType
- Type of lock initially held on the record.locker
- the initial locking context.java.lang.NullPointerException
- if locker
is null
.public java.lang.String toString()
toString
in class java.lang.Object
protected void removeLocker(SessionToken locker)
LockType.NONE
and notify any threads which are blocked on this object to resume
processing.locker
- Unique identifier of locking context to be removed.protected java.lang.String toStringVerbose()
RecordLockInfo getLockInfo()
RecordLockInfo
object for
administrative purposes.void logContention(LockType requested)
requested
- Lock type which was requested.RecordIdentifier getRecordIdentifier()
java.util.Iterator<SessionToken> lockers()
SessionToken
s.boolean addLocker(SessionToken locker)
locker
- Unique identifier of locking context to be added.true
if locker
was added; false
if
locker
already was in the set of lockers.LockType getLockType()
boolean setLockType(LockType lockType)
lockType
- Lock type.true
to indicate lock type was changed; false
to
indicate lockType
was the same as the existing lock type.boolean isLockedBy(SessionToken locker)
locker
- Unique context identifier to check.true
if locker
is among the
records current lockers, else false
.boolean isOnlyLocker(SessionToken locker)
locker
- Unique identifier of the locking context to be checked.true
if the given locker is the only entity
holding a lock on the backing record, else
false
.int getLockerCount()
private void recordOrReportTime(LockType oldType, LockType newType)
If the new lock type is more restrictive than the old, we record the current time. If the new lock type is less restrictive than the old, we check the threshold and possibly report the warning. The idea is to report when a lock is potentially blocking other access for longer than expected.
oldType
- Old lock type.newType
- New lock type.