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
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.- Since:
- 2.12
- Author:
- Bela Ban
- See Also:
Locking
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jgroups.protocols.Locking
Locking.ClientCondition, Locking.ClientLock, Locking.ClientLockTable, Locking.LockInfoResponse, Locking.LockingHeader, Locking.Request, Locking.Response, Locking.ServerCondition, Locking.ServerLock, Locking.Type
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<Address>backupsprotected Addresscoordprotected booleanis_coordprotected intnum_backupsprotected booleanuse_thread_id_for_lock_owner-
Fields inherited from class org.jgroups.protocols.Locking
bypass_bundling, client_lock_table, current_lock_id, local_addr, lock_listeners, lock_stripes, lock_striping_size, server_locks, view
-
Fields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, log, stack, stats, up_prot
-
-
Constructor Summary
Constructors Constructor Description CENTRAL_LOCK()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidawaited(java.lang.String lock_name, Owner owner)voidawaiting(java.lang.String lock_name, Owner owner)protected voidcopyLocksTo(java.util.List<Address> new_joiners)java.lang.StringgetBackups()AddressgetCoord()java.lang.StringgetCoordinator()intgetNumberOfBackups()protected OwnergetOwner()voidhandleView(View view)booleanisCoord()voidlockCreated(java.lang.String name)voidlockDeleted(java.lang.String name)voidlocked(java.lang.String lock_name, Owner owner)voidlockRevoked(java.lang.String lock_name, Owner current_owner)protected voidsendAwaitConditionRequest(java.lang.String lock_name, Owner owner)protected voidsendCreateLockRequest(Address dest, java.lang.String lock_name, Owner owner)protected voidsendDeleteAwaitConditionRequest(java.lang.String lock_name, Owner owner)protected voidsendDeleteLockRequest(Address dest, java.lang.String lock_name)protected voidsendGrantLockRequest(java.lang.String lock_name, int lock_id, Owner owner, long timeout, boolean is_trylock)protected voidsendReleaseLockRequest(java.lang.String lock_name, int lock_id, Owner owner)protected voidsendSignalConditionRequest(java.lang.String lock_name, boolean all)voidsetNumberOfBackups(int num_backups)voidunlocked(java.lang.String lock_name, Owner owner)protected voidupdateBackups(Locking.Type type, java.lang.String lock_name, Owner owner)-
Methods inherited from class org.jgroups.protocols.Locking
_getLock, addLockListener, createLock, down, getAddress, getBypassBundling, getLock, getLock, getNumClientLocks, getNumServerLocks, getView, handleAwaitRequest, handleCreateAwaitingRequest, handleCreateLockRequest, handleDeleteAwaitingRequest, handleDeleteAwaitRequest, handleDeleteLockRequest, handleLockDeniedResponse, handleLockGrantedResponse, handleLockInfoRequest, handleLockInfoResponse, handleLockReleasedResponse, handleLockRequest, handleLockRevoked, handleRequest, handleSignalRequest, handleSignalResponse, init, notifyAwaited, notifyAwaiting, notifyLockCreated, notifyLockDeleted, notifyLocked, notifyLockRevoked, notifyUnlocked, printLocks, printServerLocks, removeLockListener, requestReceived, send, sendLockResponse, sendRequest, sendRequest, sendSignalResponse, setBypassBundling, unlockAll, unlockForce, up, up
-
Methods inherited from class org.jgroups.stack.Protocol
accept, afterCreationHook, destroy, down, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, start, statsEnabled, stop, up
-
-
-
-
Method Detail
-
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, int lock_id, Owner owner, long timeout, boolean is_trylock)- Specified by:
sendGrantLockRequestin classLocking
-
sendReleaseLockRequest
protected void sendReleaseLockRequest(java.lang.String lock_name, int lock_id, Owner owner)- Specified by:
sendReleaseLockRequestin classLocking
-
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:
sendAwaitConditionRequestin classLocking
-
sendSignalConditionRequest
protected void sendSignalConditionRequest(java.lang.String lock_name, boolean all)- Specified by:
sendSignalConditionRequestin classLocking
-
sendDeleteAwaitConditionRequest
protected void sendDeleteAwaitConditionRequest(java.lang.String lock_name, Owner owner)- Specified by:
sendDeleteAwaitConditionRequestin classLocking
-
handleView
public void handleView(View view)
- Overrides:
handleViewin classLocking
-
lockCreated
public void lockCreated(java.lang.String name)
- Specified by:
lockCreatedin interfaceLockNotification
-
lockDeleted
public void lockDeleted(java.lang.String name)
- Specified by:
lockDeletedin interfaceLockNotification
-
locked
public void locked(java.lang.String lock_name, Owner owner)- Specified by:
lockedin interfaceLockNotification
-
unlocked
public void unlocked(java.lang.String lock_name, Owner owner)- Specified by:
unlockedin interfaceLockNotification
-
lockRevoked
public void lockRevoked(java.lang.String lock_name, Owner current_owner)- Specified by:
lockRevokedin interfaceLockNotification
-
awaiting
public void awaiting(java.lang.String lock_name, Owner owner)- Specified by:
awaitingin interfaceLockNotification
-
awaited
public void awaited(java.lang.String lock_name, Owner owner)- Specified by:
awaitedin interfaceLockNotification
-
updateBackups
protected void updateBackups(Locking.Type type, java.lang.String lock_name, Owner owner)
-
copyLocksTo
protected void copyLocksTo(java.util.List<Address> new_joiners)
-
-