org.linkedin.zookeeper.client.ZKData.<init>()方法的使用及代码示例

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

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

ZKData.<init>介绍

[英]Constructor
[中]建造师

代码示例

代码示例来源:origin: org.pongasoft/org.linkedin.zookeeper-impl

/**
 * Returns both the data as a byte[] as well as the stat (and sets a watcher if not null)
 */
@Override
public ZKData<byte[]> getZKByteData(String path, Watcher watcher)
 throws InterruptedException, KeeperException
{
 Stat stat = new Stat();
 return new ZKData<byte[]>(getData(path, watcher, stat), stat);
}

代码示例来源:origin: org.fusesource.insight/insight-graph

@Override
public ZKData<OutputWriter> readData(org.linkedin.zookeeper.client.IZKClient zkClient, String path, Watcher watcher) throws InterruptedException, KeeperException {
  Stat stat = new Stat();
  Unmarshaller<OutputWriter> unmarshaller = null;
  if (path.endsWith(".json")) {
    unmarshaller = new JsonUnmarshaller<OutputWriter>(OutputWriter.class);
  } else if (path.endsWith(".properties")) {
    unmarshaller = new PropertiesObjectWriterUnmarshaller();
  } else {
    LOG.debug("Ignoring ZK Path: " + path + " as it doesn't end in .json");
    return new ZKData<OutputWriter>(null, stat);
  }
  LOG.info("Reading ZK path: " + path + " and converting to an OutputWriter");
  byte[] data = zkClient.getData(path, watcher, stat);
  try {
    OutputWriter outputWriter = unmarshaller.unmarshal(path, data);
    if (outputWriter != null) {
      configureWriter(outputWriter);
      outputWriter.start();
    }
    return new ZKData<OutputWriter>(outputWriter, stat);
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: org.pongasoft/org.linkedin.zookeeper-impl

/**
 * Returns both the data as a string as well as the stat (and sets a watcher if not null)
 */
@Override
public ZKData<String> getZKStringData(String path, Watcher watcher)
 throws InterruptedException, KeeperException
{
 ZKData<byte[]> zkData = getZKByteData(path, watcher);
 return new ZKData<String>(toStringData(zkData.getData()), zkData.getStat());
}

相关文章