public class LocalAndClusterLockManager extends Object
Users should not attempt to acquire the cluster-wide lock while holding a local lock or vice versa; failure to respect this requirement may lead to deadlocks.
Constructor and Description |
---|
LocalAndClusterLockManager(String serviceHAName,
GroupRpcDispatcher rpcDispatcher,
GroupMembershipNotifier membershipNotifier) |
Modifier and Type | Method and Description |
---|---|
void |
lockGlobally(Serializable lockName,
long timeout)
Acquires a globally exclusive cluster-wide lock, blocking if another thread is holding it locally, another node is
holding it, or if the local lock is held on any node in the cluster.
|
void |
lockLocally(Serializable lockName,
long timeout)
Acquires a local lock, blocking if another thread is holding it or if the global, cluster-wide lock is held.
|
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 operation and performs cleanup work.
|
void |
unlockGlobally(Serializable lockName)
Releases a previously acquired local lock.
|
void |
unlockLocally(Serializable lockName)
Releases a previously acquired local lock.
|
public LocalAndClusterLockManager(String serviceHAName, GroupRpcDispatcher rpcDispatcher, GroupMembershipNotifier membershipNotifier)
public void lockLocally(Serializable lockName, long timeout) throws TimeoutException, InterruptedException
lockName
- unique name identifying the lock to acquiretimeout
- max number of ms to wait to acquire the lock before failing with a TimeoutExceptionTimeoutException
- if the lock cannot be acquired before timeout
ms have elapsedInterruptedException
- if the thread is interruptedpublic void unlockLocally(Serializable lockName)
lockName
- unique name identifying the lock to releasepublic void lockGlobally(Serializable lockName, long timeout) throws TimeoutException, InterruptedException
lockName
- unique name identifying the lock to acquiretimeout
- max number of ms to wait to acquire the lock before failing with a TimeoutExceptionTimeoutException
- if the lock cannot be acquired before timeout
ms have elapsedInterruptedException
- if the thread is interruptedpublic void unlockGlobally(Serializable lockName)
lockName
- unique name identifying the lock to releasepublic void start() throws Exception
Exception
Copyright © 2013 JBoss, a division of Red Hat, Inc.. All rights reserved.