Class ZooKeeperLocker
java.lang.Object
fr.ens.biologie.genomique.eoulsan.util.locker.ZooKeeperLocker
- All Implemented Interfaces:
Locker,org.apache.zookeeper.Watcher
This class implements a locker using Zookeeper. See @see blog post.
- Since:
- 2.0
- Author:
- Laurent Jourdren
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.zookeeper.Watcher
org.apache.zookeeper.Watcher.Event -
Constructor Summary
ConstructorsConstructorDescriptionZooKeeperLocker(String connectString, int sessionTimeout, String lockBasePath, String lockName) Public constructor.ZooKeeperLocker(String connectString, int sessionTimeout, String lockBasePath, String lockName, boolean sequentialLockName) Public constructor. -
Method Summary
-
Constructor Details
-
ZooKeeperLocker
public ZooKeeperLocker(String connectString, int sessionTimeout, String lockBasePath, String lockName) throws IOException Public constructor.- Parameters:
connectString- Zookeeper connection stringsessionTimeout- session time outlockBasePath- lock base pathlockName- lock name- Throws:
IOException- if an error occurs while creating the ZooKeeper connection
-
ZooKeeperLocker
public ZooKeeperLocker(String connectString, int sessionTimeout, String lockBasePath, String lockName, boolean sequentialLockName) throws IOException Public constructor.- Parameters:
connectString- Zookeeper connection stringsessionTimeout- session time outlockBasePath- lock base pathlockName- lock namesequentialLockName- sequential lock- Throws:
IOException- if an error occurs while creating the ZooKeeper connection
-
-
Method Details
-
lock
Description copied from interface:LockerWait the token and then lock the resource.- Specified by:
lockin interfaceLocker- Throws:
IOException- if an error occurs while locking the resource
-
unlock
Description copied from interface:LockerUnlock the resource.- Specified by:
unlockin interfaceLocker- Throws:
IOException- if an error occurs while unlocking the resource
-
process
public void process(org.apache.zookeeper.WatchedEvent event) - Specified by:
processin interfaceorg.apache.zookeeper.Watcher
-