Class GridCacheExplicitLockSpan
- java.lang.Object
-
- java.util.concurrent.locks.ReentrantLock
-
- org.apache.ignite.internal.processors.cache.GridCacheExplicitLockSpan
-
- All Implemented Interfaces:
Serializable,Lock
public class GridCacheExplicitLockSpan extends ReentrantLock
Collection of near local locks acquired by a thread on one topology version.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description GridCacheExplicitLockSpan(AffinityTopologyVersion topVer, GridCacheMvccCandidate cand)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddCandidate(AffinityTopologyVersion topVer, GridCacheMvccCandidate cand)Adds candidate to a lock span.@Nullable GridCacheMvccCandidatecandidate(IgniteTxKey key, @Nullable GridCacheVersion ver)Gets explicit lock candidate for given key.booleanisEmpty()voidmarkOwned(IgniteTxKey key)Marks all candidates added for given key as owned.IgniteInternalFuture<Object>releaseFuture()Gets span release future.booleanremoveCandidate(GridCacheMvccCandidate cand)Removes candidate from this lock span.GridCacheMvccCandidateremoveCandidate(IgniteTxKey key, @Nullable GridCacheVersion ver)Removes lock by key and optional version.@Nullable AffinityTopologyVersiontopologyVersion()Gets actual topology snapshot for thread lock span.StringtoString()-
Methods inherited from class java.util.concurrent.locks.ReentrantLock
getHoldCount, getOwner, getQueuedThreads, getQueueLength, getWaitingThreads, getWaitQueueLength, hasQueuedThread, hasQueuedThreads, hasWaiters, isFair, isHeldByCurrentThread, isLocked, lock, lockInterruptibly, newCondition, tryLock, tryLock, unlock
-
-
-
-
Constructor Detail
-
GridCacheExplicitLockSpan
public GridCacheExplicitLockSpan(AffinityTopologyVersion topVer, GridCacheMvccCandidate cand)
- Parameters:
topVer- Topology version.cand- Candidate.
-
-
Method Detail
-
addCandidate
public boolean addCandidate(AffinityTopologyVersion topVer, GridCacheMvccCandidate cand)
Adds candidate to a lock span.- Parameters:
topVer- Topology snapshot for which candidate is added.cand- Candidate to add.- Returns:
Trueif candidate was added,falseif this span is empty and new span should be created.
-
removeCandidate
public boolean removeCandidate(GridCacheMvccCandidate cand)
Removes candidate from this lock span.- Parameters:
cand- Candidate to remove.- Returns:
Trueif span is empty and should be removed,falseotherwise.
-
removeCandidate
public GridCacheMvccCandidate removeCandidate(IgniteTxKey key, @Nullable @Nullable GridCacheVersion ver)
Removes lock by key and optional version.- Parameters:
key- Key.ver- Version (ornullif any candidate should be removed.)- Returns:
- Removed candidate if matches given parameters.
-
isEmpty
public boolean isEmpty()
- Returns:
Trueif span is empty and candidates cannot be added anymore.
-
markOwned
public void markOwned(IgniteTxKey key)
Marks all candidates added for given key as owned.- Parameters:
key- Key.
-
candidate
@Nullable public @Nullable GridCacheMvccCandidate candidate(IgniteTxKey key, @Nullable @Nullable GridCacheVersion ver)
Gets explicit lock candidate for given key.- Parameters:
key- Key to lookup.ver- Version to lookup (ifnull- return any).- Returns:
- Last added explicit lock candidate, if any, or
null.
-
topologyVersion
@Nullable public @Nullable AffinityTopologyVersion topologyVersion()
Gets actual topology snapshot for thread lock span.- Returns:
- Topology snapshot or
nullif candidate list is empty.
-
releaseFuture
public IgniteInternalFuture<Object> releaseFuture()
Gets span release future. Future is completed when last lock is released.- Returns:
- Release future.
-
toString
public String toString()
- Overrides:
toStringin classReentrantLock
-
-