我有如下要求:
那么提交作业所需的代码是什么?客户端计算机上配置的任何特定内容?
答案 0 :(得分:0)
Hadoop应该出现在客户端计算机上,其配置与hadoop集群中的其他计算机相同。
要从java方法提交MR作业,请参阅java Fastest way to fill DataTable from LINQ query using DataContext并传递hadoop命令以启动wordcount示例。
可以找到wordcount的命令和必要的应用程序特定要求ProcessBuilder
答案 1 :(得分:0)
你应该创建一个实现Tool的类。这里有一个例子:
public class AggregateJob extends Configured implements Tool {
@Override
public int run(String[] args) throws Exception {
Job job = new Job(getConf());
job.setJarByClass(getClass());
job.setJobName(getClass().getSimpleName());
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
job.setMapperClass(ProjectionMapper.class);
job.setCombinerClass(LongSumReducer.class);
job.setReducerClass(LongSumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(LongWritable.class);
return job.waitForCompletion(true) ? 0 : 1;
}
public static void main(String[] args) throws Exception {
int rc = ToolRunner.run(new AggregateJob(), args);
System.exit(rc);
}
}
此示例来自here。正如@ hamsa-zafar已经说过的那样,客户端机器应该具有hadoop配置,就像群集中的任何其他节点一样。