gpt4 book ai didi

com.alibaba.otter.shared.common.utils.zookeeper.ZkClientx.getChildren()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 11:22:35 29 4
gpt4 key购买 nike

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

ZkClientx.getChildren介绍

暂无

代码示例

代码示例来源:origin: com.alibaba.otter/shared.common

/**
 * Counts number of children for the given path.
 * 
 * @param path
 * @return number of children or 0 if path does not exist.
 */
public int countChildren(String path) {
  try {
    return getChildren(path).size();
  } catch (ZkNoNodeException e) {
    return 0;
  }
}

代码示例来源:origin: com.alibaba.otter/shared.common

@Override
  public List<String> call() throws Exception {
    exists(path, true);
    try {
      return getChildren(path, true);
    } catch (ZkNoNodeException e) {
      // ignore, the "exists" watch will listen for the parent node to appear
    }
    return null;
  }
});

代码示例来源:origin: com.alibaba.otter/shared.arbitrate

private void initNodes() {
  // 获取一下当前存活的所有node节点,再根据对应pipeline关联的node,检查是否在对应的存活列表里
  List<String> nodes = zookeeper.getChildren(ArbitrateConstants.NODE_NID_ROOT);
  initNodes(nodes);
}

代码示例来源:origin: com.alibaba.otter/shared.common

public List<String> getChildren(String path) {
  return getChildren(path, hasListeners(path));
}

代码示例来源:origin: com.alibaba.otter/shared.arbitrate

/**
 * 获取当前存活的节点列表
 */
public List<Long> liveNodes() {
  String path = ArbitrateConstants.NODE_NID_ROOT;
  try {
    List<String> nids = zookeeper.getChildren(path);
    List<Long> result = new ArrayList<Long>();
    for (String nid : nids) {
      result.add(Long.valueOf(nid));
    }
    return result;
  } catch (ZkException e) {
    throw new ArbitrateException("liveNodes", e);
  }
}

代码示例来源:origin: com.alibaba.otter/shared.common

public boolean deleteRecursive(String path) {
  List<String> children;
  try {
    children = getChildren(path, false);
  } catch (ZkNoNodeException e) {
    return true;
  }
  for (String subPath : children) {
    if (!deleteRecursive(path + "/" + subPath)) {
      return false;
    }
  }
  return delete(path);
}

代码示例来源:origin: com.alibaba.otter/shared.arbitrate

/**
 * 获取zk列表数据,无须同步处理
 */
private void initProcess() {
  // 1. 根据pipelineId构造对应的path
  String path = StagePathUtils.getProcessRoot(getPipelineId());
  // 2. 获取当前的所有process列表
  List<String> currentProcesses = zookeeper.getChildren(path);
  initProcess(currentProcesses);
}

代码示例来源:origin: com.alibaba.otter/shared.common

@Override
  public void run() throws Exception {
    try {
      // if the node doesn't exist we should listen for the root node to reappear
      exists(path);
      List<String> children = getChildren(path);
      listener.handleChildChange(path, children);
    } catch (ZkNoNodeException e) {
      listener.handleChildChange(path, null);
    }
  }
});

代码示例来源:origin: com.alibaba.otter/shared.arbitrate

/**
 * 获取zk列表数据,无须同步处理
 */
private void initStage() {
  // 1. 根据pipelineId构造对应的path
  String path = StagePathUtils.getProcessRoot(getPipelineId());
  // 2. 获取当前的所有process列表
  List<String> currentProcesses = zookeeper.getChildren(path);
  initStage(currentProcesses);
}

代码示例来源:origin: com.alibaba.otter/shared.arbitrate

private void initTermin() {
  String path = StagePathUtils.getTerminRoot(getPipelineId());
  List<String> termins = zookeeper.getChildren(path);
  initTermin(termins);
}

代码示例来源:origin: com.alibaba.otter/shared.arbitrate

/**
 * 查询当前的remedy index记录
 */
