Yarn下分片和分块源代码分析
public class FileSplit extends InputSplit implements Writable {
private Path file;
private long start;
private long length;
private String[] hosts;
public FileSplit() {
}
public FileSplit(Path file, long start, long length, String[] hosts) {
this.file = file;
this.start = start;
this.length = length;
this.hosts = hosts;
}
public Path getPath() {
return this.file;
}
public long getStart() {
return this.start;
}
public long getLength() {
return this.length;
}
public String toString() {
return this.file + ":" + this.start + "+" + this.length;
}
public void write(DataOutput out) throws IOException {
Text.writeString(out, this.file.toString());
out.writeLong(this.start);
out.writeLong(this.length);
}
public void readFields(DataInput in) throws IOException {
this.file = new Path(Text.readString(in));
this.start = in.readLong();
this.length = in.readLong();
this.hosts = null;
}
public String[] getLocations() throws IOException {
if (this.hosts == null) {
return new String[0];
}
return this.hosts;
}
}
代码比较简单, 四部分组成 文件路径 ,启始位置,长度,Host列表
Host为什么是个列表
看分片的时候创建函数
splits.add(makeSplit(path, length - bytesRemaining,
splitSize, blkLocations[blkIndex].getHosts()));
再来看块的源代码
public class BlockLocation {
private String[] hosts;
private String[] names;
private String[] topologyPaths;
private long offset;
private long length;
private boolean corrupt;
public BlockLocation() {
this(new String[0], new String[0], 0L, 0L);
}
public BlockLocation(String[] names, String[] hosts, long offset,
long length) {
this(names, hosts, offset, length, false);
}
public BlockLocation(String[] names, String[] hosts, long offset,
long length, boolean corrupt) {
if (names == null)
this.names = new String[0];
else {
this.names = names;
}
if (hosts == null)
this.hosts = new String[0];
else {
this.hosts = hosts;
}
this.offset = offset;
this.length = length;
this.topologyPaths = new String[0];
this.corrupt = corrupt;
}
public BlockLocation(String[] names, String[] hosts,
String[] topologyPaths, long offset, long length) {
this(names, hosts, topologyPaths, offset, length, false);
}
public BlockLocation(String[] names, String[] hosts,
String[] topologyPaths, long offset, long length, boolean corrupt) {
this(names, hosts, offset, length, corrupt);
if (topologyPaths == null)
this.topologyPaths = new String[0];
else
this.topologyPaths = topologyPaths;
}
public String[] getHosts() throws IOException {
if ((this.hosts == null) || (this.hosts.length == 0)) {
return new String[0];
}
return this.hosts;
}
public String[] getNames() throws IOException {
if ((this.names == null) || (this.names.length == 0)) {
return new String[0];
}
return this.names;
}
public String[] getTopologyPaths() throws IOException {
if ((this.topologyPaths == null) || (this.topologyPaths.length == 0)) {
return new String[0];
}
return this.topologyPaths;
}
public long getOffset() {
return this.offset;
}
public long getLength() {
return this.length;
}
public boolean isCorrupt() {
return this.corrupt;
}
public void setOffset(long offset) {
this.offset = offset;
}
public void setLength(long length) {
this.length = length;
}
public void setCorrupt(boolean corrupt) {
this.corrupt = corrupt;
}
public void setHosts(String[] hosts) throws IOException {
if (hosts == null)
this.hosts = new String[0];
else
this.hosts = hosts;
}
public void setNames(String[] names) throws IOException {
if (names == null)
this.names = new String[0];
else
this.names = names;
}
public void setTopologyPaths(String[] topologyPaths) throws IOException {
if (topologyPaths == null)
this.topologyPaths = new String[0];
else
this.topologyPaths = topologyPaths;
}
public String toString() {
StringBuilder result = new StringBuilder();
result.append(this.offset);
result.append(',');
result.append(this.length);
if (this.corrupt) {
result.append("(corrupt)");
}
for (String h : this.hosts) {
result.append(',');
result.append(h);
}
return result.toString();
}
}
Yarn下分片和分块源代码分析的更多相关文章
- 【转载】linux环境下tcpdump源代码分析
linux环境下tcpdump源代码分析 原文时间 2013-10-11 13:13:02 CSDN博客 原文链接 http://blog.csdn.net/han_dawei/article/d ...
- linux环境下tcpdump源代码分析
Linux 环境下tcpdump 源代码分析 韩大卫@吉林师范大学 tcpdump.c 是tcpdump 工具的main.c, 本文旨对tcpdump的框架有简单了解,只展示linux平台使用的一部分 ...
- Flink on Yarn模式启动流程源代码分析
此文已由作者岳猛授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. Flink on yarn的启动流程可以参见前面的文章 Flink on Yarn启动流程,下面主要是从源码角 ...
- Android4.42-Setting源代码分析之蓝牙模块Bluetooth(下)
接着上一篇Android4.42-Settings源代码分析之蓝牙模块Bluetooth(上) 继续蓝牙模块源代码的研究 THREE.蓝牙模块功能实现 switch的分析以及本机蓝牙重命名和可见性的分 ...
- MapReduce源代码分析之JobSubmitter(一)
JobSubmitter.顾名思义,它是MapReduce中作业提交者,而实际上JobSubmitter除了构造方法外.对外提供的唯一一个非private成员变量或方法就是submitJobInter ...
- 转:RTMPDump源代码分析
0: 主要函数调用分析 rtmpdump 是一个用来处理 RTMP 流媒体的开源工具包,支持 rtmp://, rtmpt://, rtmpe://, rtmpte://, and rtmps://. ...
- Hadoop源代码分析
http://wenku.baidu.com/link?url=R-QoZXhc918qoO0BX6eXI9_uPU75whF62vFFUBIR-7c5XAYUVxDRX5Rs6QZR9hrBnUdM ...
- Kafka 源代码分析之LogManager
这里分析kafka 0.8.2的LogManager logmanager是kafka用来管理log文件的子系统.源代码文件在log目录下. 这里会逐步分析logmanager的源代码.首先看clas ...
- Yarn下Map数控制
public List<InputSplit> getSplits(JobContext job) throws IOException { long minSize = Math.max ...
随机推荐
- 转 如何在secureCRT上设置常用的快捷输出按钮栏听语音
https://jingyan.baidu.com/article/5d6edee2f32de199eadeec25.html 要注意secureCRT的版本,建议下载最新版本的软件 ...
- getopt 学习
https://www.cnblogs.com/qingergege/p/5914218.html
- 网络编程api总结
1.socket函数创建一个socket连接,此时该socket连接为主动式. fd(int)->fd(struct fd)->file->sock:sock->file 2. ...
- Sqlite操作的一些关键类的官方说明与Intent的startactivityforresult方法
Intent: 该功能可以用于通过intent来跳转界面时候传递信号给原理的页面,以便做出一些处理: sqlite的使用: 该方法得到的sqlitedatabase可读可写,而getreadabled ...
- Kudu1.1.0 、 Kudu1.2.0 Kudu1.3.0的版本信息异同比较
不多说,直接上干货! Kudu1.1.0 新特性 python API升级,具备JAVA C++client一样的功能(从0.3版本直接升级到1.1),主要的点如下: 1.1. 改进了Parial ...
- 如何修改FlashFXP默认编辑工具使用记事本打开
FlashFXP如果不设置默认编辑工具,那么当你打开html文档的时候,默认会用word打开,很不方便,其实简单的设置下,可以默认以任何工具打开.具体设置方法如下: 选项>>关联文件. 然 ...
- React.js 小书 Lesson6 - 使用 JSX 描述 UI 信息
作者:胡子大哈 原文链接:http://huziketang.com/books/react/lesson6 转载请注明出处,保留原文链接和作者信息. 这一节我们通过一个简单的例子讲解 React.j ...
- vue学习中遇到的onchange、push、splice、forEach方法使用
最近在做vue的练习,发现有些js中的基础知识掌握的不牢,记录一下: 1.onchange事件:是在域的内容改变时发生,单选框与复选框改变后触发的事件. 2.push方法:向数组的末尾添加一个或多个元 ...
- DIV+CSS如何让图片和文字在同一行!
在div+css布局中,如果一行(或一个DIV)内容中有图片和文字的话,图片和文字往往会一个在上一个在下,这是一个新手都会遇到问题,我的解决方法有三: 1.添加CSS属性:vertical-align ...
- Android 程序结构介绍
创建好Android开发环境后,创建一个Android Project, 截图如下: