public class ZookeeperLockRegistry extends Object implements ExpirableLockRegistry
ExpirableLockRegistry implementation using Zookeeper, or more specifically,
Curator InterProcessMutex.| Modifier and Type | Class and Description |
|---|---|
static interface |
ZookeeperLockRegistry.KeyToPathStrategy
Strategy to convert a lock key (e.g.
|
| Constructor and Description |
|---|
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. |
| Modifier and Type | Method and Description |
|---|---|
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.
|
public 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 Lock obtain(Object lockKey)
LockRegistryobtain in interface 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 in interface ExpirableLockRegistryage - the time since the lock was last obtained.