public List<RemedyIndexEventData> listRemedyIndexs(Long pipelineId) {
  String path = StagePathUtils.getRemedyRoot(pipelineId);
  List<RemedyIndexEventData> datas = new ArrayList<RemedyIndexEventData>();
  try {
    List<String> nodes = zookeeper.getChildren(path);
    for (String node : nodes) {
      RemedyIndexEventData data = RemedyIndexEventData.parseNodeName(node);
      data.setPipelineId(pipelineId);
      datas.add(data);
    }
  } catch (ZkException e) {
    throw new ArbitrateException("listRemedyIndexs", pipelineId.toString(), e);
  }
  Collections.sort(datas, new RemedyIndexComparator()); // 做一下排序
  return datas;
}

代码示例来源:origin: com.alibaba.otter/shared.arbitrate

private boolean initProcessStage(Long processId) {
  String path = null;
  try {
    // 1. 根据pipelineId+processId构造对应的path
    path = StagePathUtils.getProcess(getPipelineId(), processId);
    // 2. 获取当前的所有process列表
    List<String> currentStages = zookeeper.getChildren(path);
    return initProcessStage(processId, currentStages);
  } catch (ZkNoNodeException e) {
    // ignore,已经被termin处理
    return false;
  } catch (ZkException e) {
    return true;// 走到这一步代表已经出异常了,不需要监听
  }
}

代码示例来源:origin: com.alibaba.otter/shared.arbitrate

public NodeMonitor(){
  childListener = new IZkChildListener() {
    public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
      if (currentChilds != null) {
        initNodes(currentChilds);
      }
    }
  };
  List<String> childs = zookeeper.subscribeChildChanges(ArbitrateConstants.NODE_NID_ROOT, childListener);
  if (childs == null) {//如果为null,代表系统节点为初始化
    try {
      zookeeper.createPersistent(ArbitrateConstants.NODE_NID_ROOT, true);
    } catch (ZkNodeExistsException e) {
      //ignore 
    }
    childs = zookeeper.getChildren(ArbitrateConstants.NODE_NID_ROOT);
  }
  initNodes(childs);
  // syncNodes();// 开始监视node节点的变化
  MonitorScheduler.register(this);
}

代码示例来源:origin: com.alibaba.otter/shared.arbitrate

public void processChain(TerminEventData data) {
  // 关闭对应的服务
  Long pipelineId = data.getPipelineId();
  // 清理对应的process
  String processRoot = StagePathUtils.getProcessRoot(pipelineId);
  try {
    List<String> processNodes = zookeeper.getChildren(processRoot);
    // 3. 循环处理每个process
    List<Long> processIds = new ArrayList<Long>();
    for (String process : processNodes) {
      processIds.add(StagePathUtils.getProcessId(process));
    }
    Collections.sort(processIds); // 排序一下
    Long processId = data.getProcessId();
    if (processId != null) {// 可能为空
      normalTerminProcess.process(data);
    }
    for (Long currProcessId : processIds) {
      if (processId != null && currProcessId <= processId) {
        continue;
      }
      // 发送给最小的一个process的termin信号,进行链式的触发
      data.setProcessId(currProcessId);
      processChain(data); // 处理异常信息
      break;
    }
  } catch (ZkException e) {
    throw new ArbitrateException("Termin_process", e);
  }
}

代码示例来源:origin: com.alibaba.otter/shared.arbitrate

List<String> names = zookeeper.getChildren(root);
if (names.isEmpty()) {
  logger.warn("lock lost with scene:empty list, id[] and node[]", id, idName);

代码示例来源:origin: com.alibaba.otter/shared.arbitrate

List<String> processNodes = zookeeper.getChildren(processRoot);
List<Long> processIds = new ArrayList<Long>();
for (String processNode : processNodes) {

代码示例来源:origin: com.alibaba.otter/shared.arbitrate

currentStages = zookeeper.getChildren(StagePathUtils.getProcess(pipelineId, processId));
  Collections.sort(currentStages, new StageComparator());
} catch (ZkNoNodeException e) {

代码示例来源:origin: com.alibaba.otter/shared.arbitrate

List<String> currentProcesses = zookeeper.getChildren(path);
size = ArbitrateConfigUtils.getParallelism(getPipelineId()) - currentProcesses.size();
if (size > 0) {// 创建一个节点

代码示例来源:origin: com.alibaba.otter/shared.arbitrate

List<String> currentProcesses = zookeeper.getChildren(path);
size = ArbitrateConfigUtils.getParallelism(getPipelineId()) - currentProcesses.size();
if (size > 0) {// 创建一个节点

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