How do I print hadoop properties in command line?

0 votes

 I only find the way to set a property by Hadoop dfsadmin -D xx=yy ,

but how do I find the value of a specific property xx in command line?

Aug 23, 2018 in Big Data Hadoop by Neha
• 6,260 points
93 views

1 answer to this question.

0 votes

You can dump Hadoop config by running:

$ hadoop org.apache.hadoop.conf.Configuration
You can use GenericOptionsParser to load Hadoop's setting to Configuration-typed object and iterate its properties. Here is an example demonstrating this approach through a utility class (Configured).
public class ConfigPrinter extends Configured implements Tool {
    static {
        // by default core-site.xml is already added
        // loading "hdfs-site.xml" from classpath
        Configuration.addDefaultResource("hdfs-site.xml");
        Configuration.addDefaultResource("mapred-site.xml");
    }

    @Override
    public int run(String[] strings) throws Exception {
        Configuration config =  this.getConf();
        for (Map.Entry<String, String> entry : config) {
            System.out.println(entry.getKey() + " = " + entry.getValue());
        }
        return 0;
    }

    public static void main(String[] args) throws Exception {
        ToolRunner.run(new ConfigPrinter(), args);
    }
}
I hope this answer helps :)
answered Aug 23, 2018 by Frankie
• 9,810 points

Related Questions In Big Data Hadoop

0 votes
1 answer

How do I print hadoop properties in command line?

You can use the following command to get ...READ MORE

answered Apr 6, 2018 in Big Data Hadoop by kurt_cobain
• 9,240 points
149 views
0 votes
1 answer

How do I include all the Hadoop dependencies using Maven?

This is a dependency mismatch error. I ...READ MORE

answered Apr 10, 2018 in Big Data Hadoop by Shubham
• 13,110 points
385 views
0 votes
10 answers
0 votes
1 answer
0 votes
1 answer

What does hadoop fs -du command gives as output?

The first value is the size of ...READ MORE

answered Apr 27, 2018 in Big Data Hadoop by Shubham
• 13,110 points
624 views
0 votes
1 answer

How can I write text in HDFS using CMD?

Hadoop put & appendToFile only reads standard ...READ MORE

answered Apr 27, 2018 in Big Data Hadoop by Shubham
• 13,110 points
61 views
0 votes
1 answer

What is the command to find the free space in HDFS?

You can use dfsadmin which runs a ...READ MORE

answered Apr 29, 2018 in Big Data Hadoop by Shubham
• 13,110 points
117 views
0 votes
1 answer

How to find the used cache in HDFS

hdfs dfsadmin -report This command tells fs ...READ MORE

answered May 4, 2018 in Big Data Hadoop by Shubham
• 13,110 points
160 views
0 votes
1 answer

How do I get connected to Hadoop and Geo Spatial connector?

There are a number of free and ...READ MORE

answered Aug 13, 2018 in Big Data Hadoop by Frankie
• 9,810 points
157 views
0 votes
1 answer

What is Modeling data in Hadoop and how to do it?

I suggest spending some time with Apache ...READ MORE

answered Sep 19, 2018 in Big Data Hadoop by Frankie
• 9,810 points
63 views