public class PEER_LOCK extends Locking
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.Locking
,
CENTRAL_LOCK
Modifier and Type | Class and Description |
---|---|
protected class |
PEER_LOCK.PeerLock
Lock implementation which grants a lock when all non faulty cluster members OK it.
|
Locking.ClientCondition, Locking.ClientLock, Locking.LockingHeader, Locking.Request, Locking.ServerCondition, Locking.ServerLock, Locking.Type
bypass_bundling, client_locks, local_addr, lock_listeners, server_locks, view
Constructor and Description |
---|
PEER_LOCK() |
Modifier and Type | Method and Description |
---|---|
protected Locking.ClientLock |
createLock(String lock_name) |
void |
handleView(View view) |
protected void |
sendAwaitConditionRequest(String lock_name,
Owner owner) |
protected void |
sendDeleteAwaitConditionRequest(String lock_name,
Owner owner) |
protected void |
sendGrantLockRequest(String lock_name,
Owner owner,
long timeout,
boolean is_trylock) |
protected void |
sendReleaseLockRequest(String lock_name,
Owner owner) |
protected void |
sendSignalConditionRequest(String lock_name,
boolean all) |
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, up
destroy, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getId, getLevel, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getValue, init, isErgonomics, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, start, statsEnabled, stop
protected void sendGrantLockRequest(String lock_name, Owner owner, long timeout, boolean is_trylock)
sendGrantLockRequest
in class Locking
protected void sendReleaseLockRequest(String lock_name, Owner owner)
sendReleaseLockRequest
in class Locking
protected void sendAwaitConditionRequest(String lock_name, Owner owner)
sendAwaitConditionRequest
in class Locking
protected void sendSignalConditionRequest(String lock_name, boolean all)
sendSignalConditionRequest
in class Locking
protected void sendDeleteAwaitConditionRequest(String lock_name, Owner owner)
sendDeleteAwaitConditionRequest
in class Locking
public void handleView(View view)
handleView
in class Locking
protected Locking.ClientLock createLock(String lock_name)
createLock
in class Locking
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.