public class SharedLocalYieldingClusterLockManager extends Object
The expected use case for this class is controlling access to resources that are typically only accessed on a single node (e.g. web sessions or stateful session beans), with the distributed lock used primarily to guarantee that.
Modifier and Type | Class and Description |
---|---|
static class |
SharedLocalYieldingClusterLockManager.LockResult
Result of a
lock call |
Constructor and Description |
---|
SharedLocalYieldingClusterLockManager(String serviceHAName,
GroupRpcDispatcher rpcDispatcher,
GroupMembershipNotifier membershipNotifier) |
Modifier and Type | Method and Description |
---|---|
SharedLocalYieldingClusterLockManager.LockResult |
lock(Serializable lockName,
long timeout)
Acquire the given lock.
|
SharedLocalYieldingClusterLockManager.LockResult |
lock(Serializable lockName,
long timeout,
boolean newLock)
Acquire the given lock.
|
void |
start()
Brings this object to a state where it is ready for normal operation.
|
void |
stop()
Removes this object from a state where it is ready for normal oepration and performs cleanup work.
|
void |
unlock(Serializable lockName,
boolean remove)
Releases a previously acquired lock.
|
public SharedLocalYieldingClusterLockManager(String serviceHAName, GroupRpcDispatcher rpcDispatcher, GroupMembershipNotifier membershipNotifier)
public SharedLocalYieldingClusterLockManager.LockResult lock(Serializable lockName, long timeout) throws TimeoutException, InterruptedException
lockName
- the identifier of the lock that should be acquiredtimeout
- max time in ms to wait before throwing a TimeoutException if the lock cannot be acquiredTimeoutException
- if the lock cannot be acquired before the timeoutInterruptedException
- if the thread is interrupted while trying to acquire the lockpublic SharedLocalYieldingClusterLockManager.LockResult lock(Serializable lockName, long timeout, boolean newLock) throws TimeoutException, InterruptedException
lockName
- the identifier of the lock that should be acquiredtimeout
- max time in ms to wait before throwing a TimeoutException if the lock cannot be acquirednewLock
- true
if this object should assume this is the first use cluster-wide of the lock identified
by lockName
, and just acquire the lock locally without any cluster-wide call. See discussion of
SharedLocalYieldingClusterLockManager.LockResult.NEW_LOCK
.TimeoutException
- if the lock cannot be acquired before the timeoutInterruptedException
- if the thread is interrupted while trying to acquire the lockpublic void unlock(Serializable lockName, boolean remove)
lockName
- unique name identifying the lock to releaseremove
- true
if this lock can be removed from tracking once all local locks are unlocked.public void start() throws Exception
Exception
Copyright © 2013 JBoss, a division of Red Hat, Inc.. All Rights Reserved.