gpt4 book ai didi

org.apache.hadoop.util.curator.ZKCuratorManager.exists()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 09:44:55 34 4
gpt4 key购买 nike

本文整理了Java中org.apache.hadoop.util.curator.ZKCuratorManager.exists()方法的一些代码示例,展示了ZKCuratorManager.exists()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKCuratorManager.exists()方法的具体详情如下:
包路径:org.apache.hadoop.util.curator.ZKCuratorManager
类名称:ZKCuratorManager
方法名:exists

ZKCuratorManager.exists介绍

[英]Check if a ZNode exists.
[中]检查ZNode是否存在。

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Delete a ZNode.
 * @param path Path of the ZNode.
 * @return If the znode was deleted.
 * @throws Exception If it cannot contact ZooKeeper.
 */
public boolean delete(final String path) throws Exception {
 if (exists(path)) {
  curator.delete().deletingChildrenIfNeeded().forPath(path);
  return true;
 }
 return false;
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Create a ZNode.
 * @param path Path of the ZNode.
 * @param zkAcl ACL for the node.
 * @return If the ZNode was created.
 * @throws Exception If it cannot contact Zookeeper.
 */
public boolean create(final String path, List<ACL> zkAcl) throws Exception {
 boolean created = false;
 if (!exists(path)) {
  curator.create()
    .withMode(CreateMode.PERSISTENT)
    .withACL(zkAcl)
    .forPath(path, null);
  created = true;
 }
 return created;
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

public void safeCreate(String path, byte[] data, List<ACL> acl,
  CreateMode mode, List<ACL> fencingACL, String fencingNodePath)
  throws Exception {
 if (!exists(path)) {
  SafeTransaction transaction = createTransaction(fencingACL,
    fencingNodePath);
  transaction.create(path, data, acl, mode);
  transaction.commit();
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Deletes the path. Checks for existence of path as well.
 * @param path Path to be deleted.
 * @throws Exception if any problem occurs while performing deletion.
 */
public void safeDelete(final String path, List<ACL> fencingACL,
  String fencingNodePath) throws Exception {
 if (exists(path)) {
  SafeTransaction transaction = createTransaction(fencingACL,
    fencingNodePath);
  transaction.delete(path);
  transaction.commit();
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@VisibleForTesting
boolean exists(final String path) throws Exception {
 return zkManager.exists(path);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Override
public Version getConfStoreVersion() throws Exception {
 if (zkManager.exists(zkVersionPath)) {
  byte[] data = zkManager.getData(zkVersionPath);
  return new VersionPBImpl(YarnServerCommonProtos.VersionProto
    .parseFrom(data));
 }
 return null;
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Override
public synchronized void storeVersion() throws Exception {
 byte[] data =
   ((VersionPBImpl) CURRENT_VERSION_INFO).getProto().toByteArray();
 if (zkManager.exists(zkVersionPath)) {
  zkManager.safeSetData(zkVersionPath, data, -1, zkAcl, fencingNodePath);
 } else {
  zkManager.safeCreate(zkVersionPath, data, zkAcl, CreateMode.PERSISTENT,
    zkAcl, fencingNodePath);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

zkManager.delete(fencingNodePath);
if (!zkManager.exists(logsPath)) {
 zkManager.create(logsPath);
 zkManager.setData(logsPath,
if (!zkManager.exists(confStorePath)) {
 zkManager.create(confStorePath);
 HashMap<String, String> mapSchedConf = new HashMap<>();

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com