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

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

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

ZKUtil.parseWALPositionFrom介绍

暂无

代码示例

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

  1. @Override
  2. public long getWALPosition(ServerName serverName, String queueId, String fileName)
  3. throws ReplicationException {
  4. byte[] bytes;
  5. try {
  6. bytes = ZKUtil.getData(zookeeper, getFileNode(serverName, queueId, fileName));
  7. } catch (KeeperException | InterruptedException e) {
  8. throw new ReplicationException("Failed to get log position (serverName=" + serverName +
  9. ", queueId=" + queueId + ", fileName=" + fileName + ")", e);
  10. }
  11. try {
  12. return ZKUtil.parseWALPositionFrom(bytes);
  13. } catch (DeserializationException de) {
  14. LOG.warn("Failed parse log position (serverName={}, queueId={}, fileName={})",
  15. serverName, queueId, fileName);
  16. }
  17. // if we can not parse the position, start at the beginning of the wal file again
  18. return 0;
  19. }

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

  1. private static void appendRSZnodes(ZKWatcher zkw, String znode, StringBuilder sb)
  2. throws KeeperException {
  3. List<String> stack = new LinkedList<>();
  4. stack.add(znode);
  5. do {
  6. String znodeToProcess = stack.remove(stack.size() - 1);
  7. sb.append("\n").append(znodeToProcess).append(": ");
  8. byte[] data;
  9. try {
  10. data = ZKUtil.getData(zkw, znodeToProcess);
  11. } catch (InterruptedException e) {
  12. zkw.interruptedException(e);
  13. return;
  14. }
  15. if (data != null && data.length > 0) { // log position
  16. long position = 0;
  17. try {
  18. position = ZKUtil.parseWALPositionFrom(ZKUtil.getData(zkw, znodeToProcess));
  19. sb.append(position);
  20. } catch (DeserializationException ignored) {
  21. } catch (InterruptedException e) {
  22. zkw.interruptedException(e);
  23. return;
  24. }
  25. }
  26. for (String zNodeChild : ZKUtil.listChildrenNoWatch(zkw, znodeToProcess)) {
  27. stack.add(ZNodePaths.joinZNode(znodeToProcess, zNodeChild));
  28. }
  29. } while (stack.size() > 0);
  30. }

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

  1. /**
  2. * Return the {lastPushedSequenceId, ZNodeDataVersion} pair. if ZNodeDataVersion is -1, it means
  3. * that the ZNode does not exist.
  4. */
  5. @VisibleForTesting
  6. protected Pair<Long, Integer> getLastSequenceIdWithVersion(String encodedRegionName,
  7. String peerId) throws KeeperException {
  8. Stat stat = new Stat();
  9. String path = getSerialReplicationRegionPeerNode(encodedRegionName, peerId);
  10. byte[] data = ZKUtil.getDataNoWatch(zookeeper, path, stat);
  11. if (data == null) {
  12. // ZNode does not exist, so just return version -1 to indicate that no node exist.
  13. return Pair.newPair(HConstants.NO_SEQNUM, -1);
  14. }
  15. try {
  16. return Pair.newPair(ZKUtil.parseWALPositionFrom(data), stat.getVersion());
  17. } catch (DeserializationException de) {
  18. LOG.warn("Failed to parse log position (region=" + encodedRegionName + ", peerId=" + peerId
  19. + "), data=" + Bytes.toStringBinary(data));
  20. }
  21. return Pair.newPair(HConstants.NO_SEQNUM, stat.getVersion());
  22. }

