Class ZookeeperLockRegistry

java.lang.Object
org.springframework.integration.zookeeper.lock.ZookeeperLockRegistry
All Implemented Interfaces:
DisposableBean, ExpirableLockRegistry, LockRegistry

public class ZookeeperLockRegistry extends Object implements ExpirableLockRegistry, DisposableBean
ExpirableLockRegistry implementation using Zookeeper, or more specifically, Curator InterProcessMutex.
Since:
4.2
Author:
Gary Russell, Artem Bilan, Vedran Pavic, Unseok Kim, Christian Tzolov
  • Constructor Details

  • Method Details

    • setMutexTaskExecutor

      public void setMutexTaskExecutor(AsyncTaskExecutor mutexTaskExecutor)
      Set an AsyncTaskExecutor to use when establishing (and testing) the connection with Zookeeper. This must be performed asynchronously so the Lock.tryLock(long, TimeUnit) contract can be honored. While an executor is used internally, an external executor may be required in some environments, for example those that require the use of a WorkManagerTaskExecutor.
      Parameters:
      mutexTaskExecutor - the executor.
      Since:
      4.2.10
    • setCacheCapacity

      public void setCacheCapacity(int cacheCapacity)
      Set the capacity of cached locks.
      Parameters:
      cacheCapacity - The capacity of cached lock, (default 30_000).
      Since:
      5.5.6
    • obtain

      public Lock obtain(Object lockKey)
      Description copied from interface: LockRegistry
      Obtain the lock associated with the parameter object.
      Specified by:
      obtain in interface LockRegistry
      Parameters:
      lockKey - The object with which the lock is associated.
      Returns:
      The associated lock.
    • expireUnusedOlderThan

      public void expireUnusedOlderThan(long age)
      Remove locks last acquired more than 'age' ago that are not currently locked. Expiry is not supported if the ZookeeperLockRegistry.KeyToPathStrategy is bounded (returns a finite number of paths). With such a ZookeeperLockRegistry.KeyToPathStrategy, the overhead of tracking when a lock is obtained is avoided.
      Specified by:
      expireUnusedOlderThan in interface ExpirableLockRegistry
      Parameters:
      age - the time since the lock was last obtained.
    • destroy

      public void destroy()
      Specified by:
      destroy in interface DisposableBean