本文整理了Java中org.apache.accumulo.server.zookeeper.ZooQueueLock.<init>()
方法的一些代码示例,展示了ZooQueueLock.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooQueueLock.<init>()
方法的具体详情如下:
包路径:org.apache.accumulo.server.zookeeper.ZooQueueLock
类名称:ZooQueueLock
方法名:<init>
暂无
代码示例来源:origin: org.apache.accumulo/accumulo-server
public static void main(String args[]) throws InterruptedException, KeeperException {
ZooQueueLock lock = new ZooQueueLock("/lock", true);
DistributedReadWriteLock rlocker = new DistributedReadWriteLock(lock, "reader".getBytes(UTF_8));
DistributedReadWriteLock wlocker = new DistributedReadWriteLock(lock, "wlocker".getBytes(UTF_8));
final Lock readLock = rlocker.readLock();
readLock.lock();
final Lock readLock2 = rlocker.readLock();
readLock2.lock();
final Lock writeLock = wlocker.writeLock();
if (writeLock.tryLock(100, TimeUnit.MILLISECONDS))
throw new RuntimeException("Write lock achieved during read lock!");
readLock.unlock();
readLock2.unlock();
writeLock.lock();
if (readLock.tryLock(100, TimeUnit.MILLISECONDS))
throw new RuntimeException("Read lock achieved during write lock!");
final Lock writeLock2 = DistributedReadWriteLock.recoverLock(lock, "wlocker".getBytes(UTF_8));
writeLock2.unlock();
readLock.lock();
System.out.println("success");
}
代码示例来源:origin: org.apache.accumulo/accumulo-server-base
public static void main(String args[]) throws InterruptedException, KeeperException {
ZooQueueLock lock = new ZooQueueLock("/lock", true);
DistributedReadWriteLock rlocker = new DistributedReadWriteLock(lock, "reader".getBytes(UTF_8));
DistributedReadWriteLock wlocker = new DistributedReadWriteLock(lock,
"wlocker".getBytes(UTF_8));
final Lock readLock = rlocker.readLock();
readLock.lock();
final Lock readLock2 = rlocker.readLock();
readLock2.lock();
final Lock writeLock = wlocker.writeLock();
if (writeLock.tryLock(100, TimeUnit.MILLISECONDS))
throw new RuntimeException("Write lock achieved during read lock!");
readLock.unlock();
readLock2.unlock();
writeLock.lock();
if (readLock.tryLock(100, TimeUnit.MILLISECONDS))
throw new RuntimeException("Read lock achieved during write lock!");
final Lock writeLock2 = DistributedReadWriteLock.recoverLock(lock, "wlocker".getBytes(UTF_8));
writeLock2.unlock();
readLock.lock();
System.out.println("success");
}
代码示例来源:origin: org.apache.accumulo/accumulo-master
private static Lock getLock(String tableId, long tid, boolean writeLock) throws Exception {
byte[] lockData = String.format("%016x", tid).getBytes(UTF_8);
ZooQueueLock qlock = new ZooQueueLock(
ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZTABLE_LOCKS + "/" + tableId,
false);
Lock lock = DistributedReadWriteLock.recoverLock(qlock, lockData);
if (lock == null) {
DistributedReadWriteLock locker = new DistributedReadWriteLock(qlock, lockData);
if (writeLock)
lock = locker.writeLock();
else
lock = locker.readLock();
}
return lock;
}
代码示例来源:origin: org.apache.accumulo/accumulo-server
private static Lock getLock(String tableId, long tid, boolean writeLock) throws Exception {
byte[] lockData = String.format("%016x", tid).getBytes(UTF_8);
ZooQueueLock qlock = new ZooQueueLock(ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZTABLE_LOCKS + "/" + tableId, false);
Lock lock = DistributedReadWriteLock.recoverLock(qlock, lockData);
if (lock == null) {
DistributedReadWriteLock locker = new DistributedReadWriteLock(qlock, lockData);
if (writeLock)
lock = locker.writeLock();
else
lock = locker.readLock();
}
return lock;
}
内容来源于网络,如有侵权,请联系作者删除!