org.apache.hadoop.hbase.zookeeper.ZKUtil.getChildDataAndWatchForNewChildren()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(81)

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

ZKUtil.getChildDataAndWatchForNewChildren介绍

[英]Returns the date of child znodes of the specified znode. Also sets a watch on the specified znode which will capture a NodeDeleted event on the specified znode as well as NodeChildrenChanged if any children of the specified znode are created or deleted. Returns null if the specified node does not exist. Otherwise returns a list of children of the specified node. If the node exists but it has no children, an empty list will be returned.
[中]返回指定znode的子znode的日期。还将在指定的znode上设置一个监视,该监视将捕获指定znode上的NodeDeleted事件,以及如果创建或删除指定znode的任何子节点,NodeChildrenChanged。如果指定的节点不存在,则返回null。否则返回指定节点的子节点列表。如果节点存在但没有子节点,则返回空列表。

代码示例

代码示例来源:origin: apache/hbase

@Override
 public Void call() throws KeeperException {
  List<ZKUtil.NodeAndData> existing =
    ZKUtil.getChildDataAndWatchForNewChildren(watcher, aclZNode);
  if (existing != null) {
   refreshNodes(existing);
  }
  return null;
 }
}).get();

代码示例来源:origin: apache/hbase

@Override
 public void run() {
  try {
   List<ZKUtil.NodeAndData> nodes =
     ZKUtil.getChildDataAndWatchForNewChildren(watcher, aclZNode);
   refreshNodes(nodes);
  } catch (KeeperException ke) {
   LOG.error("Error reading data from zookeeper", ke);
   // only option is to abort
   watcher.abort("ZooKeeper error obtaining acl node children", ke);
  }
 }
});

代码示例来源:origin: apache/hbase

@Override
public void nodeCreated(String path) {
 if (path.equals(keysParentZNode)) {
  try {
   List<ZKUtil.NodeAndData> nodes =
     ZKUtil.getChildDataAndWatchForNewChildren(watcher, keysParentZNode);
   refreshNodes(nodes);
  } catch (KeeperException ke) {
   LOG.error(HBaseMarkers.FATAL, "Error reading data from zookeeper", ke);
   watcher.abort("Error reading new key znode "+path, ke);
  }
 }
}

代码示例来源:origin: apache/hbase

@Override
public void nodeChildrenChanged(String path) {
 if (path.equals(keysParentZNode)) {
  // keys changed
  try {
   List<ZKUtil.NodeAndData> nodes =
     ZKUtil.getChildDataAndWatchForNewChildren(watcher, keysParentZNode);
   refreshNodes(nodes);
  } catch (KeeperException ke) {
   LOG.error(HBaseMarkers.FATAL, "Error reading data from zookeeper", ke);
   watcher.abort("Error reading changed keys from zookeeper", ke);
  }
 }
}

代码示例来源:origin: apache/hbase

/**
 * refresh keys
 */
synchronized void refreshKeys() {
 try {
  List<ZKUtil.NodeAndData> nodes =
    ZKUtil.getChildDataAndWatchForNewChildren(watcher, keysParentZNode);
  refreshNodes(nodes);
 } catch (KeeperException ke) {
  LOG.error(HBaseMarkers.FATAL, "Error reading data from zookeeper", ke);
  watcher.abort("Error reading changed keys from zookeeper", ke);
 }
}

代码示例来源:origin: apache/hbase

@Override
public void nodeChildrenChanged(final String path) {
 waitUntilStarted();
 if (path.equals(aclZNode)) {
  try {
   final List<ZKUtil.NodeAndData> nodeList =
     ZKUtil.getChildDataAndWatchForNewChildren(watcher, aclZNode);
   // preempt any existing nodeChildrenChanged event processing
   if (childrenChangedFuture != null && !childrenChangedFuture.isDone()) {
    boolean cancelled = childrenChangedFuture.cancel(true);
    if (!cancelled) {
     // task may have finished between our check and attempted cancel, this is fine.
     if (! childrenChangedFuture.isDone()) {
      LOG.warn("Could not cancel processing node children changed event, " +
        "please file a JIRA and attach logs if possible.");
     }
    }
   }
   childrenChangedFuture = asyncProcessNodeUpdate(() -> refreshNodes(nodeList));
  } catch (KeeperException ke) {
   LOG.error("Error reading data from zookeeper for path "+path, ke);
   watcher.abort("ZooKeeper error get node children for path "+path, ke);
  }
 }
}

