當前位置: 首頁>>代碼示例>>Java>>正文


Java DistributedFileSystem.createSnapshot方法代碼示例

本文整理匯總了Java中org.apache.hadoop.hdfs.DistributedFileSystem.createSnapshot方法的典型用法代碼示例。如果您正苦於以下問題:Java DistributedFileSystem.createSnapshot方法的具體用法?Java DistributedFileSystem.createSnapshot怎麽用?Java DistributedFileSystem.createSnapshot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.hdfs.DistributedFileSystem的用法示例。


在下文中一共展示了DistributedFileSystem.createSnapshot方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testFsckForSnapshotFiles

import org.apache.hadoop.hdfs.DistributedFileSystem; //導入方法依賴的package包/類
/**
 * Test for including the snapshot files in fsck report
 */
@Test
public void testFsckForSnapshotFiles() throws Exception {
  final Configuration conf = new HdfsConfiguration();
  MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1)
      .build();
  try {
    String runFsck = runFsck(conf, 0, true, "/", "-includeSnapshots",
        "-files");
    assertTrue(runFsck.contains("HEALTHY"));
    final String fileName = "/srcdat";
    DistributedFileSystem hdfs = cluster.getFileSystem();
    Path file1 = new Path(fileName);
    DFSTestUtil.createFile(hdfs, file1, 1024, (short) 1, 1000L);
    hdfs.allowSnapshot(new Path("/"));
    hdfs.createSnapshot(new Path("/"), "mySnapShot");
    runFsck = runFsck(conf, 0, true, "/", "-includeSnapshots", "-files");
    assertTrue(runFsck.contains("/.snapshot/mySnapShot/srcdat"));
    runFsck = runFsck(conf, 0, true, "/", "-files");
    assertFalse(runFsck.contains("mySnapShot"));
  } finally {
    cluster.shutdown();
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:27,代碼來源:TestFsck.java

示例2: createSnapshot

import org.apache.hadoop.hdfs.DistributedFileSystem; //導入方法依賴的package包/類
/**
 * Create snapshot for a dir using a given snapshot name
 * 
 * @param hdfs DistributedFileSystem instance
 * @param snapshotRoot The dir to be snapshotted
 * @param snapshotName The name of the snapshot
 * @return The path of the snapshot root
 */
public static Path createSnapshot(DistributedFileSystem hdfs,
    Path snapshotRoot, String snapshotName) throws Exception {
  LOG.info("createSnapshot " + snapshotName + " for " + snapshotRoot);
  assertTrue(hdfs.exists(snapshotRoot));
  hdfs.allowSnapshot(snapshotRoot);
  hdfs.createSnapshot(snapshotRoot, snapshotName);
  // set quota to a large value for testing counts
  hdfs.setQuota(snapshotRoot, Long.MAX_VALUE-1, Long.MAX_VALUE-1);
  return SnapshotTestHelper.getSnapshotRoot(snapshotRoot, snapshotName);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:19,代碼來源:SnapshotTestHelper.java

示例3: testSnapshotStatsMXBeanInfo

import org.apache.hadoop.hdfs.DistributedFileSystem; //導入方法依賴的package包/類
/**
 * Test getting SnapshotStatsMXBean information
 */
@Test
public void testSnapshotStatsMXBeanInfo() throws Exception {
  Configuration conf = new Configuration();
  MiniDFSCluster cluster = null;
  String pathName = "/snapshot";
  Path path = new Path(pathName);

  try {
    cluster = new MiniDFSCluster.Builder(conf).build();
    cluster.waitActive();

    SnapshotManager sm = cluster.getNamesystem().getSnapshotManager();
    DistributedFileSystem dfs = (DistributedFileSystem) cluster.getFileSystem();
    dfs.mkdirs(path);
    dfs.allowSnapshot(path);
    dfs.createSnapshot(path);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    ObjectName mxbeanName = new ObjectName(
        "Hadoop:service=NameNode,name=SnapshotInfo");

    CompositeData[] directories =
        (CompositeData[]) mbs.getAttribute(
            mxbeanName, "SnapshottableDirectories");
    int numDirectories = Array.getLength(directories);
    assertEquals(sm.getNumSnapshottableDirs(), numDirectories);
    CompositeData[] snapshots =
        (CompositeData[]) mbs.getAttribute(mxbeanName, "Snapshots");
    int numSnapshots = Array.getLength(snapshots);
    assertEquals(sm.getNumSnapshots(), numSnapshots);

    CompositeData d = (CompositeData) Array.get(directories, 0);
    CompositeData s = (CompositeData) Array.get(snapshots, 0);
    assertTrue(((String) d.get("path")).contains(pathName));
    assertTrue(((String) s.get("snapshotDirectory")).contains(pathName));
  } finally {
    if (cluster != null) {
      cluster.shutdown();
    }
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:45,代碼來源:TestSnapshotStatsMXBean.java


注:本文中的org.apache.hadoop.hdfs.DistributedFileSystem.createSnapshot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。