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

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

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

ZKUtil.getNodeName介绍

[英]Get the name of the current node from the specified fully-qualified path.
[中]从指定的完全限定路径获取当前节点的名称。

代码示例

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

  1. /**
  2. * Pass along the procedure global barrier notification to any listeners
  3. * @param path full znode path that cause the notification
  4. */
  5. private void receivedReachedGlobalBarrier(String path) {
  6. LOG.debug("Received reached global barrier:" + path);
  7. String procName = ZKUtil.getNodeName(path);
  8. this.member.receivedReachedGlobalBarrier(procName);
  9. }

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

  1. @Override
  2. public void nodeDeleted(String path) {
  3. if (keysParentZNode.equals(ZKUtil.getParent(path))) {
  4. String keyId = ZKUtil.getNodeName(path);
  5. try {
  6. Integer id = Integer.valueOf(keyId);
  7. secretManager.removeKey(id);
  8. } catch (NumberFormatException nfe) {
  9. LOG.error("Invalid znode name for key ID '"+keyId+"'", nfe);
  10. }
  11. }
  12. }

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

  1. @Override
  2. public void run() {
  3. // update cache on an existing table node
  4. String entry = ZKUtil.getNodeName(path);
  5. try {
  6. byte[] data = ZKUtil.getDataAndWatch(watcher, path);
  7. refreshAuthManager(entry, data);
  8. } catch (KeeperException ke) {
  9. LOG.error("Error reading data from zookeeper for node " + entry, ke);
  10. // only option is to abort
  11. watcher.abort("ZooKeeper error getting data for node " + entry, ke);
  12. } catch (IOException ioe) {
  13. LOG.error("Error reading permissions writables", ioe);
  14. }
  15. }
  16. });

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

  1. @Override
  2. public void nodeDeleted(final String path) {
  3. if(path.startsWith(watcher.getZNodePaths().drainingZNode)) {
  4. final ServerName sn = ServerName.valueOf(ZKUtil.getNodeName(path));
  5. LOG.info("Draining RS node deleted, removing from list [" +
  6. sn + "]");
  7. remove(sn);
  8. }
  9. }

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

  1. @Override
  2. public void run() {
  3. String table = ZKUtil.getNodeName(path);
  4. if(AccessControlLists.isNamespaceEntry(table)) {
  5. authManager.removeNamespace(Bytes.toBytes(table));
  6. } else {
  7. authManager.removeTable(TableName.valueOf(table));
  8. }
  9. }
  10. });

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

  1. private void add(final List<String> servers) throws IOException {
  2. synchronized(this.drainingServers) {
  3. this.drainingServers.clear();
  4. for (String n: servers) {
  5. final ServerName sn = ServerName.valueOf(ZKUtil.getNodeName(n));
  6. this.drainingServers.add(sn);
  7. this.serverManager.addServerToDrainList(sn);
  8. LOG.info("Draining RS node created, adding to list [" +
  9. sn + "]");
  10. }
  11. }
  12. }

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

  1. @Override
  2. public void nodeDeleted(String path) {
  3. if (!path.startsWith(archiveHFileZNode)) return;
  4. LOG.debug("Archive node: " + path + " deleted");
  5. String table = path.substring(archiveHFileZNode.length());
  6. // if we stop archiving all tables
  7. if (table.length() == 0) {
  8. // make sure we have the tracker before deleting the archive
  9. // but if we don't, we don't care about delete
  10. clearTables();
  11. // watches are one-time events, so we need to renew our subscription to
  12. // the archive node and might as well check to make sure archiving
  13. // didn't come back on at the same time
  14. checkEnabledAndUpdate();
  15. return;
  16. }
  17. // just stop archiving one table
  18. // note that we don't attempt to add another watch for that table into zk.
  19. // We have no assurances that the table will be archived again (or even
  20. // exists for that matter), so its better not to add unnecessary load to
  21. // zk for watches. If the table is created again, then we will get the
  22. // notification in childrenChanaged.
  23. getMonitor().removeTable(ZKUtil.getNodeName(path));
  24. }

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

  1. private void refreshNodes(List<ZKUtil.NodeAndData> nodes) {
  2. for (ZKUtil.NodeAndData n : nodes) {
  3. if (Thread.interrupted()) {
  4. // Use Thread.interrupted so that we clear interrupt status
  5. break;
  6. }
  7. if (n.isEmpty()) continue;
  8. String path = n.getNode();
  9. String entry = (ZKUtil.getNodeName(path));
  10. try {
  11. refreshAuthManager(entry, n.getData());
  12. } catch (IOException ioe) {
  13. LOG.error("Failed parsing permissions for table '" + entry +
  14. "' from zk", ioe);
  15. }
  16. }
  17. }

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

  1. /**
  2. * Stop tracking a table. Ensures that the table doesn't exist, but if it does, it attempts to add
  3. * the table back via {@link #addAndReWatchTable(String)} - its a 'safe' removal.
  4. * @param tableZnode full zookeeper path to the table to be added
  5. * @throws KeeperException if an unexpected zk exception occurs
  6. */
  7. private void safeStopTrackingTable(String tableZnode) throws KeeperException {
  8. getMonitor().removeTable(ZKUtil.getNodeName(tableZnode));
  9. // if the table exists, then add and rewatch it
  10. if (ZKUtil.checkExists(watcher, tableZnode) >= 0) {
  11. addAndReWatchTable(tableZnode);
  12. }
  13. }

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

  1. /**
  2. * Add this table to the tracker and then read a watch on that node.
  3. * <p>
  4. * Handles situation where table is deleted in the time between the update and resetting the watch
  5. * by deleting the table via {@link #safeStopTrackingTable(String)}
  6. * @param tableZnode full zookeeper path to the table to be added
  7. * @throws KeeperException if an unexpected zk exception occurs
  8. */
  9. private void addAndReWatchTable(String tableZnode) throws KeeperException {
  10. getMonitor().addTable(ZKUtil.getNodeName(tableZnode));
  11. // re-add a watch to the table created
  12. // and check to make sure it wasn't deleted
  13. if (!ZKUtil.watchAndCheckExists(watcher, tableZnode)) {
  14. safeStopTrackingTable(tableZnode);
  15. }
  16. }

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

  1. private void refreshNodes(List<ZKUtil.NodeAndData> nodes) {
  2. for (ZKUtil.NodeAndData n : nodes) {
  3. String path = n.getNode();
  4. String keyId = ZKUtil.getNodeName(path);
  5. try {
  6. byte[] data = n.getData();
  7. if (data == null || data.length == 0) {
  8. LOG.debug("Ignoring empty node "+path);
  9. continue;
  10. }
  11. AuthenticationKey key = (AuthenticationKey)Writables.getWritable(
  12. data, new AuthenticationKey());
  13. secretManager.addKey(key);
  14. } catch (IOException ioe) {
  15. LOG.error(HBaseMarkers.FATAL, "Failed reading new secret key for id '" +
  16. keyId + "' from zk", ioe);
  17. watcher.abort("Error deserializing key from znode "+path, ioe);
  18. }
  19. }
  20. }

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

  1. String opName = ZKUtil.getNodeName(abortZNode);
  2. try {
  3. byte[] data = ZKUtil.getData(zkController.getWatcher(), abortZNode);

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

  1. String procName = ZKUtil.getNodeName(abortNode);
  2. ForeignException ee = null;
  3. try {

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

  1. if (isAcquiredPathNode(path)) {
  2. coordinator.memberAcquiredBarrier(ZKUtil.getNodeName(ZKUtil.getParent(path)),
  3. ZKUtil.getNodeName(path));
  4. } else if (isReachedPathNode(path)) {
  5. String procName = ZKUtil.getNodeName(ZKUtil.getParent(path));
  6. String member = ZKUtil.getNodeName(path);

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

  1. String opName = ZKUtil.getNodeName(path);

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

  1. @Override
  2. public void nodeDeleted(String path) {
  3. if (nsZNode.equals(ZKUtil.getParent(path))) {
  4. String nsName = ZKUtil.getNodeName(path);
  5. cache.remove(nsName);
  6. }
  7. }

代码示例来源:origin: co.cask.hbase/hbase

  1. @Override
  2. public void nodeDeleted(final String path) {
  3. if(path.startsWith(watcher.drainingZNode)) {
  4. final ServerName sn = new ServerName(ZKUtil.getNodeName(path));
  5. LOG.info("Draining RS node deleted, removing from list [" +
  6. sn + "]");
  7. remove(sn);
  8. }
  9. }

代码示例来源:origin: co.cask.hbase/hbase

  1. private void add(final List<String> servers) throws IOException {
  2. synchronized(this.regionServers) {
  3. this.regionServers.clear();
  4. for (String n: servers) {
  5. ServerName sn = ServerName.parseServerName(ZKUtil.getNodeName(n));
  6. this.regionServers.add(sn);
  7. }
  8. }
  9. }

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

  1. /**
  2. * Pass along the procedure global barrier notification to any listeners
  3. * @param path full znode path that cause the notification
  4. */
  5. private void receivedReachedGlobalBarrier(String path) {
  6. LOG.debug("Recieved reached global barrier:" + path);
  7. String procName = ZKUtil.getNodeName(path);
  8. this.member.receivedReachedGlobalBarrier(procName);
  9. }

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

  1. @Override
  2. public void nodeDeleted(final String path) {
  3. if(path.startsWith(watcher.drainingZNode)) {
  4. final ServerName sn = ServerName.valueOf(ZKUtil.getNodeName(path));
  5. LOG.info("Draining RS node deleted, removing from list [" +
  6. sn + "]");
  7. remove(sn);
  8. }
  9. }

相关文章