代码示例来源:origin: com.ngdata/hbase-sep-tools

  1. private long parseHLogPositionFrom(byte[] data) {
  2. try {
  3. return ZKUtil.parseWALPositionFrom(data);
  4. } catch (DeserializationException e) {
  5. throw new RuntimeException(e);
  6. }
  7. }

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

  1. /**
  2. * @param bytes - Content of a failed region server or recovering region znode.
  3. * @return long - The last flushed sequence Id for the region server
  4. */
  5. public static long parseLastFlushedSequenceIdFrom(final byte[] bytes) {
  6. long lastRecordedFlushedSequenceId = -1l;
  7. try {
  8. lastRecordedFlushedSequenceId = ZKUtil.parseWALPositionFrom(bytes);
  9. } catch (DeserializationException e) {
  10. lastRecordedFlushedSequenceId = -1l;
  11. LOG.warn("Can't parse last flushed sequence Id", e);
  12. }
  13. return lastRecordedFlushedSequenceId;
  14. }

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

  1. @Override
  2. public long getWALPosition(ServerName serverName, String queueId, String fileName)
  3. throws ReplicationException {
  4. byte[] bytes;
  5. try {
  6. bytes = ZKUtil.getData(zookeeper, getFileNode(serverName, queueId, fileName));
  7. } catch (KeeperException | InterruptedException e) {
  8. throw new ReplicationException("Failed to get log position (serverName=" + serverName +
  9. ", queueId=" + queueId + ", fileName=" + fileName + ")", e);
  10. }
  11. try {
  12. return ZKUtil.parseWALPositionFrom(bytes);
  13. } catch (DeserializationException de) {
  14. LOG.warn("Failed parse log position (serverName={}, queueId={}, fileName={})",
  15. serverName, queueId, fileName);
  16. }
  17. // if we can not parse the position, start at the beginning of the wal file again
  18. return 0;
  19. }

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

  1. private static void appendRSZnodes(ZooKeeperWatcher zkw, String znode, StringBuilder sb)
  2. throws KeeperException {
  3. List<String> stack = new LinkedList<String>();
  4. stack.add(znode);
  5. do {
  6. String znodeToProcess = stack.remove(stack.size() - 1);
  7. sb.append("\n").append(znodeToProcess).append(": ");
  8. byte[] data;
  9. try {
  10. data = ZKUtil.getData(zkw, znodeToProcess);
  11. } catch (InterruptedException e) {
  12. zkw.interruptedException(e);
  13. return;
  14. }
  15. if (data != null && data.length > 0) { // log position
  16. long position = 0;
  17. try {
  18. position = ZKUtil.parseWALPositionFrom(ZKUtil.getData(zkw, znodeToProcess));
  19. sb.append(position);
  20. } catch (DeserializationException ignored) {
  21. } catch (InterruptedException e) {
  22. zkw.interruptedException(e);
  23. return;
  24. }
  25. }
  26. for (String zNodeChild : ZKUtil.listChildrenNoWatch(zkw, znodeToProcess)) {
  27. stack.add(ZKUtil.joinZNode(znodeToProcess, zNodeChild));
  28. }
  29. } while (stack.size() > 0);
  30. }

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

  1. private static void appendRSZnodes(ZKWatcher zkw, String znode, StringBuilder sb)
  2. throws KeeperException {
  3. List<String> stack = new LinkedList<>();
  4. stack.add(znode);
  5. do {
  6. String znodeToProcess = stack.remove(stack.size() - 1);
  7. sb.append("\n").append(znodeToProcess).append(": ");
  8. byte[] data;
  9. try {
  10. data = ZKUtil.getData(zkw, znodeToProcess);
  11. } catch (InterruptedException e) {
  12. zkw.interruptedException(e);
  13. return;
  14. }
  15. if (data != null && data.length > 0) { // log position
  16. long position = 0;
  17. try {
  18. position = ZKUtil.parseWALPositionFrom(ZKUtil.getData(zkw, znodeToProcess));
  19. sb.append(position);
  20. } catch (DeserializationException ignored) {
  21. } catch (InterruptedException e) {
  22. zkw.interruptedException(e);
  23. return;
  24. }
  25. }
  26. for (String zNodeChild : ZKUtil.listChildrenNoWatch(zkw, znodeToProcess)) {
  27. stack.add(ZNodePaths.joinZNode(znodeToProcess, zNodeChild));
  28. }
  29. } while (stack.size() > 0);
  30. }

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

  1. @Override
  2. public long getLogPosition(String queueId, String filename) throws ReplicationException {
  3. String clusterZnode = ZKUtil.joinZNode(this.myQueuesZnode, queueId);
  4. String znode = ZKUtil.joinZNode(clusterZnode, filename);
  5. byte[] bytes = null;
  6. try {
  7. bytes = ZKUtil.getData(this.zookeeper, znode);
  8. } catch (KeeperException e) {
  9. throw new ReplicationException("Internal Error: could not get position in log for queueId="
  10. + queueId + ", filename=" + filename, e);
  11. } catch (InterruptedException e) {
  12. Thread.currentThread().interrupt();
  13. return 0;
  14. }
  15. try {
  16. return ZKUtil.parseWALPositionFrom(bytes);
  17. } catch (DeserializationException de) {
  18. LOG.warn("Failed to parse WALPosition for queueId=" + queueId + " and wal=" + filename
  19. + "znode content, continuing.");
  20. }
  21. // if we can not parse the position, start at the beginning of the wal file
  22. // again
  23. return 0;
  24. }

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

  1. /**
  2. * Return the {lastPushedSequenceId, ZNodeDataVersion} pair. if ZNodeDataVersion is -1, it means
  3. * that the ZNode does not exist.
  4. */
  5. @VisibleForTesting
  6. protected Pair<Long, Integer> getLastSequenceIdWithVersion(String encodedRegionName,
  7. String peerId) throws KeeperException {
  8. Stat stat = new Stat();
  9. String path = getSerialReplicationRegionPeerNode(encodedRegionName, peerId);
  10. byte[] data = ZKUtil.getDataNoWatch(zookeeper, path, stat);
  11. if (data == null) {
  12. // ZNode does not exist, so just return version -1 to indicate that no node exist.
  13. return Pair.newPair(HConstants.NO_SEQNUM, -1);
  14. }
  15. try {
  16. return Pair.newPair(ZKUtil.parseWALPositionFrom(data), stat.getVersion());
  17. } catch (DeserializationException de) {
  18. LOG.warn("Failed to parse log position (region=" + encodedRegionName + ", peerId=" + peerId
  19. + "), data=" + Bytes.toStringBinary(data));
  20. }
  21. return Pair.newPair(HConstants.NO_SEQNUM, stat.getVersion());
  22. }

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

  1. long position = 0;
  2. try {
  3. position = ZKUtil.parseWALPositionFrom(positionBytes);
  4. } catch (DeserializationException e) {
  5. LOG.warn("Failed parse of wal position from the following znode: " + z

相关文章