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


Java HdfsConstants.DOT_SNAPSHOT_DIR属性代码示例

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


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

示例1: createSnapshot

private Path createSnapshot() throws IOException {
  LOG.debug("Source table {}.{} has its data located at {}", sourceTable.getDbName(), sourceTable.getTableName(),
      sourceDataPath);

  FileSystem fileSystem = fileSystemFactory.get(sourceDataPath, sourceHiveConf);
  Path snapshotMetaDataPath = new Path(sourceDataPath, HdfsConstants.DOT_SNAPSHOT_DIR);
  Path resolvedLocation = sourceDataPath;
  if (fileSystem.exists(snapshotMetaDataPath)) {
    if (snapshotsDisabled) {
      LOG.info("Path {} can be snapshot, but feature has been disabled.", sourceDataPath);
    } else {
      LOG.debug("Creating source data snapshot: {}, {}", sourceDataPath, eventId);
      // fileSystem.createSnapshot does not return a fully qualified URI.
      resolvedLocation = fileSystem.makeQualified(fileSystem.createSnapshot(sourceDataPath, eventId));
      snapshotPath = resolvedLocation;
    }
  } else {
    LOG.debug("Snapshots not enabled on source location: {}", sourceDataPath);
  }
  return resolvedLocation;
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:21,代码来源:HdfsSnapshotLocationManager.java

示例2: testFallback

/**
 * Test the sync returns false in the following scenarios:
 * 1. the source/target dir are not snapshottable dir
 * 2. the source/target does not have the given snapshots
 * 3. changes have been made in target
 */
@Test
public void testFallback() throws Exception {
  // the source/target dir are not snapshottable dir
  Assert.assertFalse(DistCpSync.sync(options, conf));
  // make sure the source path has been updated to the snapshot path
  final Path spath = new Path(source,
      HdfsConstants.DOT_SNAPSHOT_DIR + Path.SEPARATOR + "s2");
  Assert.assertEquals(spath, options.getSourcePaths().get(0));

  // reset source path in options
  options.setSourcePaths(Arrays.asList(source));
  // the source/target does not have the given snapshots
  dfs.allowSnapshot(source);
  dfs.allowSnapshot(target);
  Assert.assertFalse(DistCpSync.sync(options, conf));
  Assert.assertEquals(spath, options.getSourcePaths().get(0));

  // reset source path in options
  options.setSourcePaths(Arrays.asList(source));
  dfs.createSnapshot(source, "s1");
  dfs.createSnapshot(source, "s2");
  dfs.createSnapshot(target, "s1");
  Assert.assertTrue(DistCpSync.sync(options, conf));

  // reset source paths in options
  options.setSourcePaths(Arrays.asList(source));
  // changes have been made in target
  final Path subTarget = new Path(target, "sub");
  dfs.mkdirs(subTarget);
  Assert.assertFalse(DistCpSync.sync(options, conf));
  // make sure the source path has been updated to the snapshot path
  Assert.assertEquals(spath, options.getSourcePaths().get(0));

  // reset source paths in options
  options.setSourcePaths(Arrays.asList(source));
  dfs.delete(subTarget, true);
  Assert.assertTrue(DistCpSync.sync(options, conf));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:44,代码来源:TestDistCpSync.java

示例3: verifyINodeName

/** Verify if the inode name is legal. */
void verifyINodeName(byte[] childName) throws HadoopIllegalArgumentException {
  if (Arrays.equals(HdfsConstants.DOT_SNAPSHOT_DIR_BYTES, childName)) {
    String s = "\"" + HdfsConstants.DOT_SNAPSHOT_DIR + "\" is a reserved name.";
    if (!namesystem.isImageLoaded()) {
      s += "  Please rename it before upgrade.";
    }
    throw new HadoopIllegalArgumentException(s);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:FSDirectory.java

示例4: getSourceSnapshotPath

private static Path getSourceSnapshotPath(Path sourceDir, String snapshotName) {
  if (Path.CUR_DIR.equals(snapshotName)) {
    return sourceDir;
  } else {
    return new Path(sourceDir,
        HdfsConstants.DOT_SNAPSHOT_DIR + Path.SEPARATOR + snapshotName);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:DistCpSync.java

示例5: testRenameUndo_7

/**
 * Test rename to an invalid name (xxx/.snapshot)
 */
@Test
public void testRenameUndo_7() throws Exception {
  final Path root = new Path("/");
  final Path foo = new Path(root, "foo");
  final Path bar = new Path(foo, "bar");
  DFSTestUtil.createFile(hdfs, bar, BLOCKSIZE, REPL, SEED);
  
  // create a snapshot on root
  SnapshotTestHelper.createSnapshot(hdfs, root, snap1);
  
  // rename bar to /foo/.snapshot which is invalid
  final Path invalid = new Path(foo, HdfsConstants.DOT_SNAPSHOT_DIR);
  try {
    hdfs.rename(bar, invalid);
    fail("expect exception since invalid name is used for rename");
  } catch (Exception e) {
    GenericTestUtils.assertExceptionContains("\"" +
        HdfsConstants.DOT_SNAPSHOT_DIR + "\" is a reserved name", e);
  }
  
  // check
  INodeDirectory rootNode = fsdir.getINode4Write(root.toString())
      .asDirectory();
  INodeDirectory fooNode = fsdir.getINode4Write(foo.toString()).asDirectory();
  ReadOnlyList<INode> children = fooNode
      .getChildrenList(Snapshot.CURRENT_STATE_ID);
  assertEquals(1, children.size());
  List<DirectoryDiff> diffList = fooNode.getDiffs().asList();
  assertEquals(1, diffList.size());
  DirectoryDiff diff = diffList.get(0);
  // this diff is generated while renaming
  Snapshot s1 = rootNode.getSnapshot(DFSUtil.string2Bytes(snap1));
  assertEquals(s1.getId(), diff.getSnapshotId());
  // after undo, the diff should be empty
  assertTrue(diff.getChildrenDiff().getList(ListType.DELETED).isEmpty());
  assertTrue(diff.getChildrenDiff().getList(ListType.CREATED).isEmpty());
  
  // bar was converted to filewithsnapshot while renaming
  INodeFile barNode = fsdir.getINode4Write(bar.toString()).asFile();
  assertSame(barNode, children.get(0));
  assertSame(fooNode, barNode.getParent());
  List<FileDiff> barDiffList = barNode.getDiffs().asList();
  assertEquals(1, barDiffList.size());
  FileDiff barDiff = barDiffList.get(0);
  assertEquals(s1.getId(), barDiff.getSnapshotId());
  
  // restart cluster multiple times to make sure the fsimage and edits log are
  // correct. Note that when loading fsimage, foo and bar will be converted 
  // back to normal INodeDirectory and INodeFile since they do not store any 
  // snapshot data
  hdfs.setSafeMode(SafeModeAction.SAFEMODE_ENTER);
  hdfs.saveNamespace();
  hdfs.setSafeMode(SafeModeAction.SAFEMODE_LEAVE);
  cluster.shutdown();
  cluster = new MiniDFSCluster.Builder(conf).format(false)
      .numDataNodes(REPL).build();
  cluster.waitActive();
  restartClusterAndCheckImage(true);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:62,代码来源:TestRenameWithSnapshots.java

示例6: getSnapshotRoot

public static Path getSnapshotRoot(Path snapshottedDir, String snapshotName) {
  return new Path(snapshottedDir, HdfsConstants.DOT_SNAPSHOT_DIR + "/"
      + snapshotName);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:4,代码来源:SnapshotTestHelper.java

示例7: testSync

/**
 * Test the basic functionality.
 */
@Test
public void testSync() throws Exception {
  initData(source);
  initData(target);
  dfs.allowSnapshot(source);
  dfs.allowSnapshot(target);
  dfs.createSnapshot(source, "s1");
  dfs.createSnapshot(target, "s1");

  // make changes under source
  changeData(source);
  dfs.createSnapshot(source, "s2");

  // before sync, make some further changes on source. this should not affect
  // the later distcp since we're copying (s2-s1) to target
  final Path toDelete = new Path(source, "foo/d1/foo/f1");
  dfs.delete(toDelete, true);
  final Path newdir = new Path(source, "foo/d1/foo/newdir");
  dfs.mkdirs(newdir);

  // do the sync
  Assert.assertTrue(DistCpSync.sync(options, conf));

  // make sure the source path has been updated to the snapshot path
  final Path spath = new Path(source,
      HdfsConstants.DOT_SNAPSHOT_DIR + Path.SEPARATOR + "s2");
  Assert.assertEquals(spath, options.getSourcePaths().get(0));

  // build copy listing
  final Path listingPath = new Path("/tmp/META/fileList.seq");
  CopyListing listing = new GlobbedCopyListing(conf, new Credentials());
  listing.buildListing(listingPath, options);

  Map<Text, CopyListingFileStatus> copyListing = getListing(listingPath);
  CopyMapper copyMapper = new CopyMapper();
  StubContext stubContext = new StubContext(conf, null, 0);
  Mapper<Text, CopyListingFileStatus, Text, Text>.Context context =
      stubContext.getContext();
  // Enable append
  context.getConfiguration().setBoolean(
      DistCpOptionSwitch.APPEND.getConfigLabel(), true);
  copyMapper.setup(context);
  for (Map.Entry<Text, CopyListingFileStatus> entry : copyListing.entrySet()) {
    copyMapper.map(entry.getKey(), entry.getValue(), context);
  }

  // verify that we only copied new appended data of f2 and the new file f1
  Assert.assertEquals(BLOCK_SIZE * 3, stubContext.getReporter()
      .getCounter(CopyMapper.Counter.BYTESCOPIED).getValue());

  // verify the source and target now has the same structure
  verifyCopy(dfs.getFileStatus(spath), dfs.getFileStatus(target), false);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:56,代码来源:TestDistCpSync.java


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