org.apache.oozie.service
Class ZKLocksService
java.lang.Object
org.apache.oozie.service.MemoryLocksService
org.apache.oozie.service.ZKLocksService
- All Implemented Interfaces:
- Service, Instrumentable
public class ZKLocksService
- extends MemoryLocksService
- implements Service, Instrumentable
Service that provides distributed locks via ZooKeeper. Requires that a ZooKeeper ensemble is available. The locks will be
located under a ZNode named "locks" under the namespace (see ZKUtils). For example, with default settings, if the
resource we're locking is called "foo", then the ZNode backing the lock will be at /oozie/locks/foo.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LOCKS_NODE
public static final String LOCKS_NODE
- See Also:
- Constant Field Values
DEFAULT_REAPING_THRESHOLD
public static final int DEFAULT_REAPING_THRESHOLD
- See Also:
- Constant Field Values
REAPING_THRESHOLD
public static final String REAPING_THRESHOLD
- See Also:
- Constant Field Values
REAPING_THREADS
public static final String REAPING_THREADS
- See Also:
- Constant Field Values
ZKLocksService
public ZKLocksService()
init
public void init(Services services)
throws ServiceException
- Initialize the zookeeper locks service
- Specified by:
init in interface Service- Overrides:
init in class MemoryLocksService
- Parameters:
services - services instance.
- Throws:
ServiceException - thrown if the service could not initialize.
destroy
public void destroy()
- Destroy the zookeeper locks service.
- Specified by:
destroy in interface Service- Overrides:
destroy in class MemoryLocksService
instrument
public void instrument(Instrumentation instr)
- Instruments the zookeeper locks service.
- Specified by:
instrument in interface Instrumentable- Overrides:
instrument in class MemoryLocksService
- Parameters:
instr - instance to instrument the memory locks service to.
getReadLock
public LockToken getReadLock(String resource,
long wait)
throws InterruptedException
- Obtain a READ lock for a source.
- Overrides:
getReadLock in class MemoryLocksService
- Parameters:
resource - resource name.wait - time out in milliseconds to wait for the lock, -1 means no timeout and 0 no wait.
- Returns:
- the lock token for the resource, or
null if the lock could not be obtained.
- Throws:
InterruptedException - thrown if the thread was interrupted while waiting.
getWriteLock
public LockToken getWriteLock(String resource,
long wait)
throws InterruptedException
- Obtain a WRITE lock for a source.
- Overrides:
getWriteLock in class MemoryLocksService
- Parameters:
resource - resource name.wait - time out in milliseconds to wait for the lock, -1 means no timeout and 0 no wait.
- Returns:
- the lock token for the resource, or
null if the lock could not be obtained.
- Throws:
InterruptedException - thrown if the thread was interrupted while waiting.
getLocks
public HashMap<String,org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock> getLocks()
Copyright © 2015 Apache Software Foundation. All Rights Reserved.