Skip to content

Instantly share code, notes, and snippets.

@alekratz
Created June 1, 2015 16:23
Show Gist options
  • Save alekratz/01326cd9478dc4b076b2 to your computer and use it in GitHub Desktop.
Save alekratz/01326cd9478dc4b076b2 to your computer and use it in GitHub Desktop.
Hadoop config printer
/*
* to compile: first run
* javac *.java -classpath $(hadoop classpath)
*
* then run
* jar cf config-printer.jar *.class
*
* To use it, run
* hadoop jar config-printer.jar ConfigPrinter
*/
import org.apache.hadoop.conf.*;
import org.apache.hadoop.mapreduce.*;
import org.apache.hadoop.util.*;
import java.util.Map;
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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment