Class ExclusiveLockHolder
- java.lang.Object
-
- com.oracle.coherence.concurrent.locks.internal.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classExclusiveLockHolder.RemoveLocksAn EntryProcessor that will remove locks for the provided member ID, or all the locks for the members that are not in the cluster any longer (if the specified member ID isnull).
-
Constructor Summary
Constructors Constructor Description ExclusiveLockHolder()Default constructor for serialization interfaces
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LockOwnergetOwner()Return the current lock owner, if any.booleanisLocked()Returntrueif this lock is currently owned by anyone.booleanisLockedBy(LockOwner owner)Returntrueif this lock is currently owned by the specifiedLockOwner.booleanisLockedByClient()Returntrueif this lock is currently owned by the remote client (Extend or gRPC).booleanisLockedByMember(com.tangosol.util.UUID memberId)Returntrueif this lock is currently owned by the specified member, regardless of which thread on that member owns it.booleanlock(LockOwner owner)Attempt to acquire the lock.voidreadExternal(com.tangosol.io.pof.PofReader in)voidreadExternal(DataInput in)protected booleanremoveLocksFor(com.tangosol.util.UUID memberId)Remove the lock, if it's owned by the specified member.protected booleanretainLocksFor(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).StringtoString()booleanunlock(LockOwner owner)Attempt to release the lock.voidwriteExternal(com.tangosol.io.pof.PofWriter out)voidwriteExternal(DataOutput out)
-
-
-
Method Detail
-
isLocked
public boolean isLocked()
Returntrueif this lock is currently owned by anyone.- Returns:
trueif this lock is currently owned by anyone
-
isLockedBy
public boolean isLockedBy(LockOwner owner)
Returntrueif this lock is currently owned by the specifiedLockOwner.- Returns:
trueif this lock is currently owned by he specifiedLockOwner
-
isLockedByMember
public boolean isLockedByMember(com.tangosol.util.UUID memberId)
Returntrueif this lock is currently owned by the specified member, regardless of which thread on that member owns it.- Returns:
trueif this lock is currently owned by he specified member
-
isLockedByClient
public boolean isLockedByClient()
Returntrueif this lock is currently owned by the remote client (Extend or gRPC).- Returns:
trueif 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:
trueif 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:
trueif 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;
nullotherwise
-
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:
trueif 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:
trueif this holder was modified
-
readExternal
public void readExternal(DataInput in) throws IOException
- Specified by:
readExternalin interfacecom.tangosol.io.ExternalizableLite- Throws:
IOException
-
writeExternal
public void writeExternal(DataOutput out) throws IOException
- Specified by:
writeExternalin interfacecom.tangosol.io.ExternalizableLite- Throws:
IOException
-
readExternal
public void readExternal(com.tangosol.io.pof.PofReader in) throws IOException- Specified by:
readExternalin interfacecom.tangosol.io.pof.PortableObject- Throws:
IOException
-
writeExternal
public void writeExternal(com.tangosol.io.pof.PofWriter out) throws IOException- Specified by:
writeExternalin interfacecom.tangosol.io.pof.PortableObject- Throws:
IOException
-
-