Java 获取工具界面警告,即使已实现
我有一个非常简单的“Hello world”样式的映射/缩减作业Java 获取工具界面警告,即使已实现,java,hadoop,mapreduce,hortonworks-data-platform,Java,Hadoop,Mapreduce,Hortonworks Data Platform,我有一个非常简单的“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] &
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);
}
我可以验证没有添加配置
有人知道为什么Hadoop认为ToolRunner没有实现吗
$hadoop版本
Hadoop 2.4.0.2.1.2.0-402
钟表厂
谢谢,
克里斯当你的问题快速出现在谷歌搜索此警告的顶部时,我会在这里给出正确的答案: 正如用户1797538您所说的:(对此表示抱歉)
user1797538:“问题是调用获取作业实例” 必须使用配置的超类。顾名思义,它已经配置好了,因此Tester类必须使用现有的配置,而不是设置一个新的空配置 如果我们用一种方法提取创造的就业机会:
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中的另一个示例:
Javadoc:问题是调用作业实例,应该是。。。Job.getInstance(getConf());我在运行HiveQL脚本的Hive Beeline中遇到了类似的问题
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;
}