Class ExclusiveLockHolder

  • All Implemented Interfaces:
    com.tangosol.io.ExternalizableLite, com.tangosol.io.pof.PortableObject, Serializable

    public class ExclusiveLockHolder
    extends Object
    implements com.tangosol.io.ExternalizableLite, com.tangosol.io.pof.PortableObject
    A data structure that encapsulates server-side exclusive locking logic.
    Since:
    21.12
    Author:
    Aleks Seovic 2021.10.19
    See Also:
    Serialized Form
    • Constructor Detail

      • ExclusiveLockHolder

        public ExclusiveLockHolder()
        Default constructor for serialization interfaces
    • Method Detail

      • isLocked

        public boolean isLocked()
        Return true if this lock is currently owned by anyone.
        Returns:
        true if this lock is currently owned by anyone
      • isLockedBy

        public boolean isLockedBy​(LockOwner owner)
        Return true if this lock is currently owned by the specified LockOwner.
        Returns:
        true if this lock is currently owned by he specified LockOwner
      • isLockedByMember

        public boolean isLockedByMember​(com.tangosol.util.UUID memberId)
        Return true if this lock is currently owned by the specified member, regardless of which thread on that member owns it.
        Returns:
        true if this lock is currently owned by he specified member
      • isLockedByClient

        public boolean isLockedByClient()
        Return true if this lock is currently owned by the remote client (Extend or gRPC).
        Returns:
        true if this lock is currently owned by the remote client
      • lock

        public boolean lock​(LockOwner owner)
        Attempt to acquire the lock.
        Parameters:
        owner - the lock owner to acquire the lock for
        Returns:
        true if the lock was successfully acquired
      • unlock

        public boolean unlock​(LockOwner owner)
        Attempt to release the lock.
        Parameters:
        owner - the lock owner to release the lock for
        Returns:
        true if the specified owner held the lock, and the lock was successfully released
      • getOwner

        public LockOwner getOwner()
        Return the current lock owner, if any.
        Returns:
        the current lock owner, if any; null otherwise
      • removeLocksFor

        protected boolean removeLocksFor​(com.tangosol.util.UUID memberId)
        Remove the lock, if it's owned by the specified member.
        Parameters:
        memberId - the UID of a member to remove the locks for
        Returns:
        true if this holder was modified
      • retainLocksFor

        protected boolean retainLocksFor​(Set<com.tangosol.util.UUID> setMemberIds)
        Remove the lock if it's NOT owned by one of the specified cluster members or a remote client (Extend or gRPC).
        Parameters:
        setMemberIds - the UUIDs of the cluster members to retain the locks for
        Returns:
        true if this holder was modified
      • readExternal

        public void readExternal​(DataInput in)
                          throws IOException
        Specified by:
        readExternal in interface com.tangosol.io.ExternalizableLite
        Throws:
        IOException
      • writeExternal

        public void writeExternal​(DataOutput out)
                           throws IOException
        Specified by:
        writeExternal in interface com.tangosol.io.ExternalizableLite
        Throws:
        IOException
      • readExternal

        public void readExternal​(com.tangosol.io.pof.PofReader in)
                          throws IOException
        Specified by:
        readExternal in interface com.tangosol.io.pof.PortableObject
        Throws:
        IOException
      • writeExternal

        public void writeExternal​(com.tangosol.io.pof.PofWriter out)
                           throws IOException
        Specified by:
        writeExternal in interface com.tangosol.io.pof.PortableObject
        Throws:
        IOException