use of com.twitter.distributedlog.lock.ZKSessionLockFactory in project distributedlog by twitter.
the class TestBKLogSegmentWriter method createLock.
private ZKDistributedLock createLock(String path, ZooKeeperClient zkClient, boolean acquireLock) throws Exception {
try {
Await.result(Utils.zkAsyncCreateFullPathOptimistic(zkClient, path, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT));
} catch (KeeperException.NodeExistsException nee) {
// 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 FutureUtils.result(lock.asyncAcquire());
} else {
return lock;
}
}
Aggregations