Interface LockManager

    • Method Detail

      • getLock

        Lock getLock​(String id)
        Gets the lock on a document.

        If the document does not exist, null is returned.

        id - the document id
        the existing lock, or null when there is no lock
      • setLock

        Lock setLock​(String id,
                     Lock lock)
        Sets a lock on a document.

        If the document is already locked, returns its existing lock status (there is no re-locking, removeLock(java.lang.String, java.lang.String) must be called first).

        id - the document id
        lock - the lock to set
        null if locking succeeded, or the existing lock if locking failed
      • removeLock

        Lock removeLock​(String id,
                        String owner)
        Removes the lock from a document.

        The previous lock is returned.

        If owner is null then the lock is unconditionally removed.

        If owner is not null, it must match the existing lock owner for the lock to be removed. If it doesn't match, the returned lock will return true for Lock.getFailed().

        id - the document id
        owner - the owner to check, or null for no check
        the previous lock (may be null), with a failed flag if locking failed
      • canLockBeRemoved

        static boolean canLockBeRemoved​(String oldOwner,
                                        String owner)
        Checks if a given lock can be removed by the given owner.
        oldOwner - the existing lock's owner
        owner - the owner (may be null)
        true if the lock can be removed
      • closeLockManager

        default void closeLockManager()
        Closes the lock manager and releases resources.