Interface DistributedCollectionLockFactory
-
- All Known Implementing Classes:
ZkDistributedCollectionLockFactory
public interface DistributedCollectionLockFactory
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DistributedLockcreateLock(boolean isWriteLock, org.apache.solr.common.params.CollectionParams.LockLevel level, String collName, String shardId, String replicaName)Create a new lock of the specified type (read or write) entering the "competition" for actually getting the lock at the given level for the given path i.e.
-
-
-
Method Detail
-
createLock
DistributedLock createLock(boolean isWriteLock, org.apache.solr.common.params.CollectionParams.LockLevel level, String collName, String shardId, String replicaName)
Create a new lock of the specified type (read or write) entering the "competition" for actually getting the lock at the given level for the given path i.e. a lock atcollNameor a lock atcollName/shardIdor a lock atcollName/shardId/replicaName, depending on the passedlevel.The paths are used to define which locks compete with each other (locks of equal paths compete).
Upon return from this call, the lock has not been acquired but the it had entered the lock acquiring "competition", and the caller can decide to wait until the lock is granted by calling
DistributedLock.waitUntilAcquired().
Separating the lock creation from lock acquisition allows a more deterministic release of the locks when/if they can't be acquired.Locks at different paths are independent of each other, multiple
DistributedLockare therefore requested for a single operation and are packaged together and returned as anDistributedMultiLock, seeCollectionApiLockFactory.createCollectionApiLock(org.apache.solr.common.params.CollectionParams.LockLevel, java.lang.String, java.lang.String, java.lang.String).- Parameters:
isWriteLock-trueif requesting a write lock,falsefor a read lock.level- The requested locking level. Can be one of:CollectionParams.LockLevel.COLLECTIONCollectionParams.LockLevel.SHARDCollectionParams.LockLevel.REPLICA
collName- the collection name, can never benullas is needed for all locks.shardId- is ignored and can benulliflevelisCollectionParams.LockLevel.COLLECTIONreplicaName- is ignored and can benulliflevelisCollectionParams.LockLevel.COLLECTIONorCollectionParams.LockLevel.SHARD- Returns:
- a lock instance that must be
DistributedLock.release()'ed in afinally, regardless of the lock having been acquired or not.
-
-