gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-13 12:35:29 26 4
gpt4 key购买 nike

本文整理了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

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

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

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

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

private void internalPrunePersistent(
 ZkGenericPath path, String keyword, Set<String> keepSet
) throws InterruptedException, KeeperException {
 if (isEphemeral(path.toString())) {
  // We should only be scanning persistent nodes (although we may delete
  // ephemeral nodes in order to remove a parent persistent node)
  return;
 }
 if (keepSet.contains(path.toString())) {
  try {
   ZooKeeperIface zk = getZk();
   byte[] data = zk.getData(path.toString(), false, null);
   if (data != null &&
    keyword.equals(ZkUtil.bytesToString(data))
    ) {
    zk.setData(path.toString(), new byte[0], -1);
   }
   List<String> children = zk.getChildren(path.toString(), null);
   for (String child : children) {
    internalPrunePersistent(path.appendChild(child), keyword, keepSet);
   }
  } catch (KeeperException.NoNodeException e) {
   // If the node disappears while scanning it, then just ignore
  }
 } else {
  deleteSubtree(path, keyword);
 }
}

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

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

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