我有一个非常简单的“Hello world”风格地图/减少工作。
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,但运行时不解析参数。
$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.
我可以验证是否未添加配置。
任何人都知道为什么Hadoop认为ToolRunner没有实现?
$ hadoop版本 Hadoop 2.4.0.2.1.2.0-402
Hortonworks
谢谢, 克里斯
答案 0 :(得分:8)
由于您的问题在Google搜索此警告的顶部非常快,我会在这里给出正确答案:
正如 user1797538 你说:(对不起)
user1797538:“问题是调用获取Job实例”
必须使用超类Configured。顾名思义,它已经配置好了,所以现有的配置必须由Tester类使用,而不是设置一个新的空。
如果我们在方法中提取作业:
>>> input = numpy.matrix((((2, 3), (4, 5)), ((6, 7), (8, 9))))
ValueError: matrix must be 2-dimensional
javadoc的另一个例子:org.apache.hadoop.util.Tool
Javadoc:Configured.getConf()