Class 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 to CENTRAL_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 than CENTRAL_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
    • Field Detail

      • use_thread_id_for_lock_owner

        protected boolean use_thread_id_for_lock_owner
      • lock_reconciliation_timeout

        protected long lock_reconciliation_timeout
      • req_queue

        protected final java.util.concurrent.BlockingQueue<Locking.Request> req_queue
      • req_handler

        protected final Runner req_handler
    • Constructor Detail

      • CENTRAL_LOCK2

        public CENTRAL_LOCK2()
    • 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: Protocol
        This method is called on a JChannel.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
        Overrides:
        stop in class Protocol
      • processQueue

        protected void processQueue()
      • 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:
        sendGrantLockRequest in class Locking
      • sendReleaseLockRequest

        protected void sendReleaseLockRequest​(java.lang.String lock_name,
                                              int lock_id,
                                              Owner owner)
        Specified by:
        sendReleaseLockRequest in class Locking
      • sendSignalConditionRequest

        protected void sendSignalConditionRequest​(java.lang.String lock_name,
                                                  boolean all)
        Specified by:
        sendSignalConditionRequest in class Locking