gpt4 book ai didi

com.griddynamics.jagger.coordinator.zookeeper.ZNode.hasChild()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 12:27:37 26 4
gpt4 key购买 nike

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

ZNode.hasChild介绍

暂无

代码示例

代码示例来源:origin: griddynamics/jagger

@Override
public boolean isLockable() {
  return node.hasChild(lockPath);
}

代码示例来源:origin: griddynamics/jagger

@Override
public void waitForInitialization() {
  log.info("Waiting for coordination znode structure structure initialization");
  while (true) {
    boolean initialized = rootNode.exists() && rootNode.hasChild(CoordinationUtil.STATUSES_NODE_NAME);
    if (initialized) {
      log.info("Coordination znode structure initialized");
      break;
    }
    try {
      Thread.sleep(INITIALIZATION_SLEEP_PERIOD);
      log.info("Znode structure is not initialized. Waiting {} ms", INITIALIZATION_SLEEP_PERIOD);
    } catch (InterruptedException e) {
      log.warn("Sleep interrupted", e);
    }
  }
}

代码示例来源:origin: griddynamics/jagger

@Override
public Set<NodeId> getAvailableNodes(NodeType type) {
  Set<NodeId> result = Sets.newHashSet();
  ZNode typeNode = rootNode.child(CoordinationUtil.nodeNameOf(type));
  for (ZNode node : typeNode.children()) {
    if (node.hasChild(CoordinationUtil.AVAILABLE_NODE_NAME)) {
      result.add(NodeId.of(type, node.getShortPath()));
    }
  }
  return result;
}

代码示例来源:origin: griddynamics/jagger

@Override
public void initialize() {
  log.info("Going to initialize required znode structure in zookeeper");
  for (NodeType type : NodeType.values()) {
    String child = CoordinationUtil.nodeNameOf(type);
    if (!rootNode.hasChild(child)) {
      rootNode.createChild(znode().withPath(child));
      log.info("Created Zookeeper node {}", child);
    }
  }

  if (!rootNode.hasChild(CoordinationUtil.STATUSES_NODE_NAME)) {
    rootNode.createChild(znode().withPath(CoordinationUtil.STATUSES_NODE_NAME));
    log.info("Created Zookeeper node {}", CoordinationUtil.STATUSES_NODE_NAME);
  }
  log.info("Successfully initialized");
}

代码示例来源:origin: griddynamics/jagger

@Override
public boolean canExecuteCommands(NodeId nodeId, Set<Qualifier<?>> qualifiers) {
  ZNode typeNode = rootNode.child(CoordinationUtil.nodeNameOf(nodeId.getType()));
  String identifier = nodeId.getIdentifier();
  if (!typeNode.hasChild(identifier)) {
    throw new CoordinatorException("Node with id " + nodeId + " is not found");
  }
  ZNode node = typeNode.child(identifier);
  if (!node.hasChild(CoordinationUtil.AVAILABLE_NODE_NAME)) {
    return false;
  }
  for (Qualifier<?> qualifier : qualifiers) {
    if (!node.hasChild(nodeNameOf(qualifier))) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: griddynamics/jagger

boolean hasChild = lockDir().hasChild(nextNodePath, new Watcher() {
  @Override
  public void process(WatchedEvent event) {

代码示例来源:origin: griddynamics/jagger

public void initialize() {
  ZooKeeperFactory zooKeeperFactory = new ZooKeeperFactory();
  zooKeeperFactory.setConnectString(endpoint);
  zooKeeperFactory.setSessionTimeout(sessionTimeout);
  log.info("Connect to {} endpoint with timeout {}", endpoint, sessionTimeout);
  IZookeeper zooKeeper = null;
  try {
    zooKeeper = zooKeeperFactory.create();
    zoo = new Zoo(zooKeeperFactory.create());
    // TODO: timeout only 40000. svi.
    if (zoo.root().hasChild(rootNode)) {
      log.info("ZNode [" + rootNode + "] was found.");
      zoo.root().child(rootNode).removeWithChildren();
      log.info("ZNode [" + rootNode + "] with children nodes were removed.");
    }
    zoo.root().createChild(znode().withPath(rootNode));
    log.info("ZNode [" + rootNode + "] was created.");
  } finally {
    if (zooKeeper != null) {
      try {
        zooKeeper.close();
      } catch (InterruptedException e) {
        // do nothing
      }
    }
  }
}

代码示例来源:origin: griddynamics/jagger

if (typeNode.hasChild(nodeContext.getId().getIdentifier())) {
  typeNode.child(nodeContext.getId().getIdentifier()).removeWithChildren();

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