本文整理了Java中org.apache.hadoop.hive.ql.lockmgr.zookeeper.ZooKeeperHiveLockManager
类的一些代码示例,展示了ZooKeeperHiveLockManager
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperHiveLockManager
类的具体详情如下:
包路径:org.apache.hadoop.hive.ql.lockmgr.zookeeper.ZooKeeperHiveLockManager
类名称:ZooKeeperHiveLockManager
暂无
代码示例来源:origin: apache/hive
/**
* @param key
* The object to be locked
* @param mode
* The mode of the lock
* @param keepAlive
* Whether the lock is to be persisted after the statement Acquire the
* lock. Return null if a conflicting lock is present.
**/
@Override
public ZooKeeperHiveLock lock(HiveLockObject key, HiveLockMode mode,
boolean keepAlive) throws LockException {
return lock(key, mode, keepAlive, false);
}
代码示例来源:origin: apache/hive
/**
* @param hiveLocks
* list of hive locks to be released Release all the locks specified. If some of the
* locks have already been released, ignore them
**/
@Override
public void releaseLocks(List<HiveLock> hiveLocks) {
if (hiveLocks != null) {
int len = hiveLocks.size();
for (int pos = len-1; pos >= 0; pos--) {
HiveLock hiveLock = hiveLocks.get(pos);
try {
LOG.debug("About to release lock for {}",
hiveLock.getHiveLockObject().getName());
unlock(hiveLock);
} catch (LockException e) {
// The lock may have been released. Ignore and continue
LOG.warn("Error when releasing lock", e);
}
}
}
}
代码示例来源:origin: apache/hive
private void checkRedundantNode(String node) {
try {
// Nothing to do if it is a lock mode
if (getLockMode(node) != null) {
return;
}
List<String> children = curatorFramework.getChildren().forPath(node);
for (String child : children) {
checkRedundantNode(node + "/" + child);
}
children = curatorFramework.getChildren().forPath(node);
if ((children == null) || (children.isEmpty()))
{
curatorFramework.delete().forPath(node);
}
} catch (Exception e) {
LOG.warn("Error in checkRedundantNode for node " + node, e);
}
}
代码示例来源:origin: apache/hive
public static void releaseAllLocks(HiveConf conf) throws Exception {
try {
String parent = conf.getVar(HiveConf.ConfVars.HIVE_ZOOKEEPER_NAMESPACE);
List<HiveLock> locks = getLocks(conf, null, parent, false, false);
Exception lastExceptionGot = null;
if (locks != null) {
for (HiveLock lock : locks) {
try {
unlockPrimitive(lock, parent, curatorFramework);
} catch (Exception e) {
lastExceptionGot = e;
}
}
}
// if we got exception during doing the unlock, rethrow it here
if(lastExceptionGot != null) {
throw lastExceptionGot;
}
} catch (Exception e) {
LOG.error("Failed to release all locks: ", e);
throw new Exception(ErrorMsg.ZOOKEEPER_CLIENT_COULD_NOT_BE_INITIALIZED.getMsg());
}
}
代码示例来源:origin: apache/hive
lastName = getLastObjectName(parent, key);
names.add(lastName);
} else {
names = getObjectNames(key);
lastName = names.get(names.size() - 1);
res = createChild(name, new byte[0], CreateMode.PERSISTENT);
} catch (Exception e) {
if (!(e instanceof KeeperException) || ((KeeperException)e).code() != KeeperException.Code.NODEEXISTS) {
res = createChild(getLockName(lastName, mode), key.getData().toString()
.getBytes(), keepAlive ? CreateMode.PERSISTENT_SEQUENTIAL
: CreateMode.EPHEMERAL_SEQUENTIAL);
int seqNo = getSequenceNumber(res, getLockName(lastName, mode));
if (seqNo == -1) {
curatorFramework.delete().forPath(res);
String exLock = getLockName(lastName, HiveLockMode.EXCLUSIVE);
String shLock = getLockName(lastName, HiveLockMode.SHARED);
childSeq = getSequenceNumber(child, exLock);
childSeq = getSequenceNumber(child, shLock);
代码示例来源:origin: apache/hive
@Test
public void testMetrics() throws Exception{
conf.setVar(HiveConf.ConfVars.HIVE_ZOOKEEPER_QUORUM, "localhost");
conf.setVar(HiveConf.ConfVars.HIVE_ZOOKEEPER_CLIENT_PORT, String.valueOf(server.getPort()));
conf.setBoolVar(HiveConf.ConfVars.HIVE_SERVER2_METRICS_ENABLED, true);
conf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
conf.setVar(HiveConf.ConfVars.HIVE_METRICS_REPORTER, MetricsReporting.JSON_FILE.name() + "," + MetricsReporting.JMX.name());
MetricsFactory.init(conf);
CodahaleMetrics metrics = (CodahaleMetrics) MetricsFactory.getInstance();
HiveLockManagerCtx ctx = new HiveLockManagerCtx(conf);
ZooKeeperHiveLockManager zMgr= new ZooKeeperHiveLockManager();
zMgr.setContext(ctx);
ZooKeeperHiveLock curLock = zMgr.lock(hiveLock, HiveLockMode.SHARED, false);
String json = metrics.dumpJson();
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.ZOOKEEPER_HIVE_SHAREDLOCKS, 1);
zMgr.unlock(curLock);
json = metrics.dumpJson();
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.ZOOKEEPER_HIVE_SHAREDLOCKS, 0);
zMgr.close();
}
代码示例来源:origin: apache/hive
lock = lock(lockObject.getObj(), lockObject.getMode(), keepAlive, true);
} catch (LockException e) {
console.printError("Error in acquireLocks..." );
releaseLocks(hiveLocks);
if (isInterrupted) {
throw new LockException(ErrorMsg.LOCK_ACQUIRE_CANCELLED.getMsg());
代码示例来源:origin: apache/hive
HiveLockMode mode = getLockMode(curChild);
if (mode == null) {
continue;
HiveLockObject obj = getLockObject(conf, curChild, mode, data, parent, verifyTablePartition);
if (obj == null) {
continue;
代码示例来源:origin: apache/hive
@Override
public List<HiveLock> getLocks(HiveLockObject key, boolean verifyTablePartitions,
boolean fetchData) throws LockException {
return getLocks(ctx.getConf(), key, parent, verifyTablePartitions, fetchData);
}
代码示例来源:origin: org.apache.hadoop.hive/hive-exec
public static void releaseAllLocks(HiveConf conf) throws Exception {
try {
int sessionTimeout = conf.getIntVar(HiveConf.ConfVars.HIVE_ZOOKEEPER_SESSION_TIMEOUT);
String quorumServers = getQuorumServers(conf);
ZooKeeper zkpClient = new ZooKeeper(quorumServers, sessionTimeout, new DummyWatcher());
String parent = conf.getVar(HiveConf.ConfVars.HIVE_ZOOKEEPER_NAMESPACE);
List<HiveLock> locks = getLocks(conf, zkpClient, null, parent, false, false);
if (locks != null) {
for (HiveLock lock : locks) {
unlock(conf, zkpClient, lock, parent);
}
}
zkpClient.close();
zkpClient = null;
} catch (Exception e) {
LOG.error("Failed to release all locks: " + e.getMessage());
throw new Exception(ErrorMsg.ZOOKEEPER_CLIENT_COULD_NOT_BE_INITIALIZED.getMsg());
}
}
代码示例来源:origin: apache/hive
HiveLockMode lMode = hiveLock.getHiveLockMode();
HiveLockObject obj = zLock.getHiveLockObject();
String name = getLastObjectName(parent, obj);
try {
代码示例来源:origin: apache/hive
/** Remove all redundant nodes **/
private void removeAllRedundantNodes() {
try {
checkRedundantNode("/" + parent);
} catch (Exception e) {
LOG.warn("Exception while removing all redundant nodes", e);
}
}
代码示例来源:origin: org.apache.hadoop.hive/hive-exec
/** Remove all redundant nodes **/
private void removeAllRedundantNodes() {
try {
renewZookeeperInstance(sessionTimeout, quorumServers);
checkRedundantNode("/" + parent);
} catch (Exception e) {
// ignore all errors
}
}
代码示例来源:origin: apache/drill
lastName = getLastObjectName(parent, key);
names.add(lastName);
} else {
names = getObjectNames(key);
lastName = names.get(names.size() - 1);
res = createChild(name, new byte[0], CreateMode.PERSISTENT);
} catch (Exception e) {
if (!(e instanceof KeeperException) || ((KeeperException)e).code() != KeeperException.Code.NODEEXISTS) {
res = createChild(getLockName(lastName, mode), key.getData().toString()
.getBytes(), keepAlive ? CreateMode.PERSISTENT_SEQUENTIAL
: CreateMode.EPHEMERAL_SEQUENTIAL);
int seqNo = getSequenceNumber(res, getLockName(lastName, mode));
if (seqNo == -1) {
curatorFramework.delete().forPath(res);
String exLock = getLockName(lastName, HiveLockMode.EXCLUSIVE);
String shLock = getLockName(lastName, HiveLockMode.SHARED);
childSeq = getSequenceNumber(child, exLock);
childSeq = getSequenceNumber(child, shLock);
代码示例来源:origin: apache/drill
lock = lock(lockObject.getObj(), lockObject.getMode(), keepAlive, true);
} catch (LockException e) {
console.printError("Error in acquireLocks..." );
releaseLocks(hiveLocks);
if (isInterrupted) {
throw new LockException(ErrorMsg.LOCK_ACQUIRE_CANCELLED.getMsg());
代码示例来源:origin: apache/drill
HiveLockMode mode = getLockMode(curChild);
if (mode == null) {
continue;
HiveLockObject obj = getLockObject(conf, curChild, mode, data, parent, verifyTablePartition);
if (obj == null) {
continue;
代码示例来源:origin: apache/drill
public static void releaseAllLocks(HiveConf conf) throws Exception {
try {
String parent = conf.getVar(HiveConf.ConfVars.HIVE_ZOOKEEPER_NAMESPACE);
List<HiveLock> locks = getLocks(conf, null, parent, false, false);
Exception lastExceptionGot = null;
if (locks != null) {
for (HiveLock lock : locks) {
try {
unlockPrimitive(lock, parent, curatorFramework);
} catch (Exception e) {
lastExceptionGot = e;
}
}
}
// if we got exception during doing the unlock, rethrow it here
if(lastExceptionGot != null) {
throw lastExceptionGot;
}
} catch (Exception e) {
LOG.error("Failed to release all locks: ", e);
throw new Exception(ErrorMsg.ZOOKEEPER_CLIENT_COULD_NOT_BE_INITIALIZED.getMsg());
}
}
代码示例来源:origin: apache/hive
@Override
public List<HiveLock> getLocks(boolean verifyTablePartition, boolean fetchData)
throws LockException {
return getLocks(ctx.getConf(), null, parent, verifyTablePartition, fetchData);
}
代码示例来源:origin: apache/drill
HiveLockMode lMode = hiveLock.getHiveLockMode();
HiveLockObject obj = zLock.getHiveLockObject();
String name = getLastObjectName(parent, obj);
try {
代码示例来源:origin: apache/drill
/** Remove all redundant nodes **/
private void removeAllRedundantNodes() {
try {
checkRedundantNode("/" + parent);
} catch (Exception e) {
LOG.warn("Exception while removing all redundant nodes", e);
}
}
内容来源于网络,如有侵权,请联系作者删除!