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
限定符和类型 | 字段和说明 |
---|---|
protected java.util.List<Address> |
backups |
protected Address |
coord |
protected boolean |
is_coord |
protected int |
num_backups |
bypass_bundling, client_lock_table, current_lock_id, local_addr, lock_listeners, lock_stripes, lock_striping_size, server_locks, view
构造器和说明 |
---|
CENTRAL_LOCK() |
限定符和类型 | 方法和说明 |
---|---|
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() |
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,
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, 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, up
accept, 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, up
protected int num_backups
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
在类中 Locking
protected void sendReleaseLockRequest(java.lang.String lock_name, Owner owner)
sendReleaseLockRequest
在类中 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
在类中 Locking
protected void sendSignalConditionRequest(java.lang.String lock_name, boolean all)
sendSignalConditionRequest
在类中 Locking
protected void sendDeleteAwaitConditionRequest(java.lang.String lock_name, Owner owner)
sendDeleteAwaitConditionRequest
在类中 Locking
public void handleView(View view)
handleView
在类中 Locking
public void lockCreated(java.lang.String name)
lockCreated
在接口中 LockNotification
public void lockDeleted(java.lang.String name)
lockDeleted
在接口中 LockNotification
public void locked(java.lang.String lock_name, Owner owner)
locked
在接口中 LockNotification
public void unlocked(java.lang.String lock_name, Owner owner)
unlocked
在接口中 LockNotification
public void awaiting(java.lang.String lock_name, Owner owner)
awaiting
在接口中 LockNotification
public void awaited(java.lang.String lock_name, Owner owner)
awaited
在接口中 LockNotification
protected void updateBackups(Locking.Type type, java.lang.String lock_name, Owner owner)
protected void copyLocksTo(java.util.List<Address> new_joiners)