代码示例来源:origin: apache/hbase

/**
 * Test should not fail with NPE when getChildDataAndWatchForNewChildren invoked with wrongNode
 */
@Test
@SuppressWarnings("deprecation")
public void testGetChildDataAndWatchForNewChildrenShouldNotThrowNPE() throws Exception {
 ZKUtil.getChildDataAndWatchForNewChildren(ZKW, "/wrongNode");
}

代码示例来源:origin: apache/hbase

public void start() throws KeeperException {
 watcher.registerListener(this);
 // make sure the base node exists
 ZKUtil.createWithParents(watcher, keysParentZNode);
 if (ZKUtil.watchAndCheckExists(watcher, keysParentZNode)) {
  List<ZKUtil.NodeAndData> nodes =
    ZKUtil.getChildDataAndWatchForNewChildren(watcher, keysParentZNode);
  refreshNodes(nodes);
 }
}

代码示例来源:origin: harbby/presto-connectors

@Override
public void nodeCreated(String path) {
 if (path.equals(keysParentZNode)) {
  try {
   List<ZKUtil.NodeAndData> nodes =
     ZKUtil.getChildDataAndWatchForNewChildren(watcher, keysParentZNode);
   refreshNodes(nodes);
  } catch (KeeperException ke) {
   LOG.fatal("Error reading data from zookeeper", ke);
   watcher.abort("Error reading new key znode "+path, ke);
  }
 }
}

代码示例来源:origin: harbby/presto-connectors

public void start() throws KeeperException {
 try {
  watcher.registerListener(this);
  if (ZKUtil.watchAndCheckExists(watcher, aclZNode)) {
   List<ZKUtil.NodeAndData> existing =
     ZKUtil.getChildDataAndWatchForNewChildren(watcher, aclZNode);
   if (existing != null) {
    refreshNodes(existing);
   }
  }
 } finally {
  initialized.countDown();
 }
}

代码示例来源:origin: harbby/presto-connectors

@Override
public void nodeChildrenChanged(String path) {
 if (path.equals(keysParentZNode)) {
  // keys changed
  try {
   List<ZKUtil.NodeAndData> nodes =
     ZKUtil.getChildDataAndWatchForNewChildren(watcher, keysParentZNode);
   refreshNodes(nodes);
  } catch (KeeperException ke) {
   LOG.fatal("Error reading data from zookeeper", ke);
   watcher.abort("Error reading changed keys from zookeeper", ke);
  }
 }
}

代码示例来源:origin: org.apache.hbase/hbase-zookeeper

/**
 * Test should not fail with NPE when getChildDataAndWatchForNewChildren invoked with wrongNode
 */
@Test
@SuppressWarnings("deprecation")
public void testGetChildDataAndWatchForNewChildrenShouldNotThrowNPE() throws Exception {
 ZKUtil.getChildDataAndWatchForNewChildren(ZKW, "/wrongNode");
}

代码示例来源:origin: com.aliyun.hbase/alihbase-zookeeper

/**
 * Test should not fail with NPE when getChildDataAndWatchForNewChildren invoked with wrongNode
 */
@Test
@SuppressWarnings("deprecation")
public void testGetChildDataAndWatchForNewChildrenShouldNotThrowNPE() throws Exception {
 ZKUtil.getChildDataAndWatchForNewChildren(ZKW, "/wrongNode");
}

代码示例来源:origin: harbby/presto-connectors

/**
 * refresh keys
 */
