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

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

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

ZKUtil.appendPeerState介绍

暂无

代码示例

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

private static void appendPeersZnodes(ZKWatcher zkw, String peersZnode,
                   StringBuilder sb) throws KeeperException {
 int pblen = ProtobufUtil.lengthOfPBMagic();
 sb.append("\n").append(peersZnode).append(": ");
 for (String peerIdZnode : ZKUtil.listChildrenNoWatch(zkw, peersZnode)) {
  String znodeToProcess = ZNodePaths.joinZNode(peersZnode, peerIdZnode);
  byte[] data;
  try {
   data = ZKUtil.getData(zkw, znodeToProcess);
  } catch (InterruptedException e) {
   zkw.interruptedException(e);
   return;
  }
  // parse the data of the above peer znode.
  try {
   ReplicationProtos.ReplicationPeer.Builder builder =
    ReplicationProtos.ReplicationPeer.newBuilder();
   ProtobufUtil.mergeFrom(builder, data, pblen, data.length - pblen);
   String clusterKey = builder.getClusterkey();
   sb.append("\n").append(znodeToProcess).append(": ").append(clusterKey);
   // add the peer-state.
   appendPeerState(zkw, znodeToProcess, sb);
  } catch (IOException ipbe) {
   LOG.warn("Got Exception while parsing peer: " + znodeToProcess, ipbe);
  }
 }
}

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

private static void appendPeersZnodes(ZKWatcher zkw, String peersZnode,
                   StringBuilder sb) throws KeeperException {
 int pblen = ProtobufUtil.lengthOfPBMagic();
 sb.append("\n").append(peersZnode).append(": ");
 for (String peerIdZnode : ZKUtil.listChildrenNoWatch(zkw, peersZnode)) {
  String znodeToProcess = ZNodePaths.joinZNode(peersZnode, peerIdZnode);
  byte[] data;
  try {
   data = ZKUtil.getData(zkw, znodeToProcess);
  } catch (InterruptedException e) {
   zkw.interruptedException(e);
   return;
  }
  // parse the data of the above peer znode.
  try {
   ReplicationProtos.ReplicationPeer.Builder builder =
    ReplicationProtos.ReplicationPeer.newBuilder();
   ProtobufUtil.mergeFrom(builder, data, pblen, data.length - pblen);
   String clusterKey = builder.getClusterkey();
   sb.append("\n").append(znodeToProcess).append(": ").append(clusterKey);
   // add the peer-state.
   appendPeerState(zkw, znodeToProcess, sb);
  } catch (IOException ipbe) {
   LOG.warn("Got Exception while parsing peer: " + znodeToProcess, ipbe);
  }
 }
}

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

private static void appendPeersZnodes(ZooKeeperWatcher zkw, String peersZnode,
 StringBuilder sb) throws KeeperException {
 int pblen = ProtobufUtil.lengthOfPBMagic();
 sb.append("\n").append(peersZnode).append(": ");
 for (String peerIdZnode : ZKUtil.listChildrenNoWatch(zkw, peersZnode)) {
  String znodeToProcess = ZKUtil.joinZNode(peersZnode, peerIdZnode);
  byte[] data;
  try {
   data = ZKUtil.getData(zkw, znodeToProcess);
  } catch (InterruptedException e) {
   zkw.interruptedException(e);
   return;
  }
  // parse the data of the above peer znode.
  try {
   ZooKeeperProtos.ReplicationPeer.Builder builder =
    ZooKeeperProtos.ReplicationPeer.newBuilder();
   ProtobufUtil.mergeFrom(builder, data, pblen, data.length - pblen);
   String clusterKey = builder.getClusterkey();
   sb.append("\n").append(znodeToProcess).append(": ").append(clusterKey);
   // add the peer-state.
   appendPeerState(zkw, znodeToProcess, sb);
  } catch (IOException ipbe) {
   LOG.warn("Got Exception while parsing peer: " + znodeToProcess, ipbe);
  }
 }
}

相关文章