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| 限定符和类型 | 类和说明 |
|---|---|
protected class |
PEER_LOCK.PeerLock
Lock implementation which grants a lock when all non faulty cluster members OK it.
|
Locking.ClientCondition, Locking.ClientLock, Locking.ClientLockTable, Locking.LockingHeader, Locking.Request, Locking.Response, Locking.ServerCondition, Locking.ServerLock, Locking.Typebypass_bundling, client_lock_table, current_lock_id, local_addr, lock_listeners, lock_stripes, lock_striping_size, server_locks, view| 构造器和说明 |
|---|
PEER_LOCK() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected Locking.ClientLock |
createLock(java.lang.String lock_name) |
void |
handleView(View view) |
protected void |
sendAwaitConditionRequest(java.lang.String lock_name,
Owner owner) |
protected void |
sendDeleteAwaitConditionRequest(java.lang.String lock_name,
Owner owner) |
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,
Owner owner) |
protected void |
sendSignalConditionRequest(java.lang.String lock_name,
boolean all) |
_getLock, addLockListener, createLock, down, getAddress, getBypassBundling, getLock, getLock, getOwner, getView, handleAwaitRequest, handleCreateAwaitingRequest, handleCreateLockRequest, handleDeleteAwaitingRequest, handleDeleteAwaitRequest, handleDeleteLockRequest, handleLockDeniedResponse, handleLockGrantedResponse, handleLockRequest, handleSignalRequest, handleSignalResponse, init, notifyAwaited, notifyAwaiting, notifyLockCreated, notifyLockDeleted, notifyLocked, notifyUnlocked, printLocks, removeLockListener, send, sendLockResponse, sendRequest, sendRequest, sendSignalResponse, setBypassBundling, unlockAll, upaccept, destroy, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, start, statsEnabled, stop, upprotected void sendGrantLockRequest(java.lang.String lock_name,
int lock_id,
Owner owner,
long timeout,
boolean is_trylock)
sendGrantLockRequest 在类中 Lockingprotected void sendReleaseLockRequest(java.lang.String lock_name,
Owner owner)
sendReleaseLockRequest 在类中 Lockingprotected void sendAwaitConditionRequest(java.lang.String lock_name,
Owner owner)
sendAwaitConditionRequest 在类中 Lockingprotected void sendSignalConditionRequest(java.lang.String lock_name,
boolean all)
sendSignalConditionRequest 在类中 Lockingprotected void sendDeleteAwaitConditionRequest(java.lang.String lock_name,
Owner owner)
sendDeleteAwaitConditionRequest 在类中 Lockingpublic void handleView(View view)
handleView 在类中 Lockingprotected Locking.ClientLock createLock(java.lang.String lock_name)