synchronized void refreshKeys() {
 try {
  List<ZKUtil.NodeAndData> nodes =
    ZKUtil.getChildDataAndWatchForNewChildren(watcher, keysParentZNode);
  refreshNodes(nodes);
 } catch (KeeperException ke) {
  LOG.fatal("Error reading data from zookeeper", ke);
  watcher.abort("Error reading changed keys from zookeeper", ke);
 }
}

代码示例来源:origin: harbby/presto-connectors

@Override
public void nodeCreated(String path) {
 waitUntilStarted();
 if (path.equals(aclZNode)) {
  try {
   List<ZKUtil.NodeAndData> nodes =
     ZKUtil.getChildDataAndWatchForNewChildren(watcher, aclZNode);
   refreshNodes(nodes);
  } catch (KeeperException ke) {
   LOG.error("Error reading data from zookeeper", ke);
   // only option is to abort
   watcher.abort("Zookeeper error obtaining acl node children", ke);
  }
 }
}

代码示例来源:origin: harbby/presto-connectors

@Override
public void nodeChildrenChanged(String path) {
 waitUntilStarted();
 if (path.equals(aclZNode)) {
  // table permissions changed
  try {
   List<ZKUtil.NodeAndData> nodes =
     ZKUtil.getChildDataAndWatchForNewChildren(watcher, aclZNode);
   refreshNodes(nodes);
  } catch (KeeperException ke) {
   LOG.error("Error reading data from zookeeper for path "+path, ke);
   watcher.abort("Zookeeper error get node children for path "+path, ke);
  }
 }
}

代码示例来源:origin: harbby/presto-connectors

public void start() throws IOException {
 watcher.registerListener(this);
 try {
  if (ZKUtil.watchAndCheckExists(watcher, nsZNode)) {
   List<ZKUtil.NodeAndData> existing =
     ZKUtil.getChildDataAndWatchForNewChildren(watcher, nsZNode);
   if (existing != null) {
    refreshNodes(existing);
   }
  } else {
   ZKUtil.createWithParents(watcher, nsZNode);
  }
 } catch (KeeperException e) {
  throw new IOException("Failed to initialize ZKNamespaceManager", e);
 }
}

代码示例来源:origin: harbby/presto-connectors

public void start() throws KeeperException {
 watcher.registerListener(this);
 // make sure the base node exists
 ZKUtil.createWithParents(watcher, keysParentZNode);
 if (ZKUtil.watchAndCheckExists(watcher, keysParentZNode)) {
  List<ZKUtil.NodeAndData> nodes =
    ZKUtil.getChildDataAndWatchForNewChildren(watcher, keysParentZNode);
  refreshNodes(nodes);
 }
}

代码示例来源:origin: harbby/presto-connectors

@Override
public void nodeChildrenChanged(String path) {
 if (nsZNode.equals(path)) {
  try {
   List<ZKUtil.NodeAndData> nodes =
     ZKUtil.getChildDataAndWatchForNewChildren(watcher, nsZNode);
   refreshNodes(nodes);
  } catch (KeeperException ke) {
   LOG.error("Error reading data from zookeeper for path "+path, ke);
   watcher.abort("Zookeeper error get node children for path "+path, ke);
  } catch (IOException e) {
   LOG.error("Error deserializing namespace child from: "+path, e);
   watcher.abort("Error deserializing namespace child from: " + path, e);
  }
 }
}

代码示例来源:origin: harbby/presto-connectors

@Override
public void nodeCreated(String path) {
 if (nsZNode.equals(path)) {
  try {
   List<ZKUtil.NodeAndData> nodes =
     ZKUtil.getChildDataAndWatchForNewChildren(watcher, nsZNode);
   refreshNodes(nodes);
  } catch (KeeperException ke) {
   String msg = "Error reading data from zookeeper";
   LOG.error(msg, ke);
   watcher.abort(msg, ke);
  } catch (IOException e) {
   String msg = "Error parsing data from zookeeper";
   LOG.error(msg, e);
   watcher.abort(msg, e);
  }
 }
}

相关文章

微信公众号

最新文章

更多