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


Java NameNodeFile.IMAGE_ROLLBACK属性代码示例

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


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

示例1: purgeOldStorage

void purgeOldStorage(NameNodeFile nnf) throws IOException {
  FSImageTransactionalStorageInspector inspector =
      new FSImageTransactionalStorageInspector(EnumSet.of(nnf));
  storage.inspectStorageDirs(inspector);

  long minImageTxId = getImageTxIdToRetain(inspector);
  purgeCheckpointsOlderThan(inspector, minImageTxId);
  
  if (nnf == NameNodeFile.IMAGE_ROLLBACK) {
    // do not purge edits for IMAGE_ROLLBACK.
    return;
  }

  // If fsimage_N is the image we want to keep, then we need to keep
  // all txns > N. We can remove anything < N+1, since fsimage_N
  // reflects the state up to and including N. However, we also
  // provide a "cushion" of older txns that we keep, which is
  // handy for HA, where a remote node may not have as many
  // new images.
  //
  // First, determine the target number of extra transactions to retain based
  // on the configured amount.
  long minimumRequiredTxId = minImageTxId + 1;
  long purgeLogsFrom = Math.max(0, minimumRequiredTxId - numExtraEditsToRetain);
  
  ArrayList<EditLogInputStream> editLogs = new ArrayList<EditLogInputStream>();
  purgeableLogs.selectInputStreams(editLogs, purgeLogsFrom, false);
  Collections.sort(editLogs, new Comparator<EditLogInputStream>() {
    @Override
    public int compare(EditLogInputStream a, EditLogInputStream b) {
      return ComparisonChain.start()
          .compare(a.getFirstTxId(), b.getFirstTxId())
          .compare(a.getLastTxId(), b.getLastTxId())
          .result();
    }
  });

  // Remove from consideration any edit logs that are in fact required.
  while (editLogs.size() > 0 &&
      editLogs.get(editLogs.size() - 1).getFirstTxId() >= minimumRequiredTxId) {
    editLogs.remove(editLogs.size() - 1);
  }
  
  // Next, adjust the number of transactions to retain if doing so would mean
  // keeping too many segments around.
  while (editLogs.size() > maxExtraEditsSegmentsToRetain) {
    purgeLogsFrom = editLogs.get(0).getLastTxId() + 1;
    editLogs.remove(0);
  }
  
  // Finally, ensure that we're not trying to purge any transactions that we
  // actually need.
  if (purgeLogsFrom > minimumRequiredTxId) {
    throw new AssertionError("Should not purge more edits than required to "
        + "restore: " + purgeLogsFrom + " should be <= "
        + minimumRequiredTxId);
  }
  
  purgeableLogs.purgeLogsOlderThan(purgeLogsFrom);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:60,代码来源:NNStorageRetentionManager.java


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