Created
June 1, 2015 16:23
-
-
Save alekratz/01326cd9478dc4b076b2 to your computer and use it in GitHub Desktop.
Hadoop config printer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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