Java Code Examples for org.apache.hadoop.hdfs.tools.DFSAdmin#setConf()

The following examples show how to use org.apache.hadoop.hdfs.tools.DFSAdmin#setConf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestDFSShell.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * default setting is file:// which is not a DFS
 * so DFSAdmin should throw and catch InvalidArgumentException
 * and return -1 exit code.
 * @throws Exception
 */
@Test (timeout = 30000)
public void testInvalidShell() throws Exception {
  Configuration conf = new Configuration(); // default FS (non-DFS)
  DFSAdmin admin = new DFSAdmin();
  admin.setConf(conf);
  int res = admin.run(new String[] {"-refreshNodes"});
  assertEquals("expected to fail -1", res , -1);
}
 
Example 2
Source File: TestFetchImage.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Download a few fsimages using `hdfs dfsadmin -fetchImage ...' and verify
 * the results.
 */
@Test
public void testFetchImage() throws Exception {
  FETCHED_IMAGE_FILE.mkdirs();
  Configuration conf = new Configuration();
  MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build();
  FileSystem fs = null;
  try {
    DFSAdmin dfsAdmin = new DFSAdmin();
    dfsAdmin.setConf(conf);
    
    runFetchImage(dfsAdmin, cluster);
    
    fs = cluster.getFileSystem();
    fs.mkdirs(new Path("/foo"));
    fs.mkdirs(new Path("/foo2"));
    fs.mkdirs(new Path("/foo3"));
    
    cluster.getNameNodeRpc()
        .setSafeMode(SafeModeAction.SAFEMODE_ENTER, false);
    cluster.getNameNodeRpc().saveNamespace();
    cluster.getNameNodeRpc()
        .setSafeMode(SafeModeAction.SAFEMODE_LEAVE, false);
    
    runFetchImage(dfsAdmin, cluster);
  } finally {
    if (fs != null) {
      fs.close();
    }
    if (cluster != null) {
      cluster.shutdown();
    }
  }
}
 
Example 3
Source File: TestDFSShell.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * default setting is file:// which is not a DFS
 * so DFSAdmin should throw and catch InvalidArgumentException
 * and return -1 exit code.
 * @throws Exception
 */
@Test (timeout = 30000)
public void testInvalidShell() throws Exception {
  Configuration conf = new Configuration(); // default FS (non-DFS)
  DFSAdmin admin = new DFSAdmin();
  admin.setConf(conf);
  int res = admin.run(new String[] {"-refreshNodes"});
  assertEquals("expected to fail -1", res , -1);
}
 
Example 4
Source File: TestFetchImage.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Download a few fsimages using `hdfs dfsadmin -fetchImage ...' and verify
 * the results.
 */
@Test
public void testFetchImage() throws Exception {
  FETCHED_IMAGE_FILE.mkdirs();
  Configuration conf = new Configuration();
  MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build();
  FileSystem fs = null;
  try {
    DFSAdmin dfsAdmin = new DFSAdmin();
    dfsAdmin.setConf(conf);
    
    runFetchImage(dfsAdmin, cluster);
    
    fs = cluster.getFileSystem();
    fs.mkdirs(new Path("/foo"));
    fs.mkdirs(new Path("/foo2"));
    fs.mkdirs(new Path("/foo3"));
    
    cluster.getNameNodeRpc()
        .setSafeMode(SafeModeAction.SAFEMODE_ENTER, false);
    cluster.getNameNodeRpc().saveNamespace();
    cluster.getNameNodeRpc()
        .setSafeMode(SafeModeAction.SAFEMODE_LEAVE, false);
    
    runFetchImage(dfsAdmin, cluster);
  } finally {
    if (fs != null) {
      fs.close();
    }
    if (cluster != null) {
      cluster.shutdown();
    }
  }
}