Class Locking

  • Direct Known Subclasses:
    CENTRAL_LOCK, CENTRAL_LOCK2

    public abstract class Locking
    extends Protocol
    Base locking protocol, handling most of the protocol communication with other instances. To use distributed locking, LockService is placed on a channel. LockService talks to a subclass of Locking via events.
    Since:
    2.12
    Author:
    Bela Ban
    See Also:
    CENTRAL_LOCK, CENTRAL_LOCK2
    • Field Detail

      • bypass_bundling

        protected boolean bypass_bundling
      • lock_striping_size

        protected int lock_striping_size
      • local_addr

        protected Address local_addr
      • view

        protected View view
      • server_locks

        protected final java.util.concurrent.ConcurrentMap<java.lang.String,​Locking.ServerLock> server_locks
      • lock_stripes

        protected java.util.concurrent.locks.Lock[] lock_stripes
      • lock_listeners

        protected final java.util.Set<LockNotification> lock_listeners
      • current_lock_id

        protected static final java.util.concurrent.atomic.AtomicInteger current_lock_id
    • Constructor Detail

      • Locking

        public Locking()
    • Method Detail

      • getBypassBundling

        public boolean getBypassBundling()
      • setBypassBundling

        public void setBypassBundling​(boolean bypass_bundling)
      • removeLockListener

        public void removeLockListener​(LockNotification listener)
      • getAddress

        public java.lang.String getAddress()
      • getView

        public java.lang.String getView()
      • getNumServerLocks

        public int getNumServerLocks()
      • getNumClientLocks

        public int getNumClientLocks()
      • init

        public void init()
                  throws java.lang.Exception
        Description copied from class: Protocol
        Called after instance has been created (null constructor) and before protocol is started. Properties are already set. Other protocols are not yet connected and events cannot yet be sent.
        Overrides:
        init in class Protocol
        Throws:
        java.lang.Exception - Thrown if protocol cannot be initialized successfully. This will cause the ProtocolStack to fail, so the channel constructor will throw an exception
      • down

        public java.lang.Object down​(Event evt)
        Description copied from class: Protocol
        An event is to be sent down the stack. A protocol may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the protocol may need to add a header to it (or do nothing at all) before sending it down the stack using down_prot.down().
        Overrides:
        down in class Protocol
      • up

        public java.lang.Object up​(Event evt)
        Description copied from class: Protocol
        An event was received from the protocol below. Usually the current protocol will want to examine the event type and - depending on its type - perform some computation (e.g. removing headers from a MSG event type, or updating the internal membership list when receiving a VIEW_CHANGE event). Finally the event is either a) discarded, or b) an event is sent down the stack using down_prot.down() or c) the event (or another event) is sent up the stack using up_prot.up().
        Overrides:
        up in class Protocol
      • up

        public java.lang.Object up​(Message msg)
        Description copied from class: Protocol
        A single message was received. Protocols may examine the message and do something (e.g. add a header) with it before passing it up.
        Overrides:
        up in class Protocol
      • requestReceived

        protected void requestReceived​(Locking.Request req)
      • getLock

        protected Locking.ClientLock getLock​(java.lang.String name,
                                             boolean create_if_absent)
      • unlockAll

        public void unlockAll()
      • unlockForce

        public void unlockForce​(java.lang.String lock_name)
      • printLocks

        public java.lang.String printLocks()
      • printServerLocks

        public java.lang.Object printServerLocks()
      • handleView

        protected void handleView​(View view)
      • _getLock

        protected java.util.concurrent.locks.Lock _getLock​(java.lang.String lock_name)
        Gets a lock from locks based on the hash of the lock name
      • getOwner

        protected Owner getOwner()
      • sendGrantLockRequest

        protected abstract void sendGrantLockRequest​(java.lang.String lock_name,
                                                     int lock_id,
                                                     Owner owner,
                                                     long timeout,
                                                     boolean is_trylock)
      • sendReleaseLockRequest

        protected abstract void sendReleaseLockRequest​(java.lang.String lock_name,
                                                       int lock_id,
                                                       Owner owner)
      • sendAwaitConditionRequest

        protected abstract void sendAwaitConditionRequest​(java.lang.String lock_name,
                                                          Owner owner)
      • sendSignalConditionRequest

        protected abstract void sendSignalConditionRequest​(java.lang.String lock_name,
                                                           boolean all)
      • sendDeleteAwaitConditionRequest

        protected abstract void sendDeleteAwaitConditionRequest​(java.lang.String lock_name,
                                                                Owner owner)
      • sendRequest

        protected void sendRequest​(Address dest,
                                   Locking.Type type,
                                   java.lang.String lock_name,
                                   Owner owner,
                                   long timeout,
                                   boolean is_trylock)
      • sendRequest

        protected void sendRequest​(Address dest,
                                   Locking.Type type,
                                   java.lang.String lock_name,
                                   int lock_id,
                                   Owner owner,
                                   long timeout,
                                   boolean is_trylock)
      • sendLockResponse

        protected void sendLockResponse​(Locking.Type type,
                                        Owner dest,
                                        java.lang.String lock_name,
                                        int lock_id)
      • sendSignalResponse

        protected void sendSignalResponse​(Owner dest,
                                          java.lang.String lock_name)
      • handleLockRequest

        protected void handleLockRequest​(Locking.Request req)
      • handleLockGrantedResponse

        protected void handleLockGrantedResponse​(java.lang.String lock_name,
                                                 int lock_id,
                                                 Owner owner)
      • handleLockReleasedResponse

        protected void handleLockReleasedResponse​(java.lang.String lock_name,
                                                  int lock_id,
                                                  Owner owner)
      • handleLockDeniedResponse

        protected void handleLockDeniedResponse​(java.lang.String lock_name,
                                                int lock_id,
                                                Owner owner)
      • handleLockInfoRequest

        protected void handleLockInfoRequest​(Address requester)
      • handleLockRevoked

        protected void handleLockRevoked​(Locking.Request rsp)
      • handleAwaitRequest

        protected void handleAwaitRequest​(java.lang.String lock_name,
                                          Owner owner)
      • handleDeleteAwaitRequest

        protected void handleDeleteAwaitRequest​(java.lang.String lock_name,
                                                Owner owner)
      • handleSignalResponse

        protected void handleSignalResponse​(java.lang.String lock_name,
                                            Owner owner)
      • handleSignalRequest

        protected void handleSignalRequest​(Locking.Request req)
      • handleCreateLockRequest

        protected void handleCreateLockRequest​(java.lang.String lock_name,
                                               Owner owner)
      • handleDeleteLockRequest

        protected void handleDeleteLockRequest​(java.lang.String lock_name)
      • handleCreateAwaitingRequest

        protected void handleCreateAwaitingRequest​(java.lang.String lock_name,
                                                   Owner owner)
      • handleDeleteAwaitingRequest

        protected void handleDeleteAwaitingRequest​(java.lang.String lock_name,
                                                   Owner owner)
      • notifyLockCreated

        protected void notifyLockCreated​(java.lang.String lock_name)
      • notifyLockDeleted

        protected void notifyLockDeleted​(java.lang.String lock_name)
      • notifyLockRevoked

        protected void notifyLockRevoked​(java.lang.String lock_name,
                                         Owner current_owner)
      • notifyLocked

        protected void notifyLocked​(java.lang.String lock_name,
                                    Owner owner)
      • notifyUnlocked

        protected void notifyUnlocked​(java.lang.String lock_name,
                                      Owner owner)
      • notifyAwaiting

        protected void notifyAwaiting​(java.lang.String lock_name,
                                      Owner owner)
      • notifyAwaited

        protected void notifyAwaited​(java.lang.String lock_name,
                                     Owner owner)