|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ILockSequence
A lock sequence is a collection of acquired locks. A sequence makes sure that
all acquired locks get unlocked and released when the sequence is released.
How a sequence is working depends on the implementation of the sequence and
its super container - a lock session. If the sequence supports for example
the "two phase lock protocol" than it should forbid to acquire locks and lock
locks, if already one acquired lock was unlocked at the sequence.
Implementations must be not thread-safe. Parts of the contract may differ in
different lock sequence implementations, those changes should be documented.
A lock sequence should be used in a short running "transaction" way, if the
probability for simultaneous locks for the same lock key is high.
Method Summary | |
---|---|
IMutex |
acquireMutex(Object lockKey)
Acquires a mutex for the given lock key and returns it. |
boolean |
detach(IMutex mutex)
Detaches the mutex immediately from the sequence and releases the lock, if it was locked over the sequence. |
IMutex |
getMutex(Object lockKey)
Returns the corresponding mutex to the lockKey, null if there exists no such mutex for the lockKey at the sequence. |
IMutex |
lock(Object lockKey)
Acquires a mutex for the given lock key and locks it initial. |
IMutex |
lockInterruptibly(Object lockKey)
Tries to acquire a mutex and do trie to do a lock on it as long as the current thread is not interrupted. |
IMutex |
tryLock(Object lockKey)
Tries to acquire a mutex and do a tryLock on it. |
IMutex |
tryLock(Object lockKey,
long maxWaitTime,
TimeUnit timeUnit)
Tries to acquire a mutex and do a timed wait tryLock on it. |
IMutex |
unlock(Object lockKey)
Unlocks the mutex for the given lockKey, so that the mutex could be locked by another thread. |
Methods inherited from interface net.sf.sasl.distributed.lock.ILockContainer |
---|
clear, getName, isActive, release |
Method Detail |
---|
IMutex acquireMutex(Object lockKey) throws LockOperationException
lockKey
- non null
LockOperationException
- if any exception occurs during trying to acquire a mutex for
the lock key.IMutex getMutex(Object lockKey) throws LockOperationException
lockKey
- non null
LockOperationException
- if the operation is not allowed.boolean detach(IMutex mutex) throws LockOperationException
mutex
- non null
LockOperationException
- if the operation is not allowed.IMutex lock(Object lockKey) throws LockOperationException, DeadlockException
lockKey
- non null.
LockOperationException
- if the mutex could not get acquired, for example because its
held by another sequence (of the same session), or the
operation is not allowed.
DeadlockException
- if a deadlock scenario occurred.IMutex lockInterruptibly(Object lockKey) throws LockOperationException, DeadlockException, InterruptedException
lockKey
- non null
LockOperationException
- if the mutex could not get acquired, for example because its
held by another sequence (of the same session), or the
operation is not allowed.
DeadlockException
- if a deadlock scenario occurred.
InterruptedException
- if the current thread was interrupted.IMutex tryLock(Object lockKey) throws LockOperationException, DeadlockException
lockKey
- non null
LockOperationException
- if the mutex could not get acquired, for example because its
held by another sequence (of the same session), or the
operation is not allowed.
DeadlockException
- if a deadlock scenario occurred.IMutex tryLock(Object lockKey, long maxWaitTime, TimeUnit timeUnit) throws LockOperationException, DeadlockException, InterruptedException
lockKey
- non nullmaxWaitTime
- positive long value.timeUnit
- non null, describing of what time unit the maxWaitTime is.
LockOperationException
- if the mutex could not get acquired, for example because its
held by another sequence (of the same session).
DeadlockException
- if a deadlock scenario occurred.
InterruptedException
IMutex unlock(Object lockKey) throws LockOperationException
lockKey
- non null.
LockOperationException
- if the mutex could not get unlocked, for example because it
was never held by this sequence, or the operation is not
allowed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |