java - 即使已实现,也会收到工具界面警告

标签 java hadoop mapreduce hortonworks-data-platform

我有一个非常简单的“Hello world”风格的 map/reduce 作业。

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

霍顿工厂

谢谢, 克里斯

最佳答案

由于您的问题在 Google 搜索此警告的顶部的速度非常快,因此我将在此处给出正确的答案:

正如 user1797538 所说:(对此感到抱歉)

user1797538: "The problem was the call to get a Job instance"

必须使用父类(super class) Configured。顾名思义,它已经配置好了,所以Tester类必须使用现有的Configuration,不能设置一个新的空Configuration。

如果我们在方法中提取作业创建:

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

还有 Javadoc:Configured.getConf()

关于java - 即使已实现,也会收到工具界面警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28333080/

相关文章:

java - 如何在 ANTLR 中处理左联想语法

hadoop - 将 50 个大文件中的列/字段合并到一个文件中

hadoop - 如何通过清管作业或maprecude作业控制存储在零件文件中的记录数?

java - Hadoop:Reduce 没有产生所需的输出,它与 map 输出相同

python - 如何为以下内容写图归约

hadoop - Hadoop 映射器如何处理部分溢出到下一个 block 的记录?

java - BlockingQueue 在 Java 中是完全线程安全的吗

java - 如何将代码更改为 switch 语句?

java - PowerMock,如何使静态方法多次返回值?

hadoop - 无法通过Map/Reduce完成的任务