Configurataion Printer(基于全新2.2.0API)

Configurataion Printer


 

 1 import java.util.Map.Entry;

 2 

 3 import org.apache.hadoop.conf.Configuration;

 4 import org.apache.hadoop.fs.FileSystem;

 5 import org.apache.hadoop.util.ToolRunner;

 6 import org.apache.hadoop.util.Tool;

 7 import org.apache.hadoop.conf.Configured;

 8 

 9 

10 public class ConfigurationPrinter extends Configured implements Tool {

11   

12   @Override

13   public int run(String[] args) throws Exception {

14     Configuration.addDefaultResource(args[0]);

15     Configuration.addDefaultResource(args[1]);

16 

17     Configuration conf = getConf();

18     for(Entry<String, String> entry : conf) {

19       System.out.printf("%s=%s\n", entry.getKey(), entry.getValue());

20     }   

21     return 0;

22   }

23   

24   public static void main(String[] args) throws Exception {

25     ToolRunner.run(new ConfigurationPrinter(), args);

26   }

27 }

 

你可能感兴趣的:(config)