Class LockInfo


  • public abstract class LockInfo
    extends Object
    Internal lock information.
    • Constructor Detail

      • LockInfo

        protected LockInfo​(NodeId id,
                           boolean sessionScoped,
                           boolean deep,
                           String lockOwner,
                           long timeoutHint)
        Create a new instance of this class.
        Parameters:
        id - lock holder node id
        sessionScoped - whether lock token is session scoped
        deep - whether lock is deep
        lockOwner - owner of lock
        timeoutHint - lock timeout hint in seconds
      • LockInfo

        protected LockInfo​(LockInfo that)
    • Method Detail

      • getLockToken

        public String getLockToken()
        Return the lock token associated with this lock.
        Returns:
        lock token
      • getId

        public NodeId getId()
        Return the ID of the lock holding node
        Returns:
        the id
      • getLockOwner

        public String getLockOwner()
        Return the lock owner.
        Returns:
        lock owner
      • isDeep

        public boolean isDeep()
        Return a flag indicating whether the lock is deep.
        Returns:
        true if the lock is deep; false otherwise
      • isLockHolder

        public boolean isLockHolder​(Session session)
        Return a flag indicating whether the session given is lock holder.
        Parameters:
        session - session to compare with
      • getLockHolder

        public SessionImpl getLockHolder()
        Return the session currently holding the lock
        Returns:
        session currently holding the lock
      • setLockHolder

        public void setLockHolder​(SessionImpl lockHolder)
        Set the session currently holding the lock
        Parameters:
        lockHolder - session currently holding the lock
      • isLive

        public boolean isLive()
        Return a flag indicating whether the lock is live
        Returns:
        true if the lock is live; otherwise false
      • setLive

        public void setLive​(boolean live)
        Set the live flag
        Parameters:
        live - live flag
      • mayChange

        public boolean mayChange()
        Return a flag indicating whether the lock information may still change.
        Returns:
        true if the lock is still alive.
      • isSessionScoped

        public boolean isSessionScoped()
        Return a flag indicating whether the lock is session-scoped
        Returns:
        true if the lock is session-scoped; otherwise false
      • getTimeoutHint

        public long getTimeoutHint()
        Returns the timeout hint given when the lock was created.
        Returns:
        timeout hint (in seconds)
      • getTimeoutTime

        public long getTimeoutTime()
        Returns the time when this lock will expire.
        Returns:
        timeout time in milliseconds since the epoch
      • isExpired

        public boolean isExpired()
      • updateTimeoutTime

        public void updateTimeoutTime()
        Updates the timeout time of this lock based on current time and the timeout hint specified for this lock. The timeout time is always rounded up.
      • throwLockException

        public void throwLockException​(String message,
                                       SessionImpl session)
                                throws LockException,
                                       RepositoryException
        Utility method that throws a LockException with the "failure node path" set to the path of the node that holds this lock. The given session is used to resolve the path of the lock holder node.
        Parameters:
        message - exception message
        session - session that the user was using for the failing operation
        Throws:
        LockException - always thrown, unless another error occurs
        RepositoryException - if the path of this lock can not be resolved
      • parseLockToken

        public static NodeId parseLockToken​(String token)
                                     throws IllegalArgumentException
        Parse a lock token string representation and return the lock holder node id.
        Parameters:
        token - string representation of lock token
        Returns:
        lock holder node id
        Throws:
        IllegalArgumentException - if some field is illegal