Examples of HdfsAdmin


Examples of org.apache.hadoop.hdfs.client.HdfsAdmin

  /**
   * Test that we can set and clear quotas via {@link HdfsAdmin}.
   */
  @Test
  public void testHdfsAdminSetQuota() throws Exception {
    HdfsAdmin dfsAdmin = new HdfsAdmin(
        FileSystem.getDefaultUri(conf), conf);
    FileSystem fs = null;
    try {
      fs = FileSystem.get(conf);
      assertTrue(fs.mkdirs(TEST_PATH));
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getQuota());
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getSpaceQuota());
     
      dfsAdmin.setSpaceQuota(TEST_PATH, 10);
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getQuota());
      assertEquals(10, fs.getContentSummary(TEST_PATH).getSpaceQuota());
     
      dfsAdmin.setQuota(TEST_PATH, 10);
      assertEquals(10, fs.getContentSummary(TEST_PATH).getQuota());
      assertEquals(10, fs.getContentSummary(TEST_PATH).getSpaceQuota());
     
      dfsAdmin.clearSpaceQuota(TEST_PATH);
      assertEquals(10, fs.getContentSummary(TEST_PATH).getQuota());
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getSpaceQuota());
     
      dfsAdmin.clearQuota(TEST_PATH);
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getQuota());
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getSpaceQuota());
    } finally {
      if (fs != null) {
        fs.close();
View Full Code Here

Examples of org.apache.hadoop.hdfs.client.HdfsAdmin

  /**
   * Make sure that a non-HDFS URI throws a helpful error.
   */
  @Test(expected = IllegalArgumentException.class)
  public void testHdfsAdminWithBadUri() throws IOException, URISyntaxException {
    new HdfsAdmin(new URI("file:///bad-scheme"), conf);
  }
View Full Code Here

Examples of org.apache.hadoop.hdfs.client.HdfsAdmin

      secondary = new SecondaryNameNode(conf);
      SnapshotManager nnSnapshotManager = cluster.getNamesystem().getSnapshotManager();
      SnapshotManager secondarySnapshotManager = secondary.getFSNamesystem().getSnapshotManager();
     
      FileSystem fs = cluster.getFileSystem();
      HdfsAdmin admin =  new HdfsAdmin(FileSystem.getDefaultUri(conf), conf);
     
      assertEquals(0, nnSnapshotManager.getNumSnapshots());
      assertEquals(0, nnSnapshotManager.getNumSnapshottableDirs());
      assertEquals(0, secondarySnapshotManager.getNumSnapshots());
      assertEquals(0, secondarySnapshotManager.getNumSnapshottableDirs());
     
      // 1. Create a snapshottable directory foo on the NN.
      fs.mkdirs(TEST_PATH);
      admin.allowSnapshot(TEST_PATH);
      assertEquals(0, nnSnapshotManager.getNumSnapshots());
      assertEquals(1, nnSnapshotManager.getNumSnapshottableDirs());
     
      // 2. Create a snapshot of the dir foo. This will be referenced both in
      // the SnapshotManager as well as in the file system tree. The snapshot
      // count will go up to 1.
      Path snapshotPath = fs.createSnapshot(TEST_PATH);
      assertEquals(1, nnSnapshotManager.getNumSnapshots());
      assertEquals(1, nnSnapshotManager.getNumSnapshottableDirs());
     
      // 3. Start up a 2NN and have it do a checkpoint. It will have foo and its
      // snapshot in its list of snapshottable dirs referenced from the
      // SnapshotManager, as well as in the file system tree.
      secondary.doCheckpoint();
      assertEquals(1, secondarySnapshotManager.getNumSnapshots());
      assertEquals(1, secondarySnapshotManager.getNumSnapshottableDirs());
     
      // 4. Disallow snapshots on and delete foo on the NN. The snapshot count
      // will go down to 0 and the snapshottable dir will be removed from the fs
      // tree.
      fs.deleteSnapshot(TEST_PATH, snapshotPath.getName());
      admin.disallowSnapshot(TEST_PATH);
      assertEquals(0, nnSnapshotManager.getNumSnapshots());
      assertEquals(0, nnSnapshotManager.getNumSnapshottableDirs());
     
      // 5. Have the NN do a saveNamespace, writing out a new fsimage with
      // snapshot count 0.
View Full Code Here

Examples of org.apache.hadoop.hdfs.client.HdfsAdmin

  /**
   * Test that we can set and clear quotas via {@link HdfsAdmin}.
   */
  @Test
  public void testHdfsAdminSetQuota() throws Exception {
    HdfsAdmin dfsAdmin = new HdfsAdmin(
        FileSystem.getDefaultUri(conf), conf);
    FileSystem fs = null;
    try {
      fs = FileSystem.get(conf);
      assertTrue(fs.mkdirs(TEST_PATH));
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getQuota());
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getSpaceQuota());
     
      dfsAdmin.setSpaceQuota(TEST_PATH, 10);
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getQuota());
      assertEquals(10, fs.getContentSummary(TEST_PATH).getSpaceQuota());
     
      dfsAdmin.setQuota(TEST_PATH, 10);
      assertEquals(10, fs.getContentSummary(TEST_PATH).getQuota());
      assertEquals(10, fs.getContentSummary(TEST_PATH).getSpaceQuota());
     
      dfsAdmin.clearSpaceQuota(TEST_PATH);
      assertEquals(10, fs.getContentSummary(TEST_PATH).getQuota());
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getSpaceQuota());
     
      dfsAdmin.clearQuota(TEST_PATH);
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getQuota());
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getSpaceQuota());
    } finally {
      if (fs != null) {
        fs.close();
View Full Code Here

Examples of org.apache.hadoop.hdfs.client.HdfsAdmin

  /**
   * Make sure that a non-HDFS URI throws a helpful error.
   */
  @Test(expected = IllegalArgumentException.class)
  public void testHdfsAdminWithBadUri() throws IOException, URISyntaxException {
    new HdfsAdmin(new URI("file:///bad-scheme"), conf);
  }
View Full Code Here

Examples of org.apache.hadoop.hdfs.client.HdfsAdmin

      secondary = new SecondaryNameNode(conf);
      SnapshotManager nnSnapshotManager = cluster.getNamesystem().getSnapshotManager();
      SnapshotManager secondarySnapshotManager = secondary.getFSNamesystem().getSnapshotManager();
     
      FileSystem fs = cluster.getFileSystem();
      HdfsAdmin admin =  new HdfsAdmin(FileSystem.getDefaultUri(conf), conf);
     
      assertEquals(0, nnSnapshotManager.getNumSnapshots());
      assertEquals(0, nnSnapshotManager.getNumSnapshottableDirs());
      assertEquals(0, secondarySnapshotManager.getNumSnapshots());
      assertEquals(0, secondarySnapshotManager.getNumSnapshottableDirs());
     
      // 1. Create a snapshottable directory foo on the NN.
      fs.mkdirs(TEST_PATH);
      admin.allowSnapshot(TEST_PATH);
      assertEquals(0, nnSnapshotManager.getNumSnapshots());
      assertEquals(1, nnSnapshotManager.getNumSnapshottableDirs());
     
      // 2. Create a snapshot of the dir foo. This will be referenced both in
      // the SnapshotManager as well as in the file system tree. The snapshot
      // count will go up to 1.
      Path snapshotPath = fs.createSnapshot(TEST_PATH);
      assertEquals(1, nnSnapshotManager.getNumSnapshots());
      assertEquals(1, nnSnapshotManager.getNumSnapshottableDirs());
     
      // 3. Start up a 2NN and have it do a checkpoint. It will have foo and its
      // snapshot in its list of snapshottable dirs referenced from the
      // SnapshotManager, as well as in the file system tree.
      secondary.doCheckpoint();
      assertEquals(1, secondarySnapshotManager.getNumSnapshots());
      assertEquals(1, secondarySnapshotManager.getNumSnapshottableDirs());
     
      // 4. Disallow snapshots on and delete foo on the NN. The snapshot count
      // will go down to 0 and the snapshottable dir will be removed from the fs
      // tree.
      fs.deleteSnapshot(TEST_PATH, snapshotPath.getName());
      admin.disallowSnapshot(TEST_PATH);
      assertEquals(0, nnSnapshotManager.getNumSnapshots());
      assertEquals(0, nnSnapshotManager.getNumSnapshottableDirs());
     
      // 5. Have the NN do a saveNamespace, writing out a new fsimage with
      // snapshot count 0.
View Full Code Here

Examples of org.apache.hadoop.hdfs.client.HdfsAdmin

  /**
   * Test that we can set and clear quotas via {@link HdfsAdmin}.
   */
  @Test
  public void testHdfsAdminSetQuota() throws Exception {
    HdfsAdmin dfsAdmin = new HdfsAdmin(
        FileSystem.getDefaultUri(conf), conf);
    FileSystem fs = null;
    try {
      fs = FileSystem.get(conf);
      assertTrue(fs.mkdirs(TEST_PATH));
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getQuota());
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getSpaceQuota());
     
      dfsAdmin.setSpaceQuota(TEST_PATH, 10);
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getQuota());
      assertEquals(10, fs.getContentSummary(TEST_PATH).getSpaceQuota());
     
      dfsAdmin.setQuota(TEST_PATH, 10);
      assertEquals(10, fs.getContentSummary(TEST_PATH).getQuota());
      assertEquals(10, fs.getContentSummary(TEST_PATH).getSpaceQuota());
     
      dfsAdmin.clearSpaceQuota(TEST_PATH);
      assertEquals(10, fs.getContentSummary(TEST_PATH).getQuota());
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getSpaceQuota());
     
      dfsAdmin.clearQuota(TEST_PATH);
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getQuota());
      assertEquals(-1, fs.getContentSummary(TEST_PATH).getSpaceQuota());
    } finally {
      if (fs != null) {
        fs.close();
View Full Code Here

Examples of org.apache.hadoop.hdfs.client.HdfsAdmin

  /**
   * Make sure that a non-HDFS URI throws a helpful error.
   */
  @Test(expected = IllegalArgumentException.class)
  public void testHdfsAdminWithBadUri() throws IOException, URISyntaxException {
    new HdfsAdmin(new URI("file:///bad-scheme"), conf);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.