Spark系列(九)DAGScheduler工作原理
以wordcount为示例进行深入分析
| 1 | |
| 33 | ) { |
| 46 | logInfo("Submitting " + tasks.size + " missing tasks from " + stage + " (" + stage.rdd + ")") |
| 47 | stage.pendingTasks ++= tasks |
| 48 | logDebug("New pending tasks: " + stage.pendingTasks) |
| 49 | // 对stage的task创建TaskSet对象,调用TaskScheduler的submitTasks()方法提交TaskSet |
| 50 | taskScheduler.submitTasks( |
| 51 | new TaskSet(tasks.toArray, stage.id, stage.newAttemptId(), stage.jobId, properties)) |
| 52 | stage.latestInfo.submissionTime = Some(clock.getTimeMillis()) |
| 53 | } |
| 54 | |
| 55 | ...................... |
| 56 | } |
getPreferredLocsInternal
功能:
计算每个task对应的partition最佳位置,从stage的最后一个rdd开始查找,看rdd的partition是否有被cache、chencjpoint,如果有那么task的最佳位置就被cache或者checkpoint的partition的位置
调用过程:
submitMissingTasks->getPreferredLocs->getPreferredLocsInternal
| 1 | // 计算每个task对应的partition最佳位置 |
| 2 | // 从stage的最后一个rdd开始查找,看rdd的partition是否有被cache、chencjpoint, |
| 3 | // 如果有那么task的最佳位置就被cache或者checkpoint的partition的位置 |
| 4 | private def getPreferredLocsInternal( |
| 5 | rdd: RDD[_], |
| 6 | partition: Int, |
| 7 | visited: HashSet[(RDD[_],Int)]) |
| 8 | : Seq[TaskLocation] = |
| 9 | { |
| 10 | // If the partition has already been visited, no need to re-visit. |
| 11 | // This avoids exponential path exploration. SPARK-695 |
| 12 | if (!visited.add((rdd,partition))) { |
| 13 | // Nil has already been returned for previously visited partitions. |
| 14 | return Nil |
| 15 | } |
| 16 | // If the partition is cached, return the cache locations |
| 17 | // 寻找rdd是否被缓存 |
| 18 | val cached = getCacheLocs(rdd)(partition) |
| 19 | if (!cached.isEmpty) { |
| 20 | return cached |
| 21 | } |
| 22 | // If the RDD has some placement preferences (as is the case for input RDDs), get those |
| 23 | // 寻找当前RDD是否被cachepoint |
| 24 | val rddPrefs = rdd.preferredLocations(rdd.partitions(partition)).toList |
| 25 | if (!rddPrefs.isEmpty) { |
| 26 | return rddPrefs.map(TaskLocation(_)) |
| 27 | } |
| 28 | // If the RDD has narrow dependencies, pick the first partition of the first narrow dep |
| 29 | // that has any placement preferences. Ideally we would choose based on transfer sizes, |
| 30 | // but this will do for now. |
| 31 | // 递归调用自己寻找rdd的父rdd,检查对应的partition是否被缓存或者checkpoint |
| 32 | rdd.dependencies.foreach { |
| 33 | case n: NarrowDependency[_] => |
| 34 | for (inPart <- n.getParents(partition)) { |
| 35 | val locs = getPreferredLocsInternal(n.rdd, inPart, visited) |
| 36 | if (locs != Nil) { |
| 37 | return locs |
| 38 | } |
| 39 | } |
| 40 | case _ => |
| 41 | } |
| 42 | // 如果stage从最后一个rdd到最开始的rdd,partiton都没有被缓存或者cachepoint, |
| 43 | // 那么task的最佳位置(preferredLocs)为Nil |
| 44 | Nil |
| 45 | } |
Spark系列(九)DAGScheduler工作原理的更多相关文章
- Spark系列(十)TaskSchedule工作原理
工作原理图 源码分析: 1.) 25 launchedTask = true 26 } 27 } catch { 28 ...
- Spark系列(八)Worker工作原理
工作原理图 源代码分析 包名:org.apache.spark.deploy.worker 启动driver入口点:registerWithMaster方法中的case LaunchDriver ...
- line-height系列——定义和工作原理总结
一.line-height的定义和工作原理总结 line-height的属性值: normal 默认 设置合理的行间距. number 设置数字,此数字会与当前的字体尺寸相乘来设置行间距li ...
- MySQL系列(九)--InnoDB索引原理
InnoDB在MySQL5.6版本后作为默认存储引擎,也是我们大部分场景要使用的,而InnoDB索引通过B+树实现,叫做B-tree索引.我们默认创建的 索引就是B-tree索引,所以理解B-tree ...
- 【原】Learning Spark (Python版) 学习笔记(三)----工作原理、调优与Spark SQL
周末的任务是更新Learning Spark系列第三篇,以为自己写不完了,但为了改正拖延症,还是得完成给自己定的任务啊 = =.这三章主要讲Spark的运行过程(本地+集群),性能调优以及Spark ...
- 49、Spark Streaming基本工作原理
一.大数据实时计算介绍 1.概述 Spark Streaming,其实就是一种Spark提供的,对于大数据,进行实时计算的一种框架.它的底层,其实,也是基于我们之前讲解的Spark Core的. 基本 ...
- “Ceph浅析”系列之五——Ceph的工作原理及流程
本文将对Ceph的工作原理和若干关键工作流程进行扼要介绍.如前所述,由于Ceph的功能实现本质上依托于RADOS,因而,此处的介绍事实上也是针对RADOS进行.对于上层的部分,特别是RADOS GW和 ...
- JSP JSP工作原理 JSP语法 JSP声明 JSP注释 JSP指令 jsp九大隐式/内置对象
1 什么是JSP 1)为什么说,Servlet是一个动态Web开发技术呢? Servlet是基于服务端的一种动态交互技术, HttpServletRequest表示客户端到服务端的 ...
- 4.Apache Spark的工作原理
Apache Spark的工作原理 1 Why Apache Spark 2 关于Apache Spark 3 如何安装Apache Spark 4 Apache Spark的工作原理 5 spark ...
随机推荐
- Servlet的应用
1.重定向 HttpServletRequest接口提供的sendRedirect()方法用于生产302响应码和Location响应头,从而通知客户端去重新访问Location响应头中指定的U ...
- P25、面试题1:赋值运算符函数
题目:如下为类型CMyString的声明,请为该类型添加赋值运算符函数. class CMyString { public: CMyString(char* pData = NULL); CMyStr ...
- ios7 webapp touch bug
// ios7 touchstart bug if(navigator.userAgent.indexOf("iPhone OS 7") != -1){ var startX = ...
- VC6.0下string不能用pusk_back,可用+=代替
2013-09-11 21:14:32 在VS下运行正确的代码,拿到VC6.0下,编译出错,提示: error C2039: 'push_back' : is not a member of 'bas ...
- Fucking "pkg-config not found"
If you got pkg-config not found error in gnu auto tools then, you must install the related librarys ...
- VS2005控制台程序修改nb0文件
VS2005控制台程序修改nb0文件 我们要实现的功能就是通过CMD传递进来的值来在nb0文件末尾增加版本信息,新建控制台程序,自动生成的main函数如下,默认的代码非常简单: int _tmain( ...
- apache启动报错(98)Address already in use: make_sock: could not bind to...
# /etc/init.d/httpd startStarting httpd: (98)Address already in use: make_sock: could not bind to ad ...
- 【Todo】【转载】ES6的学习记录
粗略看了一遍React的内容,然后看了 ES6 的入门文章: http://es6.ruanyifeng.com/#docs/intro 通过这个链接可以查看浏览器对 ES6 的支持程度: http: ...
- Python模块整理(三):子进程模块subprocess
文章 原始出处 http://ipseek.blog.51cto.com/1041109/807513. 本来收集整理网络上相关资料后整理: 从python2.4版本开始,可以用subprocess这 ...
- WEB-INF目录与META-INF目录的作用
/WEB-INF/web.xml Web应用程序配置文件,描述了 servlet 和其他的应用组件配置及命名规则. /WEB-INF/classes/包含了站点所有用的 class 文件,包括 ser ...