即使已实施也获得工具界面警告 [英] Getting the Tool Interface warning even though it is implemented
问题描述
我有一个非常简单的"Hello world"样式地图/缩小工作.
I have a very simple "Hello world" style map/reduce job.
public class Tester extends Configured implements Tool {
@Override
public int run(String[] args) throws Exception {
if (args.length != 2) {
System.err.printf("Usage: %s [generic options] <input> <output>\n",
getClass().getSimpleName());
ToolRunner.printGenericCommandUsage(System.err);
return -1;
}
Job job = Job.getInstance(new Configuration());
job.setJarByClass(getClass());
getConf().set("mapreduce.job.queuename", "adhoc");
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(NullWritable.class);
job.setMapperClass(TesterMapper.class);
job.setNumReduceTasks(0);
return job.waitForCompletion(true) ? 0 : 1;
}
public static void main(String[] args) throws Exception {
int exitCode = ToolRunner.run(new Tester(), args);
System.exit(exitCode);
}
哪个实现了ToolRunner,但是运行时不解析参数.
Which implements the ToolRunner, but when run is not parsing the arguments.
$hadoop jar target/manifold-mapreduce-0.1.0.jar ga.manifold.mapreduce.Tester -conf conf.xml etl/manifold/pipeline/ABV1T/ingest/input etl/manifold/pipeline/ABV1T/ingest/output
15/02/04 16:35:24 INFO client.RMProxy: Connecting to ResourceManager at lxjh116-pvt.phibred.com/10.56.100.23:8050
15/02/04 16:35:25 WARN mapreduce.JobSubmitter: Hadoop command-line option parsing not performed. Implement the Tool interface and execute your application with ToolRunner to remedy this.
我可以确认未添加配置.
I can verify that the configuration is not being added.
任何人都知道为什么Hadoop认为未实现ToolRunner吗?
Anyone know why Hadoop thinks the ToolRunner isn't implemented?
$ hadoop版本 Hadoop 2.4.0.2.1.2.0-402
$hadoop version Hadoop 2.4.0.2.1.2.0-402
Hortonworks
Hortonworks
谢谢, 克里斯
推荐答案
当您的问题在Google搜索此警告的顶部迅速弹出时,我将在此处给出适当的答案:
As your question pops really fast on the top of Google search for this warning, I'll give a proper answer here :
user1797538 您说:(很抱歉)
user1797538:问题在于调用Job实例"
user1797538: "The problem was the call to get a Job instance"
必须使用配置的超类.顾名思义,它已经配置好了,因此Tester类必须使用现有的Configuration,而不要设置一个新的空配置.
The superclass Configured must be used. As its name suggests, it is already configured, so the existing Configuration must be used by the Tester class and not set a new empty one.
如果我们通过以下方法提取Job的创建:
If we extract the Job creation in a method :
private Job createJob() throws IOException {
// On this line use getConf() instead of new Configuration()
Job job = Job.getInstance(getConf(), Tester.class.getCanonicalName());
// Other job setter call here, for example
job.setJarByClass(Tester.class);
job.setMapperClass(TesterMapper.class);
job.setCombinerClass(TesterReducer.class);
job.setReducerClass(TesterReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
// adapt this to your needs of course.
return job;
}
javadoc中的另一个示例: org.apache.hadoop.util.Tool
Another example from the javadoc : org.apache.hadoop.util.Tool
和Javadoc: 查看全文