国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

瑣碎-hadoop1.X和2.X的區別

2019-11-14 21:36:05
字體:
來源:轉載
供稿:網友
瑣碎-hadoop1.X和2.X的區別

1. jobtracker做了分離,分成了resourceManager和nodemanager;

2. MR變成了和HBase和Hive等一樣的yarn上面的一個應用;

3. 1.x的默認塊大小為64M,2.x的默認塊大小為128M;

4. 在2.x中除了datanode要向namenode報告status,nodemanager也要向ResourceManager報告status

5.MR API差別

舊的WordCount

 1 package org.apache.hadoop.maPRed; 2  3 ... ... 4  5 public class WordCount extends Configured implements Tool { 6    7   public static class MapClass extends MapReduceBase 8     implements Mapper<LongWritable, Text, Text, IntWritable> { 9     10     ... ...11     12     public void map(LongWritable key, Text value, 13                     OutputCollector<Text, IntWritable> output, 14                     Reporter reporter) throws IOException {15       ... ...16     }17   }18 19   public static class Reduce extends MapReduceBase20     implements Reducer<Text, IntWritable, Text, IntWritable> {21     22     public void reduce(Text key, Iterator<IntWritable> values,23                        OutputCollector<Text, IntWritable> output, 24                        Reporter reporter) throws IOException {25      ... ...26     }27   }28   29   static int printUsage() {30     System.out.println("wordcount [-m <maps>] [-r <reduces>] <input> <output>");31     ToolRunner.printGenericCommandUsage(System.out);32     return -1;33   }34    35   public int run(String[] args) throws Exception {36     ... ...37     return 0;38   }39   public static void main(String[] args) throws Exception {40     int res = ToolRunner.run(new Configuration(), new WordCount(), args);41     System.exit(res);42   }43 44 }

新的WordCount

 1 package org.apache.hadoop.examples; 2  3 ... ... 4  5 public class WordCount { 6  7   public static class TokenizerMapper  8        extends Mapper<Object, Text, Text, IntWritable>{ 9     10     ... ... 11       12     public void map(Object key, Text value, Context context13                     ) throws IOException, InterruptedException {14       ... ...15     }16   }17   18   public static class IntSumReducer 19        extends Reducer<Text,IntWritable,Text,IntWritable> {20     private IntWritable result = new IntWritable();21 22     public void reduce(Text key, Iterable<IntWritable> values, 23                        Context context24                        ) throws IOException, InterruptedException {25       ... ...26     }27   }28 29   public static void main(String[] args) throws Exception {30     ... ...31     System.exit(job.waitForCompletion(true) ? 0 : 1);32   }33 }

6.



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 同心县| 宜君县| 安新县| 鄂温| 淳安县| 扬州市| 永寿县| 绩溪县| 仙游县| 阆中市| 庄河市| 余干县| 保靖县| 华亭县| 鹤庆县| 清远市| 苍梧县| 白城市| 龙口市| 河东区| 永清县| 庆元县| 昆明市| 明光市| 拉萨市| 沭阳县| 灌南县| 盐边县| 阜平县| 长汀县| 内江市| 益阳市| 沾化县| 舞阳县| 三门峡市| 清流县| 遂宁市| 安塞县| 林甸县| 宁津县| 枝江市|