Class ZkDistributedConfigSetLockFactory

java.lang.Object
org.apache.solr.cloud.ZkDistributedConfigSetLockFactory
All Implemented Interfaces:
DistributedConfigSetLockFactory

public class ZkDistributedConfigSetLockFactory extends Object implements DistributedConfigSetLockFactory
A distributed lock implementation using Zookeeper "directory" nodes created within a collection znode hierarchy, for use with the distributed Collection API implementation. The locks are implemented using ephemeral nodes placed below the "directory" nodes.
See Also:
  • Constructor Details

    • ZkDistributedConfigSetLockFactory

      public ZkDistributedConfigSetLockFactory(org.apache.solr.common.cloud.SolrZkClient zkClient, String rootPath)
  • Method Details

    • createLock

      public DistributedLock createLock(boolean isWriteLock, String configSetName)
      Description copied from interface: DistributedConfigSetLockFactory
      Create a new lock of the specified type (read or write) entering the "competition" for actually getting the lock for the configSetName

      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 DistributedLock are therefore requested for a single operation and are packaged together and returned as an DistributedMultiLock, see CollectionApiLockFactory.createCollectionApiLock(org.apache.solr.common.params.CollectionParams.LockLevel, java.lang.String, java.lang.String, java.lang.String) or ConfigSetApiLockFactory.createConfigSetApiLock(java.lang.String, java.lang.String).

      Specified by:
      createLock in interface DistributedConfigSetLockFactory
      Parameters:
      isWriteLock - true if requesting a write lock, false for a read lock.
      configSetName - the config set name, can never be null.
      Returns:
      a lock instance that must be DistributedLock.release()'ed in a finally, regardless of the lock having been acquired or not.
    • doCreateLock

      protected DistributedLock doCreateLock(boolean isWriteLock, String lockPath)
    • getPathPrefix

      protected StringBuilder getPathPrefix()