zoukankan      html  css  js  c++  java
  • 关于Tool接口--------hadoop接口:extends Configured implements Tool 和 ToolRunner.run

      我们在写Hadoop--map/reduce程序时,遇到使用按文件url来分析文件----------多表连接的DistributedCache方式,看不懂使用extends Configured implements Tool的方式,就查了一下http://hadoop.apache.org      上面对该Tool接口及其使用做了说明:

    1. @InterfaceAudience.Public  
    2. @InterfaceStability.Stable  
    3. public interface Tool       //Tool接口继承了Configurable  
    4. extends Configurable  
    5. //Tool接口可以支持处理通用的命令行选项,它是所有Map-Reduce程序的都可用的一个标准接口,下面是一个典型用例:  
    6.   
    7.          public class MyApp extends Configured implements Tool {  
    8.            
    9.            public int run(String[] args) throws Exception {  
    10.              //ToolRunner要处理的Configuration,Tool通过ToolRunner调用ToolRunner.run时,传入参数Configuration  
    11.              Configuration conf = getConf();  
    12.                
    13.              JobConf job = new JobConf(conf, MyApp.class);  
    14.                
    15.              Path in = new Path(args[1]);  
    16.              Path out = new Path(args[2]);  
    17.                
    18.              // 设置job的各种详细参数      
    19.              job.setJobName("my-app");  
    20.              job.setInputPath(in);  
    21.              job.setOutputPath(out);  
    22.              job.setMapperClass(MyMapper.class);  
    23.              job.setReducerClass(MyReducer.class);  
    24.   
    25.              //提交job  
    26.              JobClient.runJob(job);  
    27.              return 0;  
    28.            }  
    29.              
    30.            public static void main(String[] args) throws Exception {  
    31.              // 让ToolRunner执行   
    32.              int res = ToolRunner.run(new Configuration(), new MyApp(), args);  
    33.                
    34.              System.exit(res);  
    35.            }  
    36.          }  

  • 相关阅读:
    白话数字签名(3)——Web程序中的数字签名(转)
    Android下基于XML的Graphics (转)
    js获取html页面传参
    nodejs教程:安装express及配置app.js文件
    Android中的Selector(转)
    org.apache.tools.zip.*和org.apache.commons.httpclient.*实现远程文件打包下载,支持中文文件名(转)
    EditText中进行文字截获和事件监听——(转载)
    常用js验证和常用方法汇总
    解决AVD的“SDL_app:emulator.exe应用程序错误”
    白话数字签名(2)——软件&设备(转)
  • 原文地址:https://www.cnblogs.com/zlslch/p/6431833.html
Copyright © 2011-2022 走看看