use of org.apache.distributedlog.lock.ZKSessionLockFactory in project bookkeeper by apache.
the class TestBKLogSegmentWriter method createLock.
private ZKDistributedLock createLock(String path, ZooKeeperClient zkClient, boolean acquireLock) throws Exception {
try {
Utils.ioResult(Utils.zkAsyncCreateFullPathOptimistic(zkClient, path, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT));
} catch (ZKException zke) {
// node already exists
}
SessionLockFactory lockFactory = new ZKSessionLockFactory(zkClient, "test-lock", lockStateExecutor, 0, Long.MAX_VALUE, conf.getZKSessionTimeoutMilliseconds(), NullStatsLogger.INSTANCE);
ZKDistributedLock lock = new ZKDistributedLock(lockStateExecutor, lockFactory, path, Long.MAX_VALUE, NullStatsLogger.INSTANCE);
if (acquireLock) {
return Utils.ioResult(lock.asyncAcquire());
} else {
return lock;
}
}
Aggregations