org.javagroups.blocks
Class DistributedLock

java.lang.Object
  extended byorg.javagroups.blocks.DistributedLock

public class DistributedLock
extends java.lang.Object

Building block implementing distributed locking: a caller needs to lock a resource on all group members. The call either succeeds (all members have acquired a lock on the given resource), or it fails. Locks have associated timeouts, so no lock will be held forever. The typical use case for which this class was designed is as follows:

  1. Caller acquires a lock on all members. A lock (Lock) object is returned.
  2. If successful, caller sends a message to all members containing the lock object. If the lock is still held, every member applies the message, otherwise an exception will be returned to the caller.
  3. Caller releases the locks

Version:
$Revision: 1.2 $
Author:
Bela Ban Aug 2002

Nested Class Summary
static class DistributedLock.Lock
           
 
Constructor Summary
DistributedLock(Channel ch, MessageListener l1, MembershipListener l2)
           
DistributedLock(PullPushAdapter ad, MessageListener l1, MembershipListener l2)
           
 
Method Summary
 void apply(Message msg, DistributedLock.Lock l)
           
 DistributedLock.Lock getLock(java.io.Serializable resource_name, long lease_timeout, long max_wait_time)
           
 void releaseLock(DistributedLock.Lock l)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DistributedLock

public DistributedLock(PullPushAdapter ad,
                       MessageListener l1,
                       MembershipListener l2)

DistributedLock

public DistributedLock(Channel ch,
                       MessageListener l1,
                       MembershipListener l2)
Method Detail

getLock

public DistributedLock.Lock getLock(java.io.Serializable resource_name,
                                    long lease_timeout,
                                    long max_wait_time)
                             throws org.javagroups.blocks.DistributedLock.LockDeniedException
Throws:
org.javagroups.blocks.DistributedLock.LockDeniedException

apply

public void apply(Message msg,
                  DistributedLock.Lock l)
           throws org.javagroups.blocks.DistributedLock.ResourceLockedException,
                  org.javagroups.blocks.DistributedLock.NoLockException
Throws:
org.javagroups.blocks.DistributedLock.ResourceLockedException
org.javagroups.blocks.DistributedLock.NoLockException

releaseLock

public void releaseLock(DistributedLock.Lock l)


Copyright © 2001,2002 www.javagroups.com . All Rights Reserved.