spark Master是spark集群的首脑,负责资源调度,任务分配,负载平衡等功能

以下是master启动流程概述

通过shell进行对master进行启动

首先看一下启动脚本more start-master.sh

此时我们知道最终调用的是org.apache.spark.deploy.master.Master

这是Master源码:

  1. private[spark] object Master extends Logging {
  2. val systemName = "sparkMaster"
  3. private val actorName = "Master"
  4.  
  5. //master启动的入口
  6. def main(argStrings: Array[String]) {
  7. SignalLogger.register(log)
  8. //创建SparkConf
  9. val conf = new SparkConf
  10. //保存参数到SparkConf
  11. val args = new MasterArguments(argStrings, conf)
  12. //创建ActorSystem和Actor
  13. val (actorSystem, _, _, _) = startSystemAndActor(args.host, args.port, args.webUiPort, conf)
  14. //等待结束
  15. actorSystem.awaitTermination()
  16. }
  17.  
  18. /**
  19. * Returns an `akka.tcp://...` URL for the Master actor given a sparkUrl `spark://host:port`.
  20. *
  21. * @throws SparkException if the url is invalid
  22. */
  23. def toAkkaUrl(sparkUrl: String, protocol: String): String = {
  24. val (host, port) = Utils.extractHostPortFromSparkUrl(sparkUrl)
  25. AkkaUtils.address(protocol, systemName, host, port, actorName)
  26. }
  27.  
  28. /**
  29. * Returns an akka `Address` for the Master actor given a sparkUrl `spark://host:port`.
  30. *
  31. * @throws SparkException if the url is invalid
  32. */
  33. def toAkkaAddress(sparkUrl: String, protocol: String): Address = {
  34. val (host, port) = Utils.extractHostPortFromSparkUrl(sparkUrl)
  35. Address(protocol, systemName, host, port)
  36. }
  37.  
  38. /**
  39. * Start the Master and return a four tuple of:
  40. * (1) The Master actor system
  41. * (2) The bound port
  42. * (3) The web UI bound port
  43. * (4) The REST server bound port, if any
  44. */
  45. def startSystemAndActor(
  46. host: String,
  47. port: Int,
  48. webUiPort: Int,
  49. conf: SparkConf): (ActorSystem, Int, Int, Option[Int]) = {
  50. val securityMgr = new SecurityManager(conf)
  51. //利用AkkaUtils创建ActorSystem
  52. val (actorSystem, boundPort) = AkkaUtils.createActorSystem(systemName, host, port, conf = conf,
  53. securityManager = securityMgr)
  54. //通过ActorSystem创建Actor -> actorSystem.actorOf, 就会执行Master的构造方法->然后执行生命周期方法
  55. val actor = actorSystem.actorOf(
  56. Props(classOf[Master], host, boundPort, webUiPort, securityMgr, conf), actorName)
  57. val timeout = AkkaUtils.askTimeout(conf)
  58. val portsRequest = actor.ask(BoundPortsRequest)(timeout)
  59. val portsResponse = Await.result(portsRequest, timeout).asInstanceOf[BoundPortsResponse]
  60. (actorSystem, boundPort, portsResponse.webUIPort, portsResponse.restPort)
  61. }
  62. }

最终会通过Master的main函数进行最jvm进程启动

spark Master启动流程的更多相关文章

  1. Spark-源码-Spark-StartAll Master Worler启动流程

    Spark start-all>> """Master启动流程""" Master类 class Master( host: S ...

  2. Spark启动流程(Standalone)- master源码

    Master源码 package org.apache.spark.deploy.master //伴生类 private[deploy] class Master( override val rpc ...

  3. Spark Worker启动Driver和Executor工作流程

    二:Spark Worker启动Driver源码解析 case LaunchDriver(driverId, driverDesc) => { logInfo(s"Asked to l ...

  4. Spark启动流程(Standalone)-分析

    1.start-all.sh脚本,实际上执行java -cp Master 和 java -cp Worker 2.Master 启动时首先穿件一个RpcEnv对象,负责管理所有通信逻辑 3.Mast ...

  5. Spark基本工作流程及YARN cluster模式原理(读书笔记)

    Spark基本工作流程及YARN cluster模式原理 转载请注明出处:http://www.cnblogs.com/BYRans/ Spark基本工作流程 相关术语解释 Spark应用程序相关的几 ...

  6. Spark配置&启动脚本分析

    本文档基于Spark2.0,对spark启动脚本进行分析. date:2016/8/3 author:wangxl Spark配置&启动脚本分析 我们主要关注3类文件,配置文件,启动脚本文件以 ...

  7. 【Spark2.0源码学习】-4.Master启动

         Master作为Endpoint的具体实例,下面我们介绍一下Master启动以及OnStart指令后的相关工作   一.脚本概览      下面是一个举例: /opt/jdk1..0_79/ ...

  8. 【Spark】部署流程的深度了解

    文章目录 Spark核心组件 Driver Executor Spark通用运行流程图 Standalone模式运行机制 Client模式流程图 Cluster模式流程图 On-Yarn模式运行机制 ...

  9. Storm启动流程简介

    storm启动流程          storm是一个流行的开源的,分布式实时处理框架,关于storm的基本介绍可以参加这篇官方文档.大致的拓扑结构如图所示:        其中Nimbus是一个后台 ...

随机推荐

  1. SpringBoot框架(5)-- @EableAutoConfiguration项目应用

    场景:在项目中想在当前maven项目中自动装配其他自定义的Maven项目,例如,创建数据库配置中心,被夺多个maven引用,希望简单配置,就实现springboot自动装配数据库配置类. 由此我们联想 ...

  2. registry搭建及镜像管理

    registry 的搭建 docker pull registry:2 docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 -- ...

  3. Codeforces Round #302 (Div. 2) D. Destroying Roads 最短路 删边

    题目:有n个城镇,m条边权为1的双向边让你破坏最多的道路,使得从s1到t1,从s2到t2的距离分别不超过d1和d2. #include <iostream> #include <cs ...

  4. ELK结合logback

    之前ELK的安装可以查看前面一篇博客 下面是我的logback的配置文件,通过logback的appender直接导入logstash <?xml version="1.0" ...

  5. js for循环中i++与++i有什么区别

    平时都是这样写的for循环, 1 2 3 for(var i = 0; i < 20 ; i++){        ....       } 但我看有的人这样写 for (var i = 0; ...

  6. onload,domcontentload区别+onload详解

    todo onLoad是的在页面所有文件加载完成后执行 DomContentLoad是Dom加载完成后执行,不必等待样式脚本和图片加载 domContentLoad更为合理, 原理: 如果是webki ...

  7. socket的补充

  8. legend3---Windows 7/8/10 系统下Laravel框架的开发环境安装及部署详解(Vagrant + Homestead)

    legend3---Windows 7/8/10 系统下Laravel框架的开发环境安装及部署详解(Vagrant + Homestead) 一.总结 一句话总结: 1.安装的话就是下载好git,va ...

  9. java中FastJson的json类型转换

    JSON Gson: 来自Google,功能全面.快速.简洁.面向对象.数据传递和解析方便. Jackson:来源FasterXML项目,社区活跃,更新快 解析速度和效率比Gson快,但无法按需解析, ...

  10. leetcode234 回文链表 两种做法(stack(空间非O(1)),空间O(1))

    link: leetcode234 回文链表 方法1, 快慢指针,把前半部分存入栈中和后半部分比较 public boolean isPalindrome(ListNode head) { if(he ...