use of org.apache.oozie.service.ZKLocksService.ZKLockToken in project oozie by apache.
the class TestZKLocksService method testLockRelease.
public void testLockRelease() throws ServiceException, InterruptedException {
final String path = UUID.randomUUID().toString();
ZKLocksService zkls = new ZKLocksService();
try {
zkls.init(Services.get());
ZKLockToken lock = (ZKLockToken) zkls.getWriteLock(path, TestMemoryLocks.DEFAULT_LOCK_TIMEOUT);
assertTrue(zkls.getLocks().containsKey(path));
lock.release();
checkLockRelease(path, zkls);
} finally {
zkls.destroy();
}
}
use of org.apache.oozie.service.ZKLocksService.ZKLockToken in project oozie by apache.
the class TestZKLocksService method testReentrantMultipleCall.
public void testReentrantMultipleCall() throws ServiceException, InterruptedException {
final String path = UUID.randomUUID().toString();
ZKLocksService zkls = new ZKLocksService();
try {
zkls.init(Services.get());
ZKLockToken lock = (ZKLockToken) zkls.getWriteLock(path, TestMemoryLocks.DEFAULT_LOCK_TIMEOUT);
lock = (ZKLockToken) zkls.getWriteLock(path, TestMemoryLocks.DEFAULT_LOCK_TIMEOUT);
lock = (ZKLockToken) zkls.getWriteLock(path, TestMemoryLocks.DEFAULT_LOCK_TIMEOUT);
assertTrue(zkls.getLocks().containsKey(path));
lock.release();
assertTrue(zkls.getLocks().containsKey(path));
lock.release();
assertTrue(zkls.getLocks().containsKey(path));
lock.release();
checkLockRelease(path, zkls);
} catch (Exception e) {
fail("Reentrant property, it should have acquired lock");
} finally {
zkls.destroy();
}
}
Aggregations