国产探花免费观看_亚洲丰满少妇自慰呻吟_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.



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 读书| 上饶市| 安福县| 于都县| 会同县| 康保县| 南陵县| 湘潭市| 汉阴县| 肃南| 南通市| 云霄县| 新密市| 资中县| 民和| 无棣县| 岱山县| 辽源市| SHOW| 康乐县| 闽侯县| 永新县| 固始县| 麟游县| 海门市| 安乡县| 泾源县| 中牟县| 含山县| 蒙城县| 凌源市| 固原市| 邵阳市| 淮南市| 综艺| 新乡县| 宁南县| 香港 | 西贡区| 澄江县| 德州市|