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


Java DistributedFileSystem.getSnapshotDiffReport方法代码示例

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


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

示例1: checkNoChange

import org.apache.hadoop.hdfs.DistributedFileSystem; //导入方法依赖的package包/类
/**
 * Compute the snapshot diff on the given file system. Return true if the diff
 * is empty, i.e., no changes have happened in the FS.
 */
private static boolean checkNoChange(DistCpOptions inputOptions,
    DistributedFileSystem fs, Path path) {
  try {
    SnapshotDiffReport targetDiff =
        fs.getSnapshotDiffReport(path, inputOptions.getFromSnapshot(), "");
    if (!targetDiff.getDiffList().isEmpty()) {
      DistCp.LOG.warn("The target has been modified since snapshot "
          + inputOptions.getFromSnapshot());
      return false;
    } else {
      return true;
    }
  } catch (IOException e) {
    DistCp.LOG.warn("Failed to compute snapshot diff on " + path, e);
  }
  return false;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:DistCpSync.java

示例2: run

import org.apache.hadoop.hdfs.DistributedFileSystem; //导入方法依赖的package包/类
@Override
public int run(String[] argv) throws Exception {
  String description = "hdfs snapshotDiff <snapshotDir> <from> <to>:\n" +
  "\tGet the difference between two snapshots, \n" + 
  "\tor between a snapshot and the current tree of a directory.\n" +
  "\tFor <from>/<to>, users can use \".\" to present the current status,\n" +
  "\tand use \".snapshot/snapshot_name\" to present a snapshot,\n" +
  "\twhere \".snapshot/\" can be omitted\n";
  
  if(argv.length != 3) {
    System.err.println("Usage: \n" + description);
    return 1;
  }
  
  FileSystem fs = FileSystem.get(getConf());
  if (! (fs instanceof DistributedFileSystem)) {
    System.err.println(
        "SnapshotDiff can only be used in DistributedFileSystem");
    return 1;
  }
  DistributedFileSystem dfs = (DistributedFileSystem) fs;
  
  Path snapshotRoot = new Path(argv[0]);
  String fromSnapshot = getSnapshotName(argv[1]);
  String toSnapshot = getSnapshotName(argv[2]);
  try {
    SnapshotDiffReport diffReport = dfs.getSnapshotDiffReport(snapshotRoot,
        fromSnapshot, toSnapshot);
    System.out.println(diffReport.toString());
  } catch (IOException e) {
    String[] content = e.getLocalizedMessage().split("\n");
    System.err.println("snapshotDiff: " + content[0]);
    return 1;
  }
  return 0;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:37,代码来源:SnapshotDiff.java

示例3: getDiffs

import org.apache.hadoop.hdfs.DistributedFileSystem; //导入方法依赖的package包/类
@VisibleForTesting
static DiffInfo[] getDiffs(DistCpOptions inputOptions,
    DistributedFileSystem fs, Path sourceDir, Path targetDir) {
  try {
    final String from = getSnapshotName(inputOptions.getFromSnapshot());
    final String to = getSnapshotName(inputOptions.getToSnapshot());
    SnapshotDiffReport sourceDiff = fs.getSnapshotDiffReport(sourceDir,
        from, to);
    return DiffInfo.getDiffs(sourceDiff, targetDir);
  } catch (IOException e) {
    DistCp.LOG.warn("Failed to compute snapshot diff on " + sourceDir, e);
  }
  return null;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:DistCpSync.java


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