net.sf.sasl.distributed.lock
Interface ILockSession

All Superinterfaces:
ILockContainer
All Known Implementing Classes:
DefaultLockSession

public interface ILockSession
extends ILockContainer

A lock session is the super container of lock sequences. If the session gets released, the session makes sure that all connected lock sequences gets released.
The burden to control the lock sequence behavior lies currently by the session. Sequences could be used to separate between regional and local lock areas (if the session supports such). For example:
//regional lock, locks needed by all following code parts
ILockSequence regionalLockSq = lockSession.beginLockSequence("regionalSequence");
// do regional locks
...code

// some local code
ILockSequence localLockSq = lockSession.beginLockSequence("localSequence");
//do local locks
...code
localLockSq.release(); //locks of the regional lock sq stay active
...

Since:
0.0.1 (sasl-distributed-lock-library)
Author:
Philipp Förmer

Method Summary
 ILockSequence beginLockSequence(String name)
          Starts a new lock sequence, which is owned by the session.
 ILockSequence getCurrentLockSequence()
          Returns the current active lock sequence of the session.
 LockSessionFactory getLockSessionFactory()
          Returns the lock session factory over which the session was created.
 boolean isInvalid()
          Returns true if the session is invalid, possibly because of an irreparable occured error like a DeadLockException.
 boolean isLocalLockHeldByASequence(Object lockKey)
          Returns true, if for the given lockKey a local lock is held by one lock sequence.
 boolean isLockKeyOwnedByASequence(Object lockKey)
          Returns true, if for the given lockKey a mutex is acquired by a lock sequence.
 boolean supportsNestedLockSequences()
          Returns true, if the session supports nested sequences, false else.
 
Methods inherited from interface net.sf.sasl.distributed.lock.ILockContainer
clear, getName, isActive, release
 

Method Detail

beginLockSequence

ILockSequence beginLockSequence(String name)
                                throws LockOperationException
Starts a new lock sequence, which is owned by the session. The sequence could be used to acquire new locks.

Parameters:
name - null or non null
Returns:
non null
Throws:
LockOperationException - in any exception case.
Since:
0.0.1 (sasl-distributed-lock-library)

getCurrentLockSequence

ILockSequence getCurrentLockSequence()
                                     throws LockOperationException
Returns the current active lock sequence of the session. If no sequence was started, than null will be returned.

Returns:
null or non null
Throws:
LockOperationException - in any exception case.
Since:
0.0.1 (sasl-distributed-lock-library)

supportsNestedLockSequences

boolean supportsNestedLockSequences()
Returns true, if the session supports nested sequences, false else.

Returns:
true or false
Since:
0.0.1 (sasl-distributed-lock-library)

isLockKeyOwnedByASequence

boolean isLockKeyOwnedByASequence(Object lockKey)
Returns true, if for the given lockKey a mutex is acquired by a lock sequence. A value of true does not mean that the mutex is also locked by the session.

Parameters:
lockKey - non null
Returns:
true or false.
Since:
0.0.1 (sasl-distributed-lock-library)

isLocalLockHeldByASequence

boolean isLocalLockHeldByASequence(Object lockKey)
Returns true, if for the given lockKey a local lock is held by one lock sequence. False, if the lockKey is not owned by a lock sequence or no sequence has acquired yet a lock for the given lock key. If there exists no actor in the system who unlocks locks he had never locked, a local lock implies a global lock.

Parameters:
lockKey - non null.
Returns:
true or false.
Since:
0.0.1 (sasl-distributed-lock-library)

isInvalid

boolean isInvalid()
Returns true if the session is invalid, possibly because of an irreparable occured error like a DeadLockException. An invalid session can only be made valid again, by clearing it.

Returns:
true or false.
Since:
0.0.1 (sasl-distributed-lock-library)

getLockSessionFactory

LockSessionFactory getLockSessionFactory()
Returns the lock session factory over which the session was created.

Returns:
non null
Since:
0.0.1 (sasl-distributed-lock-library)


Copyright © 2010. All Rights Reserved.