public class ZookeeperLockRegistry extends Object implements ExpirableLockRegistry, org.springframework.beans.factory.DisposableBean
ExpirableLockRegistry implementation using Zookeeper, or more specifically,
Curator InterProcessMutex.| 限定符和类型 | 类和说明 |
|---|---|
static interface |
ZookeeperLockRegistry.KeyToPathStrategy
Strategy to convert a lock key (e.g. aggregation correlation id) to a
Zookeeper path.
|
DEFAULT_EXPIRE_UNUSED_OLDER_THEN_TIME| 构造器和说明 |
|---|
ZookeeperLockRegistry(org.apache.curator.framework.CuratorFramework client)
Construct a lock registry using the default
ZookeeperLockRegistry.KeyToPathStrategy which
simple appends the key to '/SpringIntegration-LockRegistry/'. |
ZookeeperLockRegistry(org.apache.curator.framework.CuratorFramework client,
String root)
Construct a lock registry using the default
ZookeeperLockRegistry.KeyToPathStrategy which
simple appends the key to '<root>/'. |
ZookeeperLockRegistry(org.apache.curator.framework.CuratorFramework client,
ZookeeperLockRegistry.KeyToPathStrategy keyToPath)
Construct a lock registry using the supplied
ZookeeperLockRegistry.KeyToPathStrategy. |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
destroy() |
void |
expireUnusedOlderThan(long age)
Remove locks last acquired more than 'age' ago that are not currently locked.
|
Lock |
obtain(Object lockKey)
Obtains the lock associated with the parameter object.
|
void |
setMutexTaskExecutor(org.springframework.core.task.AsyncTaskExecutor mutexTaskExecutor)
Set an
AsyncTaskExecutor to use when establishing (and testing) the
connection with Zookeeper. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetDefaultExpireUnusedOlderThanTimepublic ZookeeperLockRegistry(org.apache.curator.framework.CuratorFramework client)
ZookeeperLockRegistry.KeyToPathStrategy which
simple appends the key to '/SpringIntegration-LockRegistry/'.client - the CuratorFramework.public ZookeeperLockRegistry(org.apache.curator.framework.CuratorFramework client,
String root)
ZookeeperLockRegistry.KeyToPathStrategy which
simple appends the key to '<root>/'.client - the CuratorFramework.root - the path root (no trailing /).public ZookeeperLockRegistry(org.apache.curator.framework.CuratorFramework client,
ZookeeperLockRegistry.KeyToPathStrategy keyToPath)
ZookeeperLockRegistry.KeyToPathStrategy.client - the CuratorFramework.keyToPath - the implementation of ZookeeperLockRegistry.KeyToPathStrategy.public void setMutexTaskExecutor(org.springframework.core.task.AsyncTaskExecutor mutexTaskExecutor)
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.mutexTaskExecutor - the executor.public Lock obtain(Object lockKey)
LockRegistryobtain 在接口中 LockRegistrylockKey - The object with which the lock is associated.public void expireUnusedOlderThan(long age)
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.expireUnusedOlderThan 在接口中 ExpirableLockRegistryage - the time since the lock was last obtained.Copyright © 2018 Pivotal Software, Inc.. All rights reserved.