gpt4 book ai didi

com.facebook.zookeeper.ZkUtil类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 12:36:42 27 4
gpt4 key购买 nike

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

ZkUtil介绍

暂无

代码示例

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

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

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

@Override
public byte[] encode() {
 return ZkUtil.stringToBytes(strData);
}

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

public List<String> filterByBaseName(List<String> nodes) {
  return ZkUtil.filterByPrefix(nodes, baseCandidateName + NAME_DELIM);
 }
}

代码示例来源: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

ZkUtil.stringToBytes(keyword),
 -1
);

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

private String findMyEphemeralSequentialNode(String path)
 throws KeeperException, InterruptedException {
 int lastSlashIdx = path.lastIndexOf('/');
 assert(lastSlashIdx != -1);
 String parent = path.substring(0, lastSlashIdx);
 String nodePrefix = path.substring(lastSlashIdx+1);
 List<String> nodes = zk.getChildren(parent, false);
 List<String> matching = ZkUtil.filterByPrefix(nodes, nodePrefix);
 for (String node : matching) {
  String nodePath = parent + "/" + node;
  Stat stat = zk.exists(nodePath, false);
  if (stat != null && stat.getEphemeralOwner() == zk.getSessionId()) {
   return nodePath;
  }
 }
 return null;
}

代码示例来源: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

@Override
public byte[] encode() {
 return ZkUtil.stringToBytes(strData);
}

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

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

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