MaxTxId.java 文件源码

java
阅读 38 收藏 0 点赞 0 评论 0

项目:hadoop 作者:
synchronized long get() throws IOException {
  try {
    currentStat = zkc.exists(path, false);
    if (currentStat == null) {
      return 0;
    } else {

      byte[] bytes = zkc.getData(path, false, currentStat);

      MaxTxIdProto.Builder builder = MaxTxIdProto.newBuilder();
      TextFormat.merge(new String(bytes, UTF_8), builder);
      if (!builder.isInitialized()) {
        throw new IOException("Invalid/Incomplete data in znode");
      }

      return builder.build().getTxId();
    }
  } catch (KeeperException e) {
    throw new IOException("Error reading the max tx id from zk", e);
  } catch (InterruptedException ie) {
    throw new IOException("Interrupted while reading thr max tx id", ie);
  }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号