我们在写--map/reduce程序时,遇到使用按文件url来分析文件----------多表连接的DistributedCache方式,看不懂使用extends Configured implements Tool的方式,就查了一下http://hadoop.apache.org 上面对该Tool接口及其使用做了说明:
- @InterfaceAudience.Public
- @InterfaceStability.Stable
- public interface Tool
- extends Configurable
-
- public class MyApp extends Configured implements Tool {
-
- public int run(String[] args) throws Exception {
-
- Configuration conf = getConf();
-
- JobConf job = new JobConf(conf, MyApp.class);
-
- Path in = new Path(args[1]);
- Path out = new Path(args[2]);
-
-
- job.setJobName("my-app");
- job.setInputPath(in);
- job.setOutputPath(out);
- job.setMapperClass(MyMapper.class);
- job.setReducerClass(MyReducer.class);
-
-
- JobClient.runJob(job);
- return 0;
- }
-
- public static void main(String[] args) throws Exception {
-
- int res = ToolRunner.run(new Configuration(), new MyApp(), args);
-
- System.exit(res);
- }
- }
本文转自大数据躺过的坑博客园博客,原文链接:http://www.cnblogs.com/zlslch/p/6431833.html,如需转载请自行联系原作者