标签:
一、API的配置---Configuration类
1 <?xml version="1.0"?> 2 <configuration> 3 <property> 4 <name>color</name> 5 <value>yellow</value> 6 <description>Color</description> 7 </property> 8 9 <property> 10 <name>size</name> 11 <value>10</value> 12 <description>Size</description> 13 </property> 14 15 <property> 16 <name>weight</name> 17 <value>heavy</value> 18 <final>true</final> 19 <description>Weight</description> 20 </property> 21 22 <property> 23 <name>size-weigth</name> 24 <value>${size},${weight}</value> 25 <description>Size and weight</description> 26 </property> 27 </configuration>
1 Configuration conf = new Configuration(); 2 conf.addResource("configuration-1.xml"); 3 System.out.println(conf.get("color")); 4 System.out.println(conf.getInt("size",0)); 5 System.out.println(conf.get("breadth","wide"));
二、配置开发环境
1 public interface Tool extends Configurabel{ 2 int run(String [] args) throws Exception; 3 }
1 public class ConfigurationPrinter extends Configured implements Tool { 2 static{ 3 Configuration.addDefaultResource("hdfs-default.xml"); 4 Configuration.addDefaultResource("hdfs-site.xml"); 5 Configuration.addDefaultResource("mapred-default.xml"); 6 Configuration.addDefaultResource("mapred-site.xml"); 7 } 8 9 @Override 10 public int run(String[] args) throw Exception{ 11 Configuration conf = getconf(); 12 for(Entry<String,String> entry:conf){ 13 System.out.printf("%s=%s\n",entry.getKey(),entry.getValue()); 14 } 15 return 0; 16 } 17 18 public static void main(String[] args) throw Exception { 19 int exitcode = ToolRunner.run(new ConfigurationPrinter,args); 20 System.exit(exitCode); 21 } 22 23 24 }
三、编写单元测试
四、本地运行测试数据
五、在集群上运行
六、作业调优
七、MapReduce的工作流
标签:
原文地址:http://www.cnblogs.com/ChenKeng/p/4494869.html