博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
琐碎-hadoop1.X和2.X的区别
阅读量:7020 次
发布时间:2019-06-28

本文共 2387 字,大约阅读时间需要 7 分钟。


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
{ 9 10 ... ...11 12 public void map(LongWritable key, Text value, 13 OutputCollector
output, 14 Reporter reporter) throws IOException {15 ... ...16 }17 }18 19 public static class Reduce extends MapReduceBase20 implements Reducer
{21 22 public void reduce(Text key, Iterator
values,23 OutputCollector
output, 24 Reporter reporter) throws IOException {25 ... ...26 }27 }28 29 static int printUsage() {30 System.out.println("wordcount [-m
] [-r
]
");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
{ 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
{20 private IntWritable result = new IntWritable();21 22 public void reduce(Text key, Iterable
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.

 


 

转载于:https://www.cnblogs.com/admln/p/trivial-1-xdif2-x.html

你可能感兴趣的文章
图片压缩工具Thumbnailator的使用
查看>>
安装tensorflow
查看>>
LintCode_469 等价二叉树
查看>>
UVALive3261 UVA1640 POJ2282 HDU1663 ZOJ2392 The Counting Problem【进制】
查看>>
Mathematica开始学习,
查看>>
Gulp 简单的开发环境搭建
查看>>
linux基础-网络基础知识篇
查看>>
使用MulticastSocket实现多点广播
查看>>
网盘链接
查看>>
评论发布信息可插入QQ表情
查看>>
iOS,多媒体,地图相关
查看>>
[C++基础]008_类的构造函数和析构函数
查看>>
python之字符编码(二)
查看>>
linux常用英文单词记录
查看>>
犯了一个错误
查看>>
如何访问嵌套母版页中的控件
查看>>
让你欲罢不能:你心愿我听见了
查看>>
【机器学习】--时间序列算法从初识到应用
查看>>
自定义侧滑菜单
查看>>
js8月-4号,,思想
查看>>