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>
backups
protected Address
coord
protected boolean
is_coord
protected int
num_backups
protected boolean
use_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 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()
protected Owner
getOwner()
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)
void
lockRevoked(java.lang.String lock_name, Owner current_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, int lock_id, Owner owner, long timeout, boolean is_trylock)
protected void
sendReleaseLockRequest(java.lang.String lock_name, int lock_id, 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
_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:
sendGrantLockRequest
in classLocking
-
sendReleaseLockRequest
protected void sendReleaseLockRequest(java.lang.String lock_name, int lock_id, Owner owner)
- Specified by:
sendReleaseLockRequest
in 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:
sendAwaitConditionRequest
in classLocking
-
sendSignalConditionRequest
protected void sendSignalConditionRequest(java.lang.String lock_name, boolean all)
- Specified by:
sendSignalConditionRequest
in classLocking
-
sendDeleteAwaitConditionRequest
protected void sendDeleteAwaitConditionRequest(java.lang.String lock_name, Owner owner)
- Specified by:
sendDeleteAwaitConditionRequest
in classLocking
-
handleView
public void handleView(View view)
- Overrides:
handleView
in classLocking
-
lockCreated
public void lockCreated(java.lang.String name)
- Specified by:
lockCreated
in interfaceLockNotification
-
lockDeleted
public void lockDeleted(java.lang.String name)
- Specified by:
lockDeleted
in interfaceLockNotification
-
locked
public void locked(java.lang.String lock_name, Owner owner)
- Specified by:
locked
in interfaceLockNotification
-
unlocked
public void unlocked(java.lang.String lock_name, Owner owner)
- Specified by:
unlocked
in interfaceLockNotification
-
lockRevoked
public void lockRevoked(java.lang.String lock_name, Owner current_owner)
- Specified by:
lockRevoked
in interfaceLockNotification
-
awaiting
public void awaiting(java.lang.String lock_name, Owner owner)
- Specified by:
awaiting
in interfaceLockNotification
-
awaited
public void awaited(java.lang.String lock_name, Owner owner)
- Specified by:
awaited
in 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)
-
-