gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-16 01:22:40 24 4
gpt4 key购买 nike

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

ZKUtil.getParent介绍

[英]Returns the full path of the immediate parent of the specified node.
[中]返回指定节点的直接父节点的完整路径。

代码示例

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

@Override
public void nodeDeleted(String path) {
 if (keysParentZNode.equals(ZKUtil.getParent(path))) {
  String keyId = ZKUtil.getNodeName(path);
  try {
   Integer id = Integer.valueOf(keyId);
   secretManager.removeKey(id);
  } catch (NumberFormatException nfe) {
   LOG.error("Invalid znode name for key ID '"+keyId+"'", nfe);
  }
 }
}

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

@Override
public void nodeDeleted(final String path) {
 waitUntilStarted();
 if (aclZNode.equals(ZKUtil.getParent(path))) {
  asyncProcessNodeUpdate(new Runnable() {
   @Override
   public void run() {
    String table = ZKUtil.getNodeName(path);
    if(AccessControlLists.isNamespaceEntry(table)) {
     authManager.removeNamespace(Bytes.toBytes(table));
    } else {
     authManager.removeTable(TableName.valueOf(table));
    }
   }
  });
 }
}

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

@Override
public void nodeDataChanged(final String path) {
 waitUntilStarted();
 if (aclZNode.equals(ZKUtil.getParent(path))) {
  asyncProcessNodeUpdate(new Runnable() {
   @Override
   public void run() {
    // update cache on an existing table node
    String entry = ZKUtil.getNodeName(path);
    try {
     byte[] data = ZKUtil.getDataAndWatch(watcher, path);
     refreshAuthManager(entry, data);
    } catch (KeeperException ke) {
     LOG.error("Error reading data from zookeeper for node " + entry, ke);
     // only option is to abort
     watcher.abort("ZooKeeper error getting data for node " + entry, ke);
    } catch (IOException ioe) {
     LOG.error("Error reading permissions writables", ioe);
    }
   }
  });
 }
}

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

@Override
public void nodeDataChanged(String path) {
 if (keysParentZNode.equals(ZKUtil.getParent(path))) {
  try {
   byte[] data = ZKUtil.getDataAndWatch(watcher, path);
   if (data == null || data.length == 0) {
    LOG.debug("Ignoring empty node "+path);
    return;
   }
   AuthenticationKey key = (AuthenticationKey)Writables.getWritable(data,
     new AuthenticationKey());
   secretManager.addKey(key);
  } catch (KeeperException ke) {
   LOG.error(HBaseMarkers.FATAL, "Error reading data from zookeeper", ke);
   watcher.abort("Error reading updated key znode "+path, ke);
  } catch (IOException ioe) {
   LOG.error(HBaseMarkers.FATAL, "Error reading key writables", ioe);
   watcher.abort("Error reading key writables from znode "+path, ioe);
  }
 }
}

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

@Override
public void nodeCreated(String path) {
 if (!isInProcedurePath(path)) {
  return;
 }
 LOG.info("Received created event:" + path);
 // if it is a simple start/end/abort then we just rewatch the node
 if (isAcquiredNode(path)) {
  waitForNewProcedures();
  return;
 } else if (isAbortNode(path)) {
  watchForAbortedProcedures();
  return;
 }
 String parent = ZKUtil.getParent(path);
 // if its the end barrier, the procedure can be completed
 if (isReachedNode(parent)) {
  receivedReachedGlobalBarrier(path);
  return;
 } else if (isAbortNode(parent)) {
  abort(path);
  return;
 } else if (isAcquiredNode(parent)) {
  startNewSubprocedure(path);
 } else {
  LOG.debug("Ignoring created notification for node:" + path);
 }
}

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

public void start() {
 try {
  watcher.registerListener(this);
  String parent = ZKUtil.getParent(leaderZNode);
  if (ZKUtil.checkExists(watcher, parent) < 0) {
   ZKUtil.createWithParents(watcher, parent);
  }
 } catch (KeeperException ke) {
  watcher.abort("Unhandled zk exception when starting", ke);
  candidate.stop("Unhandled zk exception starting up: "+ke.getMessage());
 }
}

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

