Package org.jgroups.protocols
Class PEER_LOCK
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.Locking
org.jgroups.protocols.PEER_LOCK
Implementation of a locking protocol which acquires locks by contacting all of the nodes of a cluster.
Unless a total order configuration is used (e.g.
SEQUENCER based), lock requests for
the same resource from different senders may be received in different order, so deadlocks can occur. Example:
- Nodes A and B - A and B call lock(X) at the same time - A receives L(X,A) followed by L(X,B): locks X(A), queues L(X,B) - B receives L(X,B) followed by L(X,A): locks X(B), queues L(X,A)To acquire a lock, we need lock grants from both A and B, but this will never happen here. To fix this, either add SEQUENCER to the configuration, so that all lock requests are received in the same global order at both A and B, or use
Lock.tryLock(long,java.util.concurrent.TimeUnit) with retries if a lock
cannot be acquired.
An alternative is also the CENTRAL_LOCK protocol.- Since:
- 2.12
- Author:
- Bela Ban
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classLock implementation which grants a lock when all non faulty cluster members OK it.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
Fields 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 TypeMethodDescriptionprotected Locking.ClientLockcreateLock(String lock_name) voidhandleView(View view) protected voidsendAwaitConditionRequest(String lock_name, Owner owner) protected voidsendDeleteAwaitConditionRequest(String lock_name, Owner owner) 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) Methods inherited from class org.jgroups.protocols.Locking
addLockListener, 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
-
Constructor Details
-
PEER_LOCK
public PEER_LOCK()
-
-
Method Details
-
sendGrantLockRequest
protected void sendGrantLockRequest(String lock_name, Owner owner, long timeout, boolean is_trylock) - Specified by:
sendGrantLockRequestin classLocking
-
sendReleaseLockRequest
- Specified by:
sendReleaseLockRequestin classLocking
-
sendAwaitConditionRequest
- Specified by:
sendAwaitConditionRequestin classLocking
-
sendSignalConditionRequest
- Specified by:
sendSignalConditionRequestin classLocking
-
sendDeleteAwaitConditionRequest
- Specified by:
sendDeleteAwaitConditionRequestin classLocking
-
handleView
- Overrides:
handleViewin classLocking
-
createLock
- Overrides:
createLockin classLocking
-