org.apache.hadoop.hbase.zookeeper.ZKUtil#NodeAndData ( )源码实例Demo

下面列出了org.apache.hadoop.hbase.zookeeper.ZKUtil#NodeAndData ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hbase   文件: ZKSecretWatcher.java
private void refreshNodes(List<ZKUtil.NodeAndData> nodes) {
  for (ZKUtil.NodeAndData n : nodes) {
    String path = n.getNode();
    String keyId = ZKUtil.getNodeName(path);
    try {
      byte[] data = n.getData();
      if (data == null || data.length == 0) {
        LOG.debug("Ignoring empty node "+path);
        continue;
      }
      AuthenticationKey key = (AuthenticationKey)Writables.getWritable(
          data, new AuthenticationKey());
      secretManager.addKey(key);
    } catch (IOException ioe) {
      LOG.error(HBaseMarkers.FATAL, "Failed reading new secret key for id '" +
          keyId + "' from zk", ioe);
      watcher.abort("Error deserializing key from znode "+path, ioe);
    }
  }
}
 
源代码2 项目: hbase   文件: ZKPermissionWatcher.java
private void refreshNodes(List<ZKUtil.NodeAndData> nodes) {
  for (ZKUtil.NodeAndData n : nodes) {
    if (Thread.interrupted()) {
      // Use Thread.interrupted so that we clear interrupt status
      break;
    }
    if (n.isEmpty()) continue;
    String path = n.getNode();
    String entry = (ZKUtil.getNodeName(path));
    try {
      refreshAuthManager(entry, n.getData());
    } catch (IOException ioe) {
      LOG.error("Failed parsing permissions for table '" + entry +
          "' from zk", ioe);
    }
  }
}
 
源代码3 项目: hbase   文件: ZKSecretWatcher.java
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);
  }
}
 
源代码4 项目: hbase   文件: ZKSecretWatcher.java
@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);
    }
  }
}
 
源代码5 项目: hbase   文件: ZKSecretWatcher.java
@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);
    }
  }
}
 
源代码6 项目: hbase   文件: ZKSecretWatcher.java
/**
 * 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);
  }
}