Class ZookeeperLockRegistry

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

public class ZookeeperLockRegistry
extends java.lang.Object
implements org.springframework.integration.support.locks.ExpirableLockRegistry, org.springframework.beans.factory.DisposableBean
ExpirableLockRegistry implementation using Zookeeper, or more specifically, Curator InterProcessMutex.
Since:
4.2
  • Constructor Details

  • Method Details

    • setMutexTaskExecutor

      public void setMutexTaskExecutor​(org.springframework.core.task.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
    • obtain

      public java.util.concurrent.locks.Lock obtain​(java.lang.Object lockKey)
      Specified by:
      obtain in interface org.springframework.integration.support.locks.LockRegistry
    • 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 org.springframework.integration.support.locks.ExpirableLockRegistry
      Parameters:
      age - the time since the lock was last obtained.
    • destroy

      public void destroy()
      Specified by:
      destroy in interface org.springframework.beans.factory.DisposableBean