gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-13 11:23:38 26 4
gpt4 key购买 nike

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

ZkClientx.exists介绍

暂无

代码示例

代码示例来源: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.common

public boolean exists(final String path) {
  return exists(path, hasListeners(path));
}

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

private void ensureExists(final String path) {
  try {
    if (zookeeper.exists(path)) {
      return;
    }
    zookeeper.create(path, data, CreateMode.PERSISTENT);
  } catch (ZkInterruptedException e) {
    Thread.currentThread().interrupt();
    interrupt = (InterruptedException) e.getCause();
  } catch (ZkException e) {
    exception = (KeeperException) e.getCause();
  }
}

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

@Override
  public void run() throws Exception {
    // reinstall watch
    exists(path, true);
    try {
      Object data = readData(path, null, true);
      listener.handleDataChange(path, data);
    } catch (ZkNoNodeException e) {
      listener.handleDataDeleted(path);
    }
  }
});

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

public boolean waitUntilExists(String path, TimeUnit timeUnit, long time) throws ZkInterruptedException {
  Date timeout = new Date(System.currentTimeMillis() + timeUnit.toMillis(time));
  LOG.debug("Waiting until znode '" + path + "' becomes available.");
  if (exists(path)) {
    return true;
  }
  acquireEventLock();
  try {
    while (!exists(path, true)) {
      boolean gotSignal = getEventLock().getZNodeEventCondition().awaitUntil(timeout);
      if (!gotSignal) {
        return false;
      }
    }
    return true;
  } catch (InterruptedException e) {
    throw new ZkInterruptedException(e);
  } finally {
    getEventLock().unlock();
  }
}

代码示例来源: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

public EtlEventData await(Long pipelineId) throws InterruptedException {
  Assert.notNull(pipelineId);
  PermitMonitor permitMonitor = ArbitrateFactory.getInstance(pipelineId, PermitMonitor.class);
  permitMonitor.waitForPermit();// 阻塞等待授权
  RpcStageController stageController = ArbitrateFactory.getInstance(pipelineId, RpcStageController.class);
  Long processId = stageController.waitForProcess(StageType.EXTRACT); // 符合条件的processId
  ChannelStatus status = permitMonitor.getChannelPermit();
  if (status.isStart() || status.isPause()) {// pause状态也让其处理,避免误删除pause状态的processId,导致通道挂起
    EtlEventData eventData = stageController.getLastData(processId);
    Node node = LoadBalanceFactory.getNextTransformNode(pipelineId);// 获取下一个处理节点信息
    if (node == null) {// 没有后端节点
      throw new ArbitrateException("Extract_single", "no next node");
    } else {
      eventData.setNextNid(node.getId());
      return eventData;// 只有这一条路返回
    }
  } else {
    logger.warn("pipelineId[{}] extract ignore processId[{}] by status[{}]", new Object[] { pipelineId,
        processId, status });
    String path = StagePathUtils.getProcess(pipelineId, processId);
    zookeeper.exists(path);
    return await(pipelineId);// 递归调用
  }
}

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

public EtlEventData await(Long pipelineId) throws InterruptedException {
  Assert.notNull(pipelineId);
  PermitMonitor permitMonitor = ArbitrateFactory.getInstance(pipelineId, PermitMonitor.class);
  permitMonitor.waitForPermit();// 阻塞等待授权
  RpcStageController stageController = ArbitrateFactory.getInstance(pipelineId, RpcStageController.class);
  Long processId = stageController.waitForProcess(StageType.LOAD); // 符合条件的processId
  ChannelStatus status = permitMonitor.getChannelPermit();
  if (status.isStart()) {// 即时查询一下当前的状态,状态随时可能会变
    return stageController.getLastData(processId);
  } else {
    // 需要进一步check,避免丢失load信号
    status = permitMonitor.getChannelPermit(true);
    if (status.isStart()) {
      return stageController.getLastData(processId);
    } else if (status.isPause()) {
      String path = StagePathUtils.getProcess(pipelineId, processId);
      if (zookeeper.exists(path)) { // 如果存在process,那说明没有被rollback掉(可能刚好在做rollback),这种运行进行load处理
        return stageController.getLastData(processId);
      }
    }
    logger.warn("pipelineId[{}] load ignore processId[{}] by status[{}]", new Object[] { pipelineId, processId,
        status });
    return await(pipelineId);// 递归调用
  }
}

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