public class ZKLocksService extends MemoryLocksService implements Service, Instrumentable
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.MemoryLocksService.Type
Modifier and Type | Field and Description |
---|---|
static String |
LOCKS_NODE |
INSTRUMENTATION_GROUP
CONF_PREFIX, DEFAULT_LOCK_TIMEOUT, lockTimeout
Constructor and Description |
---|
ZKLocksService() |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Destroy the zookeeper locks service.
|
ConcurrentMap<String,org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock> |
getLocks() |
LockToken |
getReadLock(String resource,
long wait)
Obtain a READ lock for a source.
|
LockToken |
getWriteLock(String resource,
long wait)
Obtain a WRITE lock for a source.
|
void |
init(Services services)
Initialize the zookeeper locks service
|
void |
instrument(Instrumentation instr)
Instruments the zookeeper locks service.
|
getInterface, getMemoryLocks
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getInterface
public static final String LOCKS_NODE
public ZKLocksService()
public void init(Services services) throws ServiceException
init
in interface Service
init
in class MemoryLocksService
services
- services instance.ServiceException
- thrown if the service could not initialize.public void destroy()
destroy
in interface Service
destroy
in class MemoryLocksService
public void instrument(Instrumentation instr)
instrument
in interface Instrumentable
instrument
in class MemoryLocksService
instr
- instance to instrument the memory locks service to.public LockToken getReadLock(String resource, long wait) throws InterruptedException
getReadLock
in class MemoryLocksService
resource
- resource name.wait
- time out in milliseconds to wait for the lock, -1 means no timeout and 0 no wait.null
if the lock could not be obtained.InterruptedException
- thrown if the thread was interrupted while waiting.public LockToken getWriteLock(String resource, long wait) throws InterruptedException
getWriteLock
in class MemoryLocksService
resource
- resource name.wait
- time out in milliseconds to wait for the lock, -1 means no timeout and 0 no wait.null
if the lock could not be obtained.InterruptedException
- thrown if the thread was interrupted while waiting.public ConcurrentMap<String,org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock> getLocks()
Copyright © 2018 Apache Software Foundation. All rights reserved.