当前位置: 首页>>代码示例>>Java>>正文


Java SegmentStateProto.getEndTxId方法代码示例

本文整理汇总了Java中org.apache.hadoop.hdfs.qjournal.protocol.QJournalProtocolProtos.SegmentStateProto.getEndTxId方法的典型用法代码示例。如果您正苦于以下问题:Java SegmentStateProto.getEndTxId方法的具体用法?Java SegmentStateProto.getEndTxId怎么用?Java SegmentStateProto.getEndTxId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hdfs.qjournal.protocol.QJournalProtocolProtos.SegmentStateProto的用法示例。


在下文中一共展示了SegmentStateProto.getEndTxId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compare

import org.apache.hadoop.hdfs.qjournal.protocol.QJournalProtocolProtos.SegmentStateProto; //导入方法依赖的package包/类
@Override
public int compare(
    Entry<AsyncLogger, PrepareRecoveryResponseProto> a,
    Entry<AsyncLogger, PrepareRecoveryResponseProto> b) {
  
  PrepareRecoveryResponseProto r1 = a.getValue();
  PrepareRecoveryResponseProto r2 = b.getValue();
  
  // A response that has data for a segment is always better than one
  // that doesn't.
  if (r1.hasSegmentState() != r2.hasSegmentState()) {
    return Booleans.compare(r1.hasSegmentState(), r2.hasSegmentState());
  }
  
  if (!r1.hasSegmentState()) {
    // Neither has a segment, so neither can be used for recover.
    // Call them equal.
    return 0;
  }
  
  // They both have a segment.
  SegmentStateProto r1Seg = r1.getSegmentState();
  SegmentStateProto r2Seg = r2.getSegmentState();
  
  Preconditions.checkArgument(r1Seg.getStartTxId() == r2Seg.getStartTxId(),
      "Should only be called with responses for corresponding segments: " +
      "%s and %s do not have the same start txid.", r1, r2);

  // If one is in-progress but the other is finalized,
  // the finalized one is greater.
  if (r1Seg.getIsInProgress() != r2Seg.getIsInProgress()) {
    return Booleans.compare(!r1Seg.getIsInProgress(), !r2Seg.getIsInProgress());
  }
  
  if (!r1Seg.getIsInProgress()) {
    // If both are finalized, they should match lengths
    if (r1Seg.getEndTxId() != r2Seg.getEndTxId()) {
      throw new AssertionError("finalized segs with different lengths: " + 
          r1 + ", " + r2);
    }
    return 0;
  }
  
  // Both are in-progress.
  long r1SeenEpoch = Math.max(r1.getAcceptedInEpoch(), r1.getLastWriterEpoch());
  long r2SeenEpoch = Math.max(r2.getAcceptedInEpoch(), r2.getLastWriterEpoch());
  
  return ComparisonChain.start()
      .compare(r1SeenEpoch, r2SeenEpoch)
      .compare(r1.getSegmentState().getEndTxId(), r2.getSegmentState().getEndTxId())
      .result();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:53,代码来源:SegmentRecoveryComparator.java

示例2: txnRange

import org.apache.hadoop.hdfs.qjournal.protocol.QJournalProtocolProtos.SegmentStateProto; //导入方法依赖的package包/类
private LongRange txnRange(SegmentStateProto seg) {
  Preconditions.checkArgument(seg.hasEndTxId(),
      "invalid segment: %s", seg);
  return new LongRange(seg.getStartTxId(), seg.getEndTxId());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:6,代码来源:Journal.java


注:本文中的org.apache.hadoop.hdfs.qjournal.protocol.QJournalProtocolProtos.SegmentStateProto.getEndTxId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。