|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface GlobalLockingService
provide services for acquiring global locks and creating lock groups. Global Locks provide cluster-wide synchronization. . A lock is identified by its name. The name must be unique. . A lock is represented by a lock object. There can be only one valid (i.e. locked and unexpired) lock object for the lock throughout the cluster. . You can obtain a lock only if it is currently unlocked. . A lock is created if it does not exist. It is created in the locked state. . Each lock has a specific lifetime. If that lifetime is exceeded, the lock expires, and becomes unlocked. . A lock is acquired with the default lifetime (currently 2 minutes). The lifetime must be extended if the lock is to be held longer than that. . If a lock expires, a cleanup notification will be sent when the lock is next acquired. The notification is posted on a local topic to the default Notification Center. . All lock operations other than acquiring the lock are performed on the lock object. . All operations on an invalid (expired or released) lock object throw an exception. . No synchronization is done on any of these methods. If the user wishes to share a lock object between threads on a node, the user is responsible for proper synchronization. . An acquired lock can be added to a Lock Group. Once added, the lock can be later acquired through a request to the Lock Group. . When a node goes down, all locks acquired by that node become expired. However, the lock may not become available until the node restarts. This means that a lock that becomes available due to a node crashing will always have the cleanup notification sent when the lock is next acquired. . On Cluster Restart, Global Locking is initialized (i.e. there are no locks, and there are no lock groups). This is necessary, or else creating new Lock Groups with different numbers of locks becomes unnecessarily complicated.
Field Summary | |
---|---|
static java.lang.String |
CleanupTopic
|
Method Summary | |
---|---|
GlobalLock |
acquireLock(java.lang.String lockName)
Acquire requested GlobalLock. |
GlobalLock |
acquireLock(java.lang.String lockName,
long acquireTimeout)
Aacquire requested GlobalLock with an acquistion timeout. |
GlobalLock |
acquireLockFromGroup(java.lang.String groupName)
Acquire a lock from the requested lock group. |
GlobalLock |
acquireLockFromGroup(java.lang.String groupName,
long acquireTimeout)
Acquire a lock from the requested lock group. |
void |
createLockGroup(java.lang.String groupName,
int numLocks)
Create a new lock group, and allow numLocks locks to be assigned to it. |
void |
createLockPool(java.lang.String groupName,
int numLocks)
Create a new lockgroup, and a pool of locks for it. |
void |
deleteLockGroup(java.lang.String groupName)
Delete the specified lock group. |
boolean |
nodeHasLock(java.lang.String lockName,
java.lang.String nodeName)
Returns true if the specified lock is held by the specified node. |
Field Detail |
---|
static final java.lang.String CleanupTopic
Method Detail |
---|
GlobalLock acquireLock(java.lang.String lockName)
lockName
- The name of the lock. Must be unique
GlobalLock acquireLock(java.lang.String lockName, long acquireTimeout)
lockName
- The name of the lock. Must be uniqueacquireTimeout
- The number of milliseconds to try for
GlobalLock acquireLockFromGroup(java.lang.String groupName) throws GlobalLockingException
groupName
- The lock group
GlobalLockingException
- thrown if the lock group does
not exist, or if there are no locks assigned to the group.GlobalLock acquireLockFromGroup(java.lang.String groupName, long acquireTimeout) throws GlobalLockingException
groupName
- The lock groupacquireTimeout
- The number of milliseconds to try to obtain
the lock
GlobalLockingException
- thrown if the lock group does
not exist, or if there are no locks assigned to the group.void createLockGroup(java.lang.String groupName, int numLocks) throws GlobalLockingException
groupName
- The name of the groupnumLocks
- How many locks can be in this group
GlobalLockingException
- if the group already existsvoid createLockPool(java.lang.String groupName, int numLocks) throws GlobalLockingException
groupName
- The name of the group to createnumLocks
- How many locks to create
GlobalLockingException
- if the group already exists, or
if any of the locks associated with the group already exits and are
assigned to the group.void deleteLockGroup(java.lang.String groupName) throws GlobalLockingException
groupName
- The name of the group to delete
GlobalLockingException
- if the group does not exist,
or if any of the locks within the group are locked or expired.boolean nodeHasLock(java.lang.String lockName, java.lang.String nodeName)
lockName
- The name of the locknodeName
- The name of the node
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |