|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.sgs.impl.util.lock.LockManager<K>
com.sun.sgs.impl.util.lock.TxnLockManager<K>
K - the type of keypublic final class TxnLockManager<K>
A class for managing lock conflicts of a transaction. Calls on behalf of a
locker should only be made from a single thread at a time. All Locker objects supplied to this class should be instances of TxnLocker.
This implementation checks for deadlock whenever a lock request is blocked due to a conflict. It selects as the deadlock victim the locker with the latest requested start time. The implementation does not deny requests that would not result in deadlock. When requests block, it services the requests in the order that they arrive.
This class and its superclass use the Logger named com.sun.sgs.impl.util.lock to log information at the
following logging levels:
FINER - Releasing locks; requesting, waiting for,
and returning from lock requests
FINEST - Notifying new lock owners, results of
requesting locks before waiting, releasing locks, results of attempting
to assign locks to waiters
| Field Summary |
|---|
| Fields inherited from class com.sun.sgs.impl.util.lock.LockManager |
|---|
currentKeySync, currentLockerSync, logger |
| Constructor Summary | |
|---|---|
TxnLockManager(long lockTimeout,
int numKeyMaps)
Creates an instance of this class. |
|
| Method Summary | |
|---|---|
LockConflict<K> |
lock(Locker<K> locker,
K key,
boolean forWrite)
Attempts to acquire a lock, waiting if needed. |
LockConflict<K> |
lockNoWait(Locker<K> locker,
K key,
boolean forWrite)
Attempts to acquire a lock, returning immediately. |
(package private) LockConflict<K> |
lockNoWaitInternal(Locker<K> locker,
K key,
boolean forWrite)
Attempts to acquire a lock, returning immediately. |
LockConflict<K> |
waitForLock(Locker<K> locker)
Waits for a previous attempt to obtain a lock that blocked. |
| Methods inherited from class com.sun.sgs.impl.util.lock.LockManager |
|---|
getKeyMap, getLock, getOwners, getWaiters, releaseLock, releaseLockInternal, waitForLockInternal |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TxnLockManager(long lockTimeout,
int numKeyMaps)
lockTimeout - the maximum number of milliseconds to acquire a
locknumKeyMaps - the number of separate maps to use for storing keys
IllegalArgumentException - if lockTimeout or numKeyMaps is less than 1| Method Detail |
|---|
public LockConflict<K> lock(Locker<K> locker,
K key,
boolean forWrite)
null if the lock
was acquired. If the type field of the return value is DEADLOCK, then the caller should abort the
transaction, and any subsequent lock or wait requests will throw IllegalStateException. Otherwise, the caller can repeat this call, and
any conflicts from earlier calls will be ignored.
lock in class LockManager<K>locker - the locker requesting the lockkey - the key identifying the lockforWrite - whether to request a write lock
null if there was no
conflict
IllegalArgumentException - if locker has a different lock
manager, or if locker is
not an instance of TxnLocker
public LockConflict<K> lockNoWait(Locker<K> locker,
K key,
boolean forWrite)
null if the lock was acquired. If the attempt to
acquire the lock was blocked, returns a value with a type field
of BLOCKED rather than waiting. If the
type field of the return value is DEADLOCK, then the caller should abort the
transaction, and any subsequent lock or wait requests will throw IllegalStateException. Otherwise, the caller can repeat this call, and
any conflicts from earlier calls will be ignored.
lockNoWait in class LockManager<K>locker - the locker requesting the lockkey - the key identifying the lockforWrite - whether to request a write lock
null if there was no
conflict
IllegalArgumentException - if locker has a different lock
manager, or if locker is
not an instance of TxnLockerpublic LockConflict<K> waitForLock(Locker<K> locker)
null if the lock was acquired or the
transaction was not waiting. If the type field of the return
value is DEADLOCK, then the caller
should abort the transaction, and any subsequent lock or wait requests
will throw IllegalStateException.
waitForLock in class LockManager<K>locker - the locker requesting the lock
null if there was no
conflict
IllegalArgumentException - if locker has a different lock
manager, or if locker is
not an instance of TxnLocker
LockConflict<K> lockNoWaitInternal(Locker<K> locker,
K key,
boolean forWrite)
LockManager.lockNoWait(com.sun.sgs.impl.util.lock.Locker, K, boolean) , but does not check that the correct lock manager was
supplied. This implementation calls the deadlock checker if the request blocks.
lockNoWaitInternal in class LockManager<K>locker - the locker requesting the lockkey - the key identifying the lockforWrite - whether to request a write lock
null if there was no
conflict
IllegalStateException - if an earlier lock attempt for this
transaction produced a deadlock, or if still waiting for an
earlier attempt to complete
|
RedDwarf, Version 0.10.1 2010-03-14 10:56:12 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||