|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.sasl.distributed.lock.impl.DefaultLockSession.LockSequence
protected class DefaultLockSession.LockSequence
Lock sequence which could have nested lock sequences.
Constructor Summary | |
---|---|
protected |
DefaultLockSession.LockSequence(String name)
Creates an empty lock sequence with the given name. |
Method Summary | |
---|---|
IMutex |
acquireMutex(Object key)
Acquires a mutex for the given lock key and returns it. |
protected void |
assertStrictMode()
Does a strict mode check for the operation. |
void |
clear()
Releases all locks that this lock container holds. |
boolean |
detach(IMutex mutex)
Detaches the mutex immediately from the sequence and releases the lock, if it was locked over the sequence. |
protected DefaultLockSession.MutexDecorator |
getDecoratorForLockKey(Object lockKey)
Returns the mutex decorator for a given lock key. |
protected DefaultLockSession.LockSequence |
getInnerSequence()
|
IMutex |
getMutex(Object lockKey)
Returns the corresponding mutex to the lockKey, null if there exists no such mutex for the lockKey at the sequence. |
String |
getName()
Returns a name of the lock container, for example "lock-transaction-X". |
protected DefaultLockSession.LockSequence |
getOuterSequence()
|
boolean |
isActive()
Returns true if this lock container is active which means it was not yet released via ILockContainer.release() . |
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. |
void |
release()
Releases all resources associated with this lock container. |
protected void |
setInnerSequence(DefaultLockSession.LockSequence innerSequence)
Sets the child sequence of this sequence. |
protected void |
setOuterSequence(DefaultLockSession.LockSequence outerSequence)
Sets the parent sequence of this sequence. |
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 class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected DefaultLockSession.LockSequence(String name)
name
- null or non nullMethod Detail |
---|
protected DefaultLockSession.LockSequence getInnerSequence()
#setInnerSequence(LockSequence)
protected DefaultLockSession.LockSequence getOuterSequence()
#setOuterSequence(LockSequence)
protected void setOuterSequence(DefaultLockSession.LockSequence outerSequence)
outerSequence
- null or non nullprotected void setInnerSequence(DefaultLockSession.LockSequence innerSequence)
innerSequence
- null or non nullpublic void clear() throws LockOperationException
ILockContainer
ILockContainer.release()
.
The container stays active after the operation.
clear
in interface ILockContainer
LockOperationException
- if an exception occurs during releasing locks and nested
containers.ILockContainer.clear()
protected DefaultLockSession.MutexDecorator getDecoratorForLockKey(Object lockKey)
lockKey
- null or non null.
public IMutex acquireMutex(Object key) throws LockOperationException
ILockSequence
acquireMutex
in interface ILockSequence
key
- non null
LockOperationException
- if any exception occurs during trying to acquire a mutex for
the lock key.net.sf.sasl.distributed.lock.ILockContainer#getLock(java.lang.Object)
public boolean detach(IMutex mutex) throws LockOperationException
ILockSequence
detach
in interface ILockSequence
mutex
- non null
LockOperationException
- if the operation is not allowed.ILockSequence.detach(net.sf.sasl.distributed.lock.IMutex)
public IMutex getMutex(Object lockKey) throws LockOperationException
ILockSequence
getMutex
in interface ILockSequence
lockKey
- non null
LockOperationException
- if the operation is not allowed.ILockSequence.getMutex(java.lang.Object)
public IMutex lock(Object lockKey) throws LockOperationException, DeadlockException
ILockSequence
lock
in interface ILockSequence
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.ILockSequence.lock(java.lang.Object)
public IMutex lockInterruptibly(Object lockKey) throws LockOperationException, DeadlockException, InterruptedException
ILockSequence
lockInterruptibly
in interface ILockSequence
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.ILockSequence.lockInterruptibly(Object)
public IMutex tryLock(Object lockKey) throws LockOperationException, DeadlockException
ILockSequence
tryLock
in interface ILockSequence
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.ILockSequence.tryLock(java.lang.Object)
public IMutex tryLock(Object lockKey, long maxWaitTime, TimeUnit timeUnit) throws LockOperationException, DeadlockException, InterruptedException
ILockSequence
tryLock
in interface ILockSequence
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
ILockSequence.tryLock(java.lang.Object,
long, java.util.concurrent.TimeUnit)
public IMutex unlock(Object lockKey) throws LockOperationException
ILockSequence
unlock
in interface ILockSequence
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.ILockSequence.unlock(java.lang.Object)
public String getName()
ILockContainer
getName
in interface ILockContainer
ILockContainer.getName()
public void release() throws LockOperationException
ILockContainer
release
in interface ILockContainer
LockOperationException
ILockContainer.release()
public boolean isActive()
ILockContainer
ILockContainer.release()
. False else. An inactive lock container
should be disconnected from all types of lock operations.
isActive
in interface ILockContainer
ILockContainer.isActive()
protected void assertStrictMode() throws LockOperationException
LockOperationException
- if strict mode is enabled and violated.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |