public class Configured implements Configurable {
private Configuration conf;
public Configured() {
this(null);
}
public Configured(Configuration conf) {
setConf(conf);
}
public void setConf(Configuration conf) {
this.conf = conf;
}
public Configuration getConf() {
return conf;
}
}
Tool接口继承了Configurable接口,只有一个run()方法。(接口继承接口)
1
2
3
public interface Tool extends Configurable {
int run(String [] args) throws Exception;
}
继承关系如下:
再看ToolRunner类的一部分:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public class ToolRunner {
public static int run(Configuration conf, Tool tool, String[] args)
throws Exception{
if(conf == null) {
conf = new Configuration();
}
GenericOptionsParser parser = new GenericOptionsParser(conf, args); //set the configuration back, so that Tool can configure itself
tool.setConf(conf); //get the args w/o generic hadoop args
String[] toolArgs = parser.getRemainingArgs();
return tool.run(toolArgs);
-conf < configuration file > specify a configuration file
-D < property=value > use value for given property
-fs < local|namenode:port > specify a namenode
-jt < local|jobtracker:port > specify a job tracker
-files < comma separated list of files > specify comma separated files to be copied to the map reduce cluster
-libjars < comma separated list of jars > specify comma separated jar files to include in the classpath.
-archives < comma separated list of archives > specify comma separated archives to be unarchived on the compute machines.