Class CENTRAL_LOCK

  • All Implemented Interfaces:
    LockNotification

    public class CENTRAL_LOCK
    extends Locking
    implements LockNotification
    Implementation of a locking protocol which acquires locks by contacting the coordinator.

    Because the coordinator maintains all locks, no total order configuration is required.

    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.
    Since:
    2.12
    Author:
    Bela Ban
    See Also:
    Locking
    • Field Detail

      • num_backups

        protected int num_backups
      • use_thread_id_for_lock_owner

        protected boolean use_thread_id_for_lock_owner
      • is_coord

        protected boolean is_coord
      • backups

        protected final java.util.List<Address> backups
    • Constructor Detail

      • CENTRAL_LOCK

        public CENTRAL_LOCK()
    • Method Detail

      • getCoord

        public Address getCoord()
      • isCoord

        public boolean isCoord()
      • getCoordinator

        public java.lang.String getCoordinator()
      • getNumberOfBackups

        public int getNumberOfBackups()
      • setNumberOfBackups

        public void setNumberOfBackups​(int num_backups)
      • getBackups

        public java.lang.String getBackups()
      • 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
      • sendCreateLockRequest

        protected void sendCreateLockRequest​(Address dest,
                                             java.lang.String lock_name,
                                             Owner owner)
      • sendDeleteLockRequest

        protected void sendDeleteLockRequest​(Address dest,
                                             java.lang.String lock_name)
      • sendSignalConditionRequest

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

        protected void updateBackups​(Locking.Type type,
                                     java.lang.String lock_name,
                                     Owner owner)
      • copyLocksTo

        protected void copyLocksTo​(java.util.List<Address> new_joiners)