/**
 * Creates the specified node and all parent nodes required for it to exist.  The creation of
 * parent znodes is not atomic with the leafe znode creation but the data is written atomically
 * when the leaf node is created.
 *
 * No watches are set and no errors are thrown if the node already exists.
 *
 * The nodes created are persistent and open access.
 *
 * @param zkw zk reference
 * @param znode path of node
 * @throws KeeperException if unexpected zookeeper exception
 */
public static void createWithParents(ZKWatcher zkw, String znode, byte[] data)
 throws KeeperException {
 try {
  if(znode == null) {
   return;
  }
  zkw.getRecoverableZooKeeper().create(znode, data, createACL(zkw, znode),
    CreateMode.PERSISTENT);
 } catch(KeeperException.NodeExistsException nee) {
  return;
 } catch(KeeperException.NoNodeException nne) {
  createWithParents(zkw, getParent(znode));
  createWithParents(zkw, znode, data);
 } catch(InterruptedException ie) {
  zkw.interruptedException(ie);
 }
}

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

if (isAcquiredPathNode(path)) {
 coordinator.memberAcquiredBarrier(ZKUtil.getNodeName(ZKUtil.getParent(path)),
  ZKUtil.getNodeName(path));
} else if (isReachedPathNode(path)) {
 String procName = ZKUtil.getNodeName(ZKUtil.getParent(path));
 String member = ZKUtil.getNodeName(path);

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

@Override
public void nodeDeleted(String path) {
 if (nsZNode.equals(ZKUtil.getParent(path))) {
  String nsName = ZKUtil.getNodeName(path);
  cache.remove(nsName);
 }
}

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

@Override
public void nodeDeleted(String path) {
 if (keysParentZNode.equals(ZKUtil.getParent(path))) {
  String keyId = ZKUtil.getNodeName(path);
  try {
   Integer id = Integer.valueOf(keyId);
   secretManager.removeKey(id);
  } catch (NumberFormatException nfe) {
   LOG.error("Invalid znode name for key ID '"+keyId+"'", nfe);
  }
 }
}

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

@Override
public void nodeDeleted(String path) {
 waitUntilStarted();
 if (aclZNode.equals(ZKUtil.getParent(path))) {
  String table = ZKUtil.getNodeName(path);
  if(AccessControlLists.isNamespaceEntry(table)) {
   authManager.removeNamespace(Bytes.toBytes(table));
  } else {
   authManager.removeTable(TableName.valueOf(table));
  }
 }
}

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

public void start() {
 try {
  watcher.registerListener(this);
  String parent = ZKUtil.getParent(leaderZNode);
  if (ZKUtil.checkExists(watcher, parent) < 0) {
   ZKUtil.createWithParents(watcher, parent);
  }
 } catch (KeeperException ke) {
  watcher.abort("Unhandled zk exception when starting", ke);
  candidate.stop("Unhandled zk exception starting up: "+ke.getMessage());
 }
}

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

public void start() {
 try {
  watcher.registerListener(this);
  String parent = ZKUtil.getParent(leaderZNode);
  if (ZKUtil.checkExists(watcher, parent) < 0) {
   ZKUtil.createWithParents(watcher, parent);
  }
 } catch (KeeperException ke) {
  watcher.abort("Unhandled zk exception when starting", ke);
  candidate.stop("Unhandled zk exception starting up: "+ke.getMessage());
 }
}

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

public void start() {
 try {
  watcher.registerListener(this);
  String parent = ZKUtil.getParent(leaderZNode);
  if (ZKUtil.checkExists(watcher, parent) < 0) {
   ZKUtil.createWithParents(watcher, parent);
  }
 } catch (KeeperException ke) {
  watcher.abort("Unhandled zk exception when starting", ke);
  candidate.stop("Unhandled zk exception starting up: "+ke.getMessage());
 }
}

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

@Override
public void nodeCreated(String path) {
 if (!isInProcedurePath(path)) {
  return;
 }
 LOG.info("Received created event:" + path);
 // if it is a simple start/end/abort then we just rewatch the node
 if (isAcquiredNode(path)) {
  waitForNewProcedures();
  return;
 } else if (isAbortNode(path)) {
  watchForAbortedProcedures();
  return;
 }
 String parent = ZKUtil.getParent(path);
 // if its the end barrier, the procedure can be completed
 if (isReachedNode(parent)) {
  receivedReachedGlobalBarrier(path);
  return;
 } else if (isAbortNode(parent)) {
  abort(path);
  return;
 } else if (isAcquiredNode(parent)) {
  startNewSubprocedure(path);
 } else {
  LOG.debug("Ignoring created notification for node:" + path);
 }
}

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

@Override
public void nodeDataChanged(String path) {
 if (nsZNode.equals(ZKUtil.getParent(path))) {
  try {
   byte[] data = ZKUtil.getDataAndWatch(watcher, path);
   NamespaceDescriptor ns =
     ProtobufUtil.toNamespaceDescriptor(
       HBaseProtos.NamespaceDescriptor.parseFrom(data));
   cache.put(ns.getName(), ns);
  } catch (KeeperException ke) {
   String msg = "Error reading data from zookeeper for node "+path;
   LOG.error(msg, ke);
   // only option is to abort
   watcher.abort(msg, ke);
  } catch (IOException ioe) {
   String msg = "Error deserializing namespace: "+path;
   LOG.error(msg, ioe);
   watcher.abort(msg, ioe);
  }
 }
}

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

@Override
public void nodeDataChanged(String path) {
 waitUntilStarted();
 if (aclZNode.equals(ZKUtil.getParent(path))) {
  // update cache on an existing table node
  String entry = ZKUtil.getNodeName(path);
  try {
   byte[] data = ZKUtil.getDataAndWatch(watcher, path);
   refreshAuthManager(entry, data);
  } catch (KeeperException ke) {
   LOG.error("Error reading data from zookeeper for node " + entry, ke);
   // only option is to abort
   watcher.abort("Zookeeper error getting data for node " + entry, ke);
  } catch (IOException ioe) {
   LOG.error("Error reading permissions writables", ioe);
  }
 }
}

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

@Override
 public void nodeCreated(String path) {
  if (!isInProcedurePath(path)) return;
  LOG.debug("Node created: " + path);
  logZKTree(this.baseZNode);
  if (isAcquiredPathNode(path)) {
   // node wasn't present when we created the watch so zk event triggers acquire
   coordinator.memberAcquiredBarrier(ZKUtil.getNodeName(ZKUtil.getParent(path)),
    ZKUtil.getNodeName(path));
  } else if (isReachedPathNode(path)) {
   // node was absent when we created the watch so zk event triggers the finished barrier.
   // TODO Nothing enforces that acquire and reached znodes from showing up in wrong order.
   coordinator.memberFinishedBarrier(ZKUtil.getNodeName(ZKUtil.getParent(path)),
    ZKUtil.getNodeName(path));
  } else if (isAbortPathNode(path)) {
   abort(path);
  }
 }
};

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

