org.jgroups.protocols
Class CENTRAL_LOCK
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.Locking
org.jgroups.protocols.CENTRAL_LOCK
- All Implemented Interfaces:
- LockNotification
public class CENTRAL_LOCK
- extends Locking
- implements LockNotification
Implementation of a locking protocol which acquires locks by contacting the coordinator.
Because the
coordinator maintains all locks, no total order configuration is required.
CENTRAL_LOCK has all members send lock and unlock requests to a central coordinator. The coordinator has a queue for
incoming requests, and grants locks based on order of arrival. To prevent all acquired locks from being forgotten
when the coordinator crashes, setting num_backups lets the coordinator backup lock information to a number of
backup nodes. Valid values for num_backups are 0 (no backup) to N-1, e.g. in a cluster of 4, we can have only 3 backup
nodes.
Say we have a cluster of {A,B,C,D,E} and num_backups=1. A is the coordinator, and A updates all locks (and released
locks) in B as well. When A crashes, everybody falls over to B for sending lock and unlock requests.
B in turn copies all existing locks over to C and - when locks are acquired or released - forwards this
information to C as well.
An alternative is also the PEER_LOCK
protocol.
- Since:
- 2.12
- Author:
- Bela Ban
- See Also:
Locking
,
PEER_LOCK
Method Summary |
void |
awaited(java.lang.String lock_name,
Owner owner)
|
void |
awaiting(java.lang.String lock_name,
Owner owner)
|
protected void |
copyLocksTo(java.util.List<Address> new_joiners)
|
java.lang.String |
getBackups()
|
Address |
getCoord()
|
java.lang.String |
getCoordinator()
|
int |
getNumberOfBackups()
|
void |
handleView(View view)
|
boolean |
isCoord()
|
void |
lockCreated(java.lang.String name)
|
void |
lockDeleted(java.lang.String name)
|
void |
locked(java.lang.String lock_name,
Owner owner)
|
protected void |
sendAwaitConditionRequest(java.lang.String lock_name,
Owner owner)
|
protected void |
sendCreateLockRequest(Address dest,
java.lang.String lock_name,
Owner owner)
|
protected void |
sendDeleteAwaitConditionRequest(java.lang.String lock_name,
Owner owner)
|
protected void |
sendDeleteLockRequest(Address dest,
java.lang.String lock_name)
|
protected void |
sendGrantLockRequest(java.lang.String lock_name,
Owner owner,
long timeout,
boolean is_trylock)
|
protected void |
sendReleaseLockRequest(java.lang.String lock_name,
Owner owner)
|
protected void |
sendSignalConditionRequest(java.lang.String lock_name,
boolean all)
|
void |
setNumberOfBackups(int num_backups)
|
void |
unlocked(java.lang.String lock_name,
Owner owner)
|
protected void |
updateBackups(Locking.Type type,
java.lang.String lock_name,
Owner owner)
|
Methods inherited from class org.jgroups.protocols.Locking |
addLockListener, createLock, down, getAddress, getBypassBundling, getLock, getLock, getLock, getOwner, getView, handleAwaitRequest, handleCreateAwaitingRequest, handleCreateLockRequest, handleDeleteAwaitingRequest, handleDeleteAwaitRequest, handleDeleteLockRequest, handleLockDeniedResponse, handleLockGrantedResponse, handleLockRequest, handleSignalRequest, handleSignalResponse, notifyAwaited, notifyAwaiting, notifyLockCreated, notifyLockDeleted, notifyLocked, notifyUnlocked, printLocks, removeClientLock, removeLockListener, sendLockResponse, sendRequest, sendSignalResponse, setBypassBundling, unlockAll, up |
Methods inherited from class org.jgroups.stack.Protocol |
destroy, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, init, isErgonomics, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, start, statsEnabled, stop |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
num_backups
protected int num_backups
coord
protected Address coord
is_coord
protected boolean is_coord
backups
protected final java.util.List<Address> backups
CENTRAL_LOCK
public CENTRAL_LOCK()
getCoord
public Address getCoord()
isCoord
public boolean isCoord()
getCoordinator
public java.lang.String getCoordinator()
getNumberOfBackups
public int getNumberOfBackups()
setNumberOfBackups
public void setNumberOfBackups(int num_backups)
getBackups
public java.lang.String getBackups()
sendGrantLockRequest
protected void sendGrantLockRequest(java.lang.String lock_name,
Owner owner,
long timeout,
boolean is_trylock)
- Specified by:
sendGrantLockRequest
in class Locking
sendReleaseLockRequest
protected void sendReleaseLockRequest(java.lang.String lock_name,
Owner owner)
- Specified by:
sendReleaseLockRequest
in class Locking
sendCreateLockRequest
protected void sendCreateLockRequest(Address dest,
java.lang.String lock_name,
Owner owner)
sendDeleteLockRequest
protected void sendDeleteLockRequest(Address dest,
java.lang.String lock_name)
sendAwaitConditionRequest
protected void sendAwaitConditionRequest(java.lang.String lock_name,
Owner owner)
- Specified by:
sendAwaitConditionRequest
in class Locking
sendSignalConditionRequest
protected void sendSignalConditionRequest(java.lang.String lock_name,
boolean all)
- Specified by:
sendSignalConditionRequest
in class Locking
sendDeleteAwaitConditionRequest
protected void sendDeleteAwaitConditionRequest(java.lang.String lock_name,
Owner owner)
- Specified by:
sendDeleteAwaitConditionRequest
in class Locking
handleView
public void handleView(View view)
- Overrides:
handleView
in class Locking
lockCreated
public void lockCreated(java.lang.String name)
- Specified by:
lockCreated
in interface LockNotification
lockDeleted
public void lockDeleted(java.lang.String name)
- Specified by:
lockDeleted
in interface LockNotification
locked
public void locked(java.lang.String lock_name,
Owner owner)
- Specified by:
locked
in interface LockNotification
unlocked
public void unlocked(java.lang.String lock_name,
Owner owner)
- Specified by:
unlocked
in interface LockNotification
awaiting
public void awaiting(java.lang.String lock_name,
Owner owner)
- Specified by:
awaiting
in interface LockNotification
awaited
public void awaited(java.lang.String lock_name,
Owner owner)
- Specified by:
awaited
in interface LockNotification
updateBackups
protected void updateBackups(Locking.Type type,
java.lang.String lock_name,
Owner owner)
copyLocksTo
protected void copyLocksTo(java.util.List<Address> new_joiners)
Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.