org.jgroups.blocks

Class DistributedLockManager

public class DistributedLockManager extends Object implements TwoPhaseVotingListener, LockManager, VoteResponseProcessor

Distributed lock manager is responsible for maintaining the lock information consistent on all participating nodes.

Version: $Id: DistributedLockManager.java,v 1.6 2005/06/08 15:56:54 publicnmi Exp $

Author: Roman Rokytskyy (rrokytskyy@acm.org) Robert Schaffar-Taurok (robert@fusion.at)

Nested Class Summary
static classDistributedLockManager.AcquireLockDecree
This class represents the lock to be released.
static classDistributedLockManager.LockDecree
This class represents the lock
static classDistributedLockManager.MultiLockDecree
This class represents the lock that has to be marked as multilocked
static classDistributedLockManager.ReleaseLockDecree
This class represents the lock to be released.
Field Summary
protected Loglog
Constructor Summary
DistributedLockManager(VotingAdapter voteChannel, Object id)
Create instance of this class.
DistributedLockManager(TwoPhaseVotingAdapter channel, Object id)
Constructor for the DistributedLockManager_cl object.
Method Summary
voidabort(Object decree)
Abort phase for the lock acquisition or release.
booleancommit(Object decree)
Commit phase for the lock acquisition or release.
voidlock(Object lockId, Object owner, int timeout)
Locks an object with lockId on behalf of the specified owner.
booleanprepare(Object decree)
Prepare phase for the lock acquisition or release.
booleanprocessResponses(RspList responses, int consensusType, Object decree)
Processes the response list and votes like the default processResponses method with the consensusType VOTE_ALL If the result of the voting is false, but this DistributedLockManager owns the lock, the result is changed to true and the lock is released, but marked as multiple locked. (only in the prepare state to reduce traffic)

Note: we do not support voting in case of Byzantine failures, i.e. when the node responds with the fault message.

voidunlock(Object lockId, Object owner)
Unlocks an object with lockId on behalf of the specified owner. since 2.2.9 this method is only a wrapper for unlock(Object lockId, Object owner, boolean releaseMultiLocked).
voidunlock(Object lockId, Object owner, boolean releaseMultiLocked)
Unlocks an object with lockId on behalf of the specified owner.

Field Detail

log

protected final Log log

Constructor Detail

DistributedLockManager

public DistributedLockManager(VotingAdapter voteChannel, Object id)
Create instance of this class.

Parameters: voteChannel instance of VotingAdapter that will be used for voting purposes on the lock decrees. voteChannel() will be wrapped by the instance of the TwoPhaseVotingAdapter. id the unique identifier of this lock manager.

UNKNOWN: check if the node with the same id is already in the group.

DistributedLockManager

public DistributedLockManager(TwoPhaseVotingAdapter channel, Object id)
Constructor for the DistributedLockManager_cl object.

Parameters: channel instance of TwoPhaseVotingAdapter that will be used for voting purposes on the lock decrees. id the unique identifier of this lock manager.

UNKNOWN: check if the node with the same id is already in the group.

Method Detail

abort

public void abort(Object decree)
Abort phase for the lock acquisition or release.

Parameters: decree should be an instance LockDecree, if not, we throw VoteException to be ignored by the VoteChannel.

Throws: VoteException if we should be ignored during voting.

commit

public boolean commit(Object decree)
Commit phase for the lock acquisition or release.

Parameters: decree should be an instance LockDecree, if not, we throw VoteException to be ignored by the VoteChannel.

Returns: true when commiting the lock operation succeeds.

Throws: VoteException if we should be ignored during voting.

lock

public void lock(Object lockId, Object owner, int timeout)
Locks an object with lockId on behalf of the specified owner.

Parameters: lockId Object representing the object to be locked. owner object that requests the lock. timeout time during which group members should decide whether to grant a lock or not.

Throws: LockNotGrantedException when the lock cannot be granted. ClassCastException if lockId or owner are not serializable. ChannelException if something bad happened to underlying channel.

prepare

public boolean prepare(Object decree)
Prepare phase for the lock acquisition or release.

Parameters: decree should be an instance LockDecree, if not, we throw VoteException to be ignored by the VoteChannel.

Returns: true when preparing the lock operation succeeds.

Throws: VoteException if we should be ignored during voting.

processResponses

public boolean processResponses(RspList responses, int consensusType, Object decree)
Processes the response list and votes like the default processResponses method with the consensusType VOTE_ALL If the result of the voting is false, but this DistributedLockManager owns the lock, the result is changed to true and the lock is released, but marked as multiple locked. (only in the prepare state to reduce traffic)

Note: we do not support voting in case of Byzantine failures, i.e. when the node responds with the fault message.

unlock

public void unlock(Object lockId, Object owner)
Unlocks an object with lockId on behalf of the specified owner. since 2.2.9 this method is only a wrapper for unlock(Object lockId, Object owner, boolean releaseMultiLocked). Use that with releaseMultiLocked set to true if you want to be able to release multiple locked locks (for example after a merge)

Parameters: lockId long representing the object to be unlocked. owner object that releases the lock.

Throws: LockNotReleasedException when the lock cannot be released. ClassCastException if lockId or owner are not serializable.

unlock

public void unlock(Object lockId, Object owner, boolean releaseMultiLocked)
Unlocks an object with lockId on behalf of the specified owner.

Parameters: lockId long representing the object to be unlocked. owner object that releases the lock. releaseMultiLocked releases also multiple locked locks. (eg. locks that are locked by another DLM after a merge)

Throws: LockNotReleasedException when the lock cannot be released. ClassCastException if lockId or owner are not serializable. LockMultiLockedException if releaseMultiLocked is true and a multiple locked lock has been released.

Copyright ? 1998-2005 Bela Ban. All Rights Reserved.