public class CENTRAL_LOCK extends Locking implements LockNotification
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. An alternative is also thePEER_LOCK
protocol.Locking.ClientCondition, Locking.ClientLock, Locking.ClientLockTable, Locking.LockingHeader, Locking.Request, Locking.Response, Locking.ServerCondition, Locking.ServerLock, Locking.Type
Modifier and Type | Field and 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 |
bypass_bundling, client_lock_table, current_lock_id, local_addr, lock_listeners, lock_stripes, lock_striping_size, server_locks, view
after_creation_hook, down_prot, ergonomics, id, log, name, stack, stats, up_prot
Constructor and Description |
---|
CENTRAL_LOCK() |
Modifier and Type | Method and 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) |
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) |
_getLock, addLockListener, createLock, down, getAddress, getBypassBundling, getLock, getLock, getView, handleAwaitRequest, handleCreateAwaitingRequest, handleCreateLockRequest, handleDeleteAwaitingRequest, handleDeleteAwaitRequest, handleDeleteLockRequest, handleLockDeniedResponse, handleLockGrantedResponse, handleLockReleasedResponse, handleLockRequest, handleSignalRequest, handleSignalResponse, init, notifyAwaited, notifyAwaiting, notifyLockCreated, notifyLockDeleted, notifyLocked, notifyUnlocked, printLocks, printServerLocks, removeLockListener, send, sendLockResponse, sendRequest, sendRequest, sendSignalResponse, setBypassBundling, unlockAll, up
accept, afterCreationHook, destroy, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, 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, up
protected int num_backups
protected boolean use_thread_id_for_lock_owner
protected Address coord
protected boolean is_coord
protected final java.util.List<Address> backups
public Address getCoord()
public boolean isCoord()
public java.lang.String getCoordinator()
public int getNumberOfBackups()
public void setNumberOfBackups(int num_backups)
public java.lang.String getBackups()
protected void sendGrantLockRequest(java.lang.String lock_name, int lock_id, Owner owner, long timeout, boolean is_trylock)
sendGrantLockRequest
in class Locking
protected void sendReleaseLockRequest(java.lang.String lock_name, int lock_id, Owner owner)
sendReleaseLockRequest
in class Locking
protected void sendCreateLockRequest(Address dest, java.lang.String lock_name, Owner owner)
protected void sendDeleteLockRequest(Address dest, java.lang.String lock_name)
protected void sendAwaitConditionRequest(java.lang.String lock_name, Owner owner)
sendAwaitConditionRequest
in class Locking
protected void sendSignalConditionRequest(java.lang.String lock_name, boolean all)
sendSignalConditionRequest
in class Locking
protected void sendDeleteAwaitConditionRequest(java.lang.String lock_name, Owner owner)
sendDeleteAwaitConditionRequest
in class Locking
public void handleView(View view)
handleView
in class Locking
public void lockCreated(java.lang.String name)
lockCreated
in interface LockNotification
public void lockDeleted(java.lang.String name)
lockDeleted
in interface LockNotification
public void locked(java.lang.String lock_name, Owner owner)
locked
in interface LockNotification
public void unlocked(java.lang.String lock_name, Owner owner)
unlocked
in interface LockNotification
public void awaiting(java.lang.String lock_name, Owner owner)
awaiting
in interface LockNotification
public void awaited(java.lang.String lock_name, Owner owner)
awaited
in interface LockNotification
protected void updateBackups(Locking.Type type, java.lang.String lock_name, Owner owner)
protected void copyLocksTo(java.util.List<Address> new_joiners)
Copyright © 1998-2020 Red Hat. All Rights Reserved.