@Override
public void nodeDataChanged(String path) {
 if (keysParentZNode.equals(ZKUtil.getParent(path))) {
  try {
   byte[] data = ZKUtil.getDataAndWatch(watcher, path);
   if (data == null || data.length == 0) {
    LOG.debug("Ignoring empty node "+path);
    return;
   }
   AuthenticationKey key = (AuthenticationKey)Writables.getWritable(data,
     new AuthenticationKey());
   secretManager.addKey(key);
  } catch (KeeperException ke) {
   LOG.fatal("Error reading data from zookeeper", ke);
   watcher.abort("Error reading updated key znode "+path, ke);
  } catch (IOException ioe) {
   LOG.fatal("Error reading key writables", ioe);
   watcher.abort("Error reading key writables from znode "+path, ioe);
  }
 }
}

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

@Override
public void nodeCreated(String path) {
 if (!isInProcedurePath(path)) {
  return;
 }
 LOG.info("Received created event:" + path);
 // if it is a simple start/end/abort then we just rewatch the node
 if (isAcquiredNode(path)) {
  waitForNewProcedures();
  return;
 } else if (isAbortNode(path)) {
  watchForAbortedProcedures();
  return;
 }
 String parent = ZKUtil.getParent(path);
 // if its the end barrier, the procedure can be completed
 if (isReachedNode(parent)) {
  receivedReachedGlobalBarrier(path);
  return;
 } else if (isAbortNode(parent)) {
  abort(path);
  return;
 } else if (isAcquiredNode(parent)) {
  startNewSubprocedure(path);
 } else {
  LOG.debug("Ignoring created notification for node:" + path);
 }
}

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