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


Java DiffReportEntry类代码示例

本文整理汇总了Java中org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry的典型用法代码示例。如果您正苦于以下问题:Java DiffReportEntry类的具体用法?Java DiffReportEntry怎么用?Java DiffReportEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: diff

import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry; //导入依赖的package包/类
/**
 * Compute the difference between two snapshots of a directory, or between a
 * snapshot of the directory and its current tree.
 */
public SnapshotDiffReport diff(final INodesInPath iip,
    final String snapshotRootPath, final String from,
    final String to) throws IOException {
  // Find the source root directory path where the snapshots were taken.
  // All the check for path has been included in the valueOf method.
  final INodeDirectory snapshotRoot = getSnapshottableRoot(iip);

  if ((from == null || from.isEmpty())
      && (to == null || to.isEmpty())) {
    // both fromSnapshot and toSnapshot indicate the current tree
    return new SnapshotDiffReport(snapshotRootPath, from, to,
        Collections.<DiffReportEntry> emptyList());
  }
  final SnapshotDiffInfo diffs = snapshotRoot
      .getDirectorySnapshottableFeature().computeDiff(snapshotRoot, from, to);
  return diffs != null ? diffs.generateReport() : new SnapshotDiffReport(
      snapshotRootPath, from, to, Collections.<DiffReportEntry> emptyList());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:SnapshotManager.java

示例2: generateReport

import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry; //导入依赖的package包/类
/**
 * Generate a {@link SnapshotDiffReport} based on detailed diff information.
 * @return A {@link SnapshotDiffReport} describing the difference
 */
public SnapshotDiffReport generateReport() {
  List<DiffReportEntry> diffReportList = new ArrayList<DiffReportEntry>();
  for (Map.Entry<INode,byte[][]> drEntry : diffMap.entrySet()) {
    INode node = drEntry.getKey();
    byte[][] path = drEntry.getValue();
    diffReportList.add(new DiffReportEntry(DiffType.MODIFY, path, null));
    if (node.isDirectory()) {
      List<DiffReportEntry> subList = generateReport(dirDiffMap.get(node),
          path, isFromEarlier(), renameMap);
      diffReportList.addAll(subList);
    }
  }
  return new SnapshotDiffReport(snapshotRoot.getFullPathName(),
      Snapshot.getSnapshotName(from), Snapshot.getSnapshotName(to),
      diffReportList);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:SnapshotDiffInfo.java

示例3: convert

import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry; //导入依赖的package包/类
public static SnapshotDiffReportEntryProto convert(DiffReportEntry entry) {
  if (entry == null) {
    return null;
  }
  ByteString sourcePath = ByteString
      .copyFrom(entry.getSourcePath() == null ? DFSUtil.EMPTY_BYTES : entry
          .getSourcePath());
  String modification = entry.getType().getLabel();
  SnapshotDiffReportEntryProto.Builder builder = SnapshotDiffReportEntryProto
      .newBuilder().setFullpath(sourcePath)
      .setModificationLabel(modification);
  if (entry.getType() == DiffType.RENAME) {
    ByteString targetPath = ByteString
        .copyFrom(entry.getTargetPath() == null ? DFSUtil.EMPTY_BYTES : entry
            .getTargetPath());
    builder.setTargetPath(targetPath);
  }
  return builder.build();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:PBHelper.java

示例4: testRenameFileNotInSnapshot

import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry; //导入依赖的package包/类
/**
 * Rename a file under a snapshottable directory, file does not exist
 * in a snapshot.
 */
@Test (timeout=60000)
public void testRenameFileNotInSnapshot() throws Exception {
  hdfs.mkdirs(sub1);
  hdfs.allowSnapshot(sub1);
  hdfs.createSnapshot(sub1, snap1);
  DFSTestUtil.createFile(hdfs, file1, BLOCKSIZE, REPL, SEED);
  hdfs.rename(file1, file2);

  // Query the diff report and make sure it looks as expected.
  SnapshotDiffReport diffReport = hdfs.getSnapshotDiffReport(sub1, snap1, "");
  List<DiffReportEntry> entries = diffReport.getDiffList();
  assertTrue(entries.size() == 2);
  assertTrue(existsInDiffReport(entries, DiffType.MODIFY, "", null));
  assertTrue(existsInDiffReport(entries, DiffType.CREATE, file2.getName(),
      null));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestRenameWithSnapshots.java

示例5: testRenameFileInSnapshot

import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry; //导入依赖的package包/类
/**
 * Rename a file under a snapshottable directory, file exists
 * in a snapshot.
 */
@Test
public void testRenameFileInSnapshot() throws Exception {
  hdfs.mkdirs(sub1);
  hdfs.allowSnapshot(sub1);
  DFSTestUtil.createFile(hdfs, file1, BLOCKSIZE, REPL, SEED);
  hdfs.createSnapshot(sub1, snap1);
  hdfs.rename(file1, file2);

  // Query the diff report and make sure it looks as expected.
  SnapshotDiffReport diffReport = hdfs.getSnapshotDiffReport(sub1, snap1, "");
  System.out.println("DiffList is " + diffReport.toString());
  List<DiffReportEntry> entries = diffReport.getDiffList();
  assertTrue(entries.size() == 2);
  assertTrue(existsInDiffReport(entries, DiffType.MODIFY, "", null));
  assertTrue(existsInDiffReport(entries, DiffType.RENAME, file1.getName(),
      file2.getName()));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestRenameWithSnapshots.java

示例6: testRenameFileInSubDirOfDirWithSnapshot

import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry; //导入依赖的package包/类
@Test (timeout=60000)
public void testRenameFileInSubDirOfDirWithSnapshot() throws Exception {
  final Path sub2 = new Path(sub1, "sub2");
  final Path sub2file1 = new Path(sub2, "sub2file1");
  final Path sub2file2 = new Path(sub2, "sub2file2");
  final String sub1snap1 = "sub1snap1";
  
  hdfs.mkdirs(sub1);
  hdfs.mkdirs(sub2);
  DFSTestUtil.createFile(hdfs, sub2file1, BLOCKSIZE, REPL, SEED);
  SnapshotTestHelper.createSnapshot(hdfs, sub1, sub1snap1);

  // Rename the file in the subdirectory.
  hdfs.rename(sub2file1, sub2file2);

  // Query the diff report and make sure it looks as expected.
  SnapshotDiffReport diffReport = hdfs.getSnapshotDiffReport(sub1, sub1snap1,
      "");
  LOG.info("DiffList is \n\"" + diffReport.toString() + "\"");
  List<DiffReportEntry> entries = diffReport.getDiffList();
  assertTrue(existsInDiffReport(entries, DiffType.MODIFY, sub2.getName(),
      null));
  assertTrue(existsInDiffReport(entries, DiffType.RENAME, sub2.getName()
      + "/" + sub2file1.getName(), sub2.getName() + "/" + sub2file2.getName()));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestRenameWithSnapshots.java

示例7: testRenameDirectoryInSnapshot

import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry; //导入依赖的package包/类
@Test (timeout=60000)
public void testRenameDirectoryInSnapshot() throws Exception {
  final Path sub2 = new Path(sub1, "sub2");
  final Path sub3 = new Path(sub1, "sub3");
  final Path sub2file1 = new Path(sub2, "sub2file1");
  final String sub1snap1 = "sub1snap1";
  
  hdfs.mkdirs(sub1);
  hdfs.mkdirs(sub2);
  DFSTestUtil.createFile(hdfs, sub2file1, BLOCKSIZE, REPL, SEED);
  SnapshotTestHelper.createSnapshot(hdfs, sub1, sub1snap1);
  
  // First rename the sub-directory.
  hdfs.rename(sub2, sub3);
  
  // Query the diff report and make sure it looks as expected.
  SnapshotDiffReport diffReport = hdfs.getSnapshotDiffReport(sub1, sub1snap1,
      "");
  LOG.info("DiffList is \n\"" + diffReport.toString() + "\"");
  List<DiffReportEntry> entries = diffReport.getDiffList();
  assertEquals(2, entries.size());
  assertTrue(existsInDiffReport(entries, DiffType.MODIFY, "", null));
  assertTrue(existsInDiffReport(entries, DiffType.RENAME, sub2.getName(),
      sub3.getName()));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestRenameWithSnapshots.java

示例8: testDiffReportWithRenameToNewDir

import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry; //导入依赖的package包/类
@Test
public void testDiffReportWithRenameToNewDir() throws Exception {
  final Path root = new Path("/");
  final Path foo = new Path(root, "foo");
  final Path fileInFoo = new Path(foo, "file");
  DFSTestUtil.createFile(hdfs, fileInFoo, BLOCKSIZE, REPLICATION, seed);

  SnapshotTestHelper.createSnapshot(hdfs, root, "s0");
  final Path bar = new Path(root, "bar");
  hdfs.mkdirs(bar);
  final Path fileInBar = new Path(bar, "file");
  hdfs.rename(fileInFoo, fileInBar);
  SnapshotTestHelper.createSnapshot(hdfs, root, "s1");

  verifyDiffReport(root, "s0", "s1",
      new DiffReportEntry(DiffType.MODIFY, DFSUtil.string2Bytes("")),
      new DiffReportEntry(DiffType.MODIFY, DFSUtil.string2Bytes("foo")),
      new DiffReportEntry(DiffType.CREATE, DFSUtil.string2Bytes("bar")),
      new DiffReportEntry(DiffType.RENAME, DFSUtil.string2Bytes("foo/file"),
          DFSUtil.string2Bytes("bar/file")));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestSnapshotDiffReport.java

示例9: testDiffReportWithRenameAndAppend

import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry; //导入依赖的package包/类
/**
 * Rename a file and then append some data to it
 */
@Test
public void testDiffReportWithRenameAndAppend() throws Exception {
  final Path root = new Path("/");
  final Path foo = new Path(root, "foo");
  DFSTestUtil.createFile(hdfs, foo, BLOCKSIZE, REPLICATION, seed);

  SnapshotTestHelper.createSnapshot(hdfs, root, "s0");
  final Path bar = new Path(root, "bar");
  hdfs.rename(foo, bar);
  DFSTestUtil.appendFile(hdfs, bar, 10); // append 10 bytes
  SnapshotTestHelper.createSnapshot(hdfs, root, "s1");

  // we always put modification on the file before rename
  verifyDiffReport(root, "s0", "s1",
      new DiffReportEntry(DiffType.MODIFY, DFSUtil.string2Bytes("")),
      new DiffReportEntry(DiffType.MODIFY, DFSUtil.string2Bytes("foo")),
      new DiffReportEntry(DiffType.RENAME, DFSUtil.string2Bytes("foo"),
          DFSUtil.string2Bytes("bar")));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestSnapshotDiffReport.java

示例10: convert

import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry; //导入依赖的package包/类
public static SnapshotDiffReport convert(
    SnapshotDiffReportProto reportProto) {
  if (reportProto == null) {
    return null;
  }
  String snapshotDir = reportProto.getSnapshotRoot();
  String fromSnapshot = reportProto.getFromSnapshot();
  String toSnapshot = reportProto.getToSnapshot();
  List<SnapshotDiffReportEntryProto> list = reportProto
      .getDiffReportEntriesList();
  List<DiffReportEntry> entries = new ArrayList<>();
  for (SnapshotDiffReportEntryProto entryProto : list) {
    DiffReportEntry entry = convert(entryProto);
    if (entry != null)
      entries.add(entry);
  }
  return new SnapshotDiffReport(snapshotDir, fromSnapshot, toSnapshot,
      entries);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:20,代码来源:PBHelperClient.java

示例11: diff

import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry; //导入依赖的package包/类
/**
 * Compute the difference between two snapshots of a directory, or between a
 * snapshot of the directory and its current tree.
 */
public SnapshotDiffReport diff(final String path, final String from,
    final String to) throws IOException {
  // Find the source root directory path where the snapshots were taken.
  // All the check for path has been included in the valueOf method.
  final INodeDirectory snapshotRoot = getSnapshottableRoot(path);

  if ((from == null || from.isEmpty())
      && (to == null || to.isEmpty())) {
    // both fromSnapshot and toSnapshot indicate the current tree
    return new SnapshotDiffReport(path, from, to,
        Collections.<DiffReportEntry> emptyList());
  }
  final SnapshotDiffInfo diffs = snapshotRoot
      .getDirectorySnapshottableFeature().computeDiff(snapshotRoot, from, to);
  return diffs != null ? diffs.generateReport() : new SnapshotDiffReport(
      path, from, to, Collections.<DiffReportEntry> emptyList());
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:22,代码来源:SnapshotManager.java

示例12: generateReport

import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry; //导入依赖的package包/类
/**
 * Generate a {@link SnapshotDiffReport} based on detailed diff information.
 * @return A {@link SnapshotDiffReport} describing the difference
 */
public SnapshotDiffReport generateReport() {
  List<DiffReportEntry> diffReportList = new ArrayList<DiffReportEntry>();
  for (INode node : diffMap.keySet()) {
    diffReportList.add(new DiffReportEntry(DiffType.MODIFY, diffMap
        .get(node), null));
    if (node.isDirectory()) {
      List<DiffReportEntry> subList = generateReport(dirDiffMap.get(node),
          diffMap.get(node), isFromEarlier(), renameMap);
      diffReportList.addAll(subList);
    }
  }
  return new SnapshotDiffReport(snapshotRoot.getFullPathName(),
      Snapshot.getSnapshotName(from), Snapshot.getSnapshotName(to),
      diffReportList);
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:20,代码来源:SnapshotDiffInfo.java


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