Package org.jgroups.protocols
Class CENTRAL_LOCK2
- java.lang.Object
-
- org.jgroups.stack.Protocol
-
- org.jgroups.protocols.Locking
-
- org.jgroups.protocols.CENTRAL_LOCK2
-
public class CENTRAL_LOCK2 extends Locking
Implementation of a locking protocol which acquires locks by asking the coordinator.
Because the coordinator maintains all locks, no total ordering of requests is required.
CENTRAL_LOCK2 has all members send lock and unlock requests to the current coordinator. The coordinator has a queue for incoming requests, and grants locks based on order of arrival.
Contrary toCENTRAL_LOCK, CENTRAL_LOCK2 has no members who act as backups for lock information. Instead, when the coord leaves or on a merge, the new coordinator runs a reconciliation protocol in which it fetches information from all members about acquired locks and pending lock and unlock requests, and then creates its lock table accordingly. During this phase, all regular request handling is paused.
This protocol requires less traffic thanCENTRAL_LOCK(each request also has to be sent to the backup(s)), but introduces communication between the new coord and all members (and thus a small pause) on coord change.
The JIRA issue is https://issues.jboss.org/browse/JGRP-2249.- Since:
- 4.0.13
- Author:
- Bela Ban
- See Also:
Locking,CENTRAL_LOCK
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jgroups.protocols.Locking
Locking.ClientCondition, Locking.ClientLock, Locking.ClientLockTable, Locking.LockInfoResponse, Locking.LockingHeader, Locking.Request, Locking.Response, Locking.ServerCondition, Locking.ServerLock, Locking.Type
-
-
Field Summary
Fields Modifier and Type Field Description protected Addresscoordprotected ResponseCollector<Locking.LockInfoResponse>lock_info_responsesprotected longlock_reconciliation_timeoutprotected Runnerreq_handlerprotected java.util.concurrent.BlockingQueue<Locking.Request>req_queueprotected booleanuse_thread_id_for_lock_owner-
Fields inherited from class org.jgroups.protocols.Locking
bypass_bundling, client_lock_table, current_lock_id, local_addr, lock_listeners, lock_stripes, lock_striping_size, server_locks, view
-
Fields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, log, stack, stats, up_prot
-
-
Constructor Summary
Constructors Constructor Description CENTRAL_LOCK2()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Locking.LockInfoResponsecreateLockInfoResponse()java.lang.StringgetCoordinator()protected OwnergetOwner()protected voidhandleLockInfoRequest(Address requester)protected voidhandleLockInfoResponse(Address sender, Locking.Request rsp)protected voidhandleLockRevoked(Locking.Request rsp)voidhandleView(View v)booleanisCoord()booleanisRequestHandlerRunning()protected voidprocessQueue()intrequestQueueSize()protected voidrequestReceived(Locking.Request req)voidrunReconciliation()Grabs information about locks held and pending lock/unlock requests from all membersprotected voidsendAwaitConditionRequest(java.lang.String lock_name, Owner owner)protected voidsendDeleteAwaitConditionRequest(java.lang.String lock_name, Owner owner)protected voidsendGrantLockRequest(java.lang.String lock_name, int lock_id, Owner owner, long timeout, boolean is_trylock)protected voidsendLockInfoRequestTo(Buffer buf, Address[] mbrs, Address exclude)protected voidsendReleaseLockRequest(java.lang.String lock_name, int lock_id, Owner owner)protected voidsendSignalConditionRequest(java.lang.String lock_name, boolean all)voidstop()This method is called on aJChannel.disconnect().-
Methods inherited from class org.jgroups.protocols.Locking
_getLock, addLockListener, createLock, down, getAddress, getBypassBundling, getLock, getLock, getNumClientLocks, getNumServerLocks, getView, handleAwaitRequest, handleCreateAwaitingRequest, handleCreateLockRequest, handleDeleteAwaitingRequest, handleDeleteAwaitRequest, handleDeleteLockRequest, handleLockDeniedResponse, handleLockGrantedResponse, handleLockReleasedResponse, handleLockRequest, handleRequest, handleSignalRequest, handleSignalResponse, init, notifyAwaited, notifyAwaiting, notifyLockCreated, notifyLockDeleted, notifyLocked, notifyLockRevoked, notifyUnlocked, printLocks, printServerLocks, removeLockListener, send, sendLockResponse, sendRequest, sendRequest, sendSignalResponse, setBypassBundling, unlockAll, unlockForce, up, up
-
Methods inherited from class org.jgroups.stack.Protocol
accept, afterCreationHook, destroy, down, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, start, statsEnabled, up
-
-
-
-
Field Detail
-
use_thread_id_for_lock_owner
protected boolean use_thread_id_for_lock_owner
-
lock_reconciliation_timeout
protected long lock_reconciliation_timeout
-
coord
protected Address coord
-
lock_info_responses
protected final ResponseCollector<Locking.LockInfoResponse> lock_info_responses
-
req_queue
protected final java.util.concurrent.BlockingQueue<Locking.Request> req_queue
-
req_handler
protected final Runner req_handler
-
-
Method Detail
-
isCoord
public boolean isCoord()
-
getCoordinator
public java.lang.String getCoordinator()
-
isRequestHandlerRunning
public boolean isRequestHandlerRunning()
-
requestQueueSize
public int requestQueueSize()
-
stop
public void stop()
Description copied from class:ProtocolThis method is called on aJChannel.disconnect(). Stops work (e.g. by closing multicast socket). Will be called from top to bottom. This means that at the time of the method invocation the neighbor protocol below is still working. This method will replace the STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that when this method is called all messages in the down queue will have been flushed
-
handleView
public void handleView(View v)
- Overrides:
handleViewin classLocking
-
requestReceived
protected void requestReceived(Locking.Request req)
- Overrides:
requestReceivedin classLocking
-
processQueue
protected void processQueue()
-
handleLockInfoRequest
protected void handleLockInfoRequest(Address requester)
- Overrides:
handleLockInfoRequestin classLocking
-
handleLockInfoResponse
protected void handleLockInfoResponse(Address sender, Locking.Request rsp)
- Overrides:
handleLockInfoResponsein classLocking
-
handleLockRevoked
protected void handleLockRevoked(Locking.Request rsp)
- Overrides:
handleLockRevokedin classLocking
-
runReconciliation
public void runReconciliation()
Grabs information about locks held and pending lock/unlock requests from all members
-
sendLockInfoRequestTo
protected void sendLockInfoRequestTo(Buffer buf, Address[] mbrs, Address exclude)
-
sendGrantLockRequest
protected void sendGrantLockRequest(java.lang.String lock_name, int lock_id, Owner owner, long timeout, boolean is_trylock)- Specified by:
sendGrantLockRequestin classLocking
-
sendReleaseLockRequest
protected void sendReleaseLockRequest(java.lang.String lock_name, int lock_id, Owner owner)- Specified by:
sendReleaseLockRequestin classLocking
-
sendAwaitConditionRequest
protected void sendAwaitConditionRequest(java.lang.String lock_name, Owner owner)- Specified by:
sendAwaitConditionRequestin classLocking
-
sendSignalConditionRequest
protected void sendSignalConditionRequest(java.lang.String lock_name, boolean all)- Specified by:
sendSignalConditionRequestin classLocking
-
sendDeleteAwaitConditionRequest
protected void sendDeleteAwaitConditionRequest(java.lang.String lock_name, Owner owner)- Specified by:
sendDeleteAwaitConditionRequestin classLocking
-
createLockInfoResponse
protected Locking.LockInfoResponse createLockInfoResponse()
-
-