Search in sources :

Example 1 with CommandHandler

use of org.apache.hadoop.hdfs.tools.GetConf.CommandHandler in project hadoop by apache.

the class TestGetConf method testTool.

/**
   * Tests commands other than {@link Command#NAMENODE}, {@link Command#BACKUP},
   * {@link Command#SECONDARY} and {@link Command#NNRPCADDRESSES}
   */
@Test(timeout = 10000)
public void testTool() throws Exception {
    HdfsConfiguration conf = new HdfsConfiguration(false);
    for (Command cmd : Command.values()) {
        CommandHandler handler = Command.getHandler(cmd.getName());
        if (handler.key != null && !"-confKey".equals(cmd.getName())) {
            // Add the key to the conf and ensure tool returns the right value
            String[] args = { cmd.getName() };
            conf.set(handler.key, "value");
            assertTrue(runTool(conf, args, true).contains("value"));
        }
    }
}
Also used : Command(org.apache.hadoop.hdfs.tools.GetConf.Command) CommandHandler(org.apache.hadoop.hdfs.tools.GetConf.CommandHandler) HdfsConfiguration(org.apache.hadoop.hdfs.HdfsConfiguration) Test(org.junit.Test)

Example 2 with CommandHandler

use of org.apache.hadoop.hdfs.tools.GetConf.CommandHandler in project hadoop by apache.

the class TestGetConf method testEmptyConf.

/**
   * Test empty configuration
   */
@Test(timeout = 10000)
public void testEmptyConf() throws Exception {
    HdfsConfiguration conf = new HdfsConfiguration(false);
    // Verify getting addresses fails
    getAddressListFromTool(TestType.NAMENODE, conf, false);
    System.out.println(getAddressListFromTool(TestType.BACKUP, conf, false));
    getAddressListFromTool(TestType.SECONDARY, conf, false);
    getAddressListFromTool(TestType.NNRPCADDRESSES, conf, false);
    for (Command cmd : Command.values()) {
        String arg = cmd.getName();
        CommandHandler handler = Command.getHandler(arg);
        assertNotNull("missing handler: " + cmd, handler);
        if (handler.key != null) {
            // First test with configuration missing the required key
            String[] args = { handler.key };
            runTool(conf, args, false);
        }
    }
}
Also used : Command(org.apache.hadoop.hdfs.tools.GetConf.Command) CommandHandler(org.apache.hadoop.hdfs.tools.GetConf.CommandHandler) HdfsConfiguration(org.apache.hadoop.hdfs.HdfsConfiguration) Test(org.junit.Test)

Aggregations

HdfsConfiguration (org.apache.hadoop.hdfs.HdfsConfiguration)2 Command (org.apache.hadoop.hdfs.tools.GetConf.Command)2 CommandHandler (org.apache.hadoop.hdfs.tools.GetConf.CommandHandler)2 Test (org.junit.Test)2