Package 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
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 thePEER_LOCK protocol.- Since:
- 2.12
- Author:
- Bela Ban
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jgroups.protocols.Locking
Locking.ClientCondition, Locking.ClientLock, Locking.LockingHeader, Locking.Request, Locking.ServerCondition, Locking.ServerLock, Locking.Type -
Field Summary
FieldsFields inherited from class org.jgroups.protocols.Locking
bypass_bundling, client_locks, local_addr, lock_listeners, server_locks, view -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidprotected voidcopyLocksTo(List<Address> new_joiners) getCoord()intvoidhandleView(View view) booleanisCoord()voidlockCreated(String name) voidlockDeleted(String name) voidprotected voidsendAwaitConditionRequest(String lock_name, Owner owner) protected voidsendCreateLockRequest(Address dest, String lock_name, Owner owner) protected voidsendDeleteAwaitConditionRequest(String lock_name, Owner owner) protected voidsendDeleteLockRequest(Address dest, String lock_name) protected voidsendGrantLockRequest(String lock_name, Owner owner, long timeout, boolean is_trylock) protected voidsendReleaseLockRequest(String lock_name, Owner owner) protected voidsendSignalConditionRequest(String lock_name, boolean all) voidsetNumberOfBackups(int num_backups) voidprotected voidupdateBackups(Locking.Type type, 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, upMethods inherited from class org.jgroups.stack.Protocol
destroy, downThreadEnabled, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getId, getLevel, getName, getProperties, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getValue, init, isErgonomics, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProperties, setPropertiesInternal, setProperty, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, start, statsEnabled, stop, upThreadEnabled
-
Field Details
-
num_backups
protected int num_backups -
coord
-
is_coord
protected boolean is_coord -
backups
-
-
Constructor Details
-
CENTRAL_LOCK
public CENTRAL_LOCK()
-
-
Method Details
-
getCoord
-
isCoord
public boolean isCoord() -
getCoordinator
-
getNumberOfBackups
public int getNumberOfBackups() -
setNumberOfBackups
public void setNumberOfBackups(int num_backups) -
getBackups
-
sendGrantLockRequest
protected void sendGrantLockRequest(String lock_name, Owner owner, long timeout, boolean is_trylock) - Specified by:
sendGrantLockRequestin classLocking
-
sendReleaseLockRequest
- Specified by:
sendReleaseLockRequestin classLocking
-
sendCreateLockRequest
-
sendDeleteLockRequest
-
sendAwaitConditionRequest
- Specified by:
sendAwaitConditionRequestin classLocking
-
sendSignalConditionRequest
- Specified by:
sendSignalConditionRequestin classLocking
-
sendDeleteAwaitConditionRequest
- Specified by:
sendDeleteAwaitConditionRequestin classLocking
-
handleView
- Overrides:
handleViewin classLocking
-
lockCreated
- Specified by:
lockCreatedin interfaceLockNotification
-
lockDeleted
- Specified by:
lockDeletedin interfaceLockNotification
-
locked
- Specified by:
lockedin interfaceLockNotification
-
unlocked
- Specified by:
unlockedin interfaceLockNotification
-
awaiting
- Specified by:
awaitingin interfaceLockNotification
-
awaited
- Specified by:
awaitedin interfaceLockNotification
-
updateBackups
-
copyLocksTo
-