com.facebook.zookeeper.ZkUtil.bytesToString()方法的使用及代码示例

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

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

ZkUtil.bytesToString介绍

[英]Converts a byte array from ZooKeeper into a String.
[中]将ZooKeeper中的字节数组转换为字符串。

代码示例

代码示例来源:origin: facebook/jcommon

  1. public static String decode(byte[] byteData) {
  2. return ZkUtil.bytesToString(byteData);
  3. }
  4. }

代码示例来源:origin: facebook/jcommon

  1. private void printDetailed(String zNodePath)
  2. throws InterruptedException, KeeperException {
  3. Stat stat = new Stat();
  4. byte[] rawData = getZk().getData(zNodePath, null, stat);
  5. String data =
  6. (rawData == null) ? "<NULL>" : "'" + ZkUtil.bytesToString(rawData) + "'";
  7. System.out.print(String.format("%-40s ", zNodePath));
  8. System.out.print(String.format("Data: %-20s ", data));
  9. System.out.print(String.format("Data Length: %-5d ", stat.getDataLength()));
  10. System.out.print(String.format("NumChildren: %-5d ", stat.getNumChildren()));
  11. System.out.print(String.format("Children Changes: %-20d ", stat.getCversion()));
  12. System.out.print(String.format("Ephemeral Owner: %-20d ", stat.getEphemeralOwner()));
  13. System.out.print(String.format("Version: %-20d ", stat.getVersion()));
  14. System.out.print(String.format("Time Modified: %-20d ", stat.getMtime()));
  15. System.out.print(String.format("Time Created: %-20d", stat.getCtime()));
  16. System.out.print("\n");
  17. }

代码示例来源:origin: facebook/jcommon

  1. private void internalPrunePersistent(
  2. ZkGenericPath path, String keyword, Set<String> keepSet
  3. ) throws InterruptedException, KeeperException {
  4. if (isEphemeral(path.toString())) {
  5. // We should only be scanning persistent nodes (although we may delete
  6. // ephemeral nodes in order to remove a parent persistent node)
  7. return;
  8. }
  9. if (keepSet.contains(path.toString())) {
  10. try {
  11. ZooKeeperIface zk = getZk();
  12. byte[] data = zk.getData(path.toString(), false, null);
  13. if (data != null &&
  14. keyword.equals(ZkUtil.bytesToString(data))
  15. ) {
  16. zk.setData(path.toString(), new byte[0], -1);
  17. }
  18. List<String> children = zk.getChildren(path.toString(), null);
  19. for (String child : children) {
  20. internalPrunePersistent(path.appendChild(child), keyword, keepSet);
  21. }
  22. } catch (KeeperException.NoNodeException e) {
  23. // If the node disappears while scanning it, then just ignore
  24. }
  25. } else {
  26. deleteSubtree(path, keyword);
  27. }
  28. }

代码示例来源:origin: com.facebook.jcommon/zookeeper

  1. public static String decode(byte[] byteData) {
  2. return ZkUtil.bytesToString(byteData);
  3. }
  4. }

相关文章