启动流程图

mk-assignments

功能:对当前集群中所有Topology进行新一轮的任务调度。

实现源码路径: 
\apache-storm-0.9.4\storm-core\src\clj\backtype\storm\daemon\ nimbus.clj

方法原型:

defnk mk-assignments [nimbus :scratch-topology-id nil]
 
方法说明:
  1. 参数nimbus为nimbus-data对象,scratch-topology-id为提交的Topology id.
  2. 从nimbus中依次获取conf、storm-cluster-state。
  3. 获取当前所有活跃的topology的id集合。
  4. 根据活跃的topology id调用read-topology-details方法,获取TopologyDetails信息并返回<storm-id,TopologyDetails>集合。
  5. 根据<storm-id,TopologyDetails>集合创建topologies对象。
  6. 获取已分配资源的Topology的id集合。
  7. 根据已分配资源的Topology id获取每个Topology的任务分配情况assigments,并返回<storm-id,Assigment>集合existing-assignments,除了scratch-topology-id指定的Topology不会获取它的Assigments。
  8. 调用compute-new-topology->executor->node+port方法获为所有Topology计算新的调度,返回topology->executor->node+port.
  9. 调用basic-supervisor-details-map从Zookeeper中获取所有SupervisorInfo信息,返回<supervisor-id,supervisorDetails>集合。
  10. 对第8步返回的结果集中的每一项进行遍历构造新的Assignment对象集合new-assignments,Assigmnet定义如下: 
    (defrecord Assignent [master-code-dir node->host executor->node+port executor->start-time-secs]) 
    master-code-dir:Nimbus在本地保存Topology信息路劲,主要包括stormjar.jar、stormcode.ser、stormconf.ser. 
    node->host:该Topology分配的<supervisor-id,hostname>集合. 
    executor->node+port:该Topology中executor的分配情况,node为supervisor-id,port为端口号。 
    executor->start-time-secs:该Topology对用的supervisor的启动时间.
  11. 比较new-assignments与existing-assignments中的每一项是否有差异,如果没有就打印一条提示信息,如果有就将该Topology在Zookeeper中保存的调度结果更新为new-assignments。
  12. 计算new-assignment中的每一项新增加的slot并进行分配。(新增的solt通过new-assignment中的node+port减去existing-assignment中的node+port得到,返回为<topology-id,WorkerSlot>集合) 
    WorkerSlot格式为{ nodeId port }

功能总结: 
获取已分配资源的Topology的任务分配情况<storm-id,Assigment>集合(existing-assignments),获取活跃的Topology信息<storm-id,TopologyDetails>集合创建topologies对象。然后调用compute-new-topology->executor->node+port方法获为所有Topology计算新的调度,返回topology->executor->node+port再构造Assigmnet对象集。

compute-new-topology->executor->node+port

函数原型:

defn compute-new-topology->executor->node+port [nimbus existing-assignments topologies scratch-topology-id]

参数说明: 
nimbus:nimbus-data对象。 
existing-assignments:当前已经分配的的任务,格式<topology-id,Assignment>。 
Topologies:当前活跃的Topology,格式<storm-id,TopologyDetails>. 
scratch-topology-id:需要重新调度的topology-id.

  1. 调用compute-topology->executors方法根据existing-assignments中的topology-id获取<topology-id,executors>集合,与调用compute-executors方法效果作用一样。
  2. 调用update-all-hearbeats!更新上一步中executor中的心跳信息.
  3. 调用compute-topology->alive-executors获取<topology-id,alive-executors>集合,每个topology-id对应的活跃的executor.
  4. 调用compute-supervisor->dead-ports获取<supervisor-id,dead-ports>集合。
  5. 调用compute-topology->scheduler-assignment获取<topology-id,Scheduler-AssignmentImpl>集合.(topology-id对用的任务分配情况Scheduler-AssignmentImpl == <ExecutorDetails,WorkerSlot>).
  6. 根据参数topologies中的topology-id进行条件过滤,该topology中所有executor为空或者topology中的所有executor不等于Topology中活跃的executor或者该Topology的num-use-workers小于其指定的num-worker,过滤后的结果集群赋值给missing-assignmnet-topologies.
  7. 调用all-scheduling-slots方法获取<node-id,port>集合。
  8. 调用read-all-supervisor-details方法获取<supervisor-id,supervisorDetails>集合。
  9. 根据参数nimbus、第5步、第8步的结果集构造Cluster对象。
  10. 调用nimbus中的scheduler方法进行任务调度。
  11. 从Cluster对象中获取重新调度完之后的所有Assignments作为new-scheduler-assignment,格式为<topology-id,SchedulerAssignment>集合。
  12. 调用compute-topology->executor->node+port将第11步的结果集转换为<topology-id,{executor[node port]}>集合。
  13. 调用basic-supervisor-details-map将Zookeeper中记录的所有SupervisorInfo都转换为SupervisorDetails,返回<supervisor-id,SuperviosrDetails>集合.

流程图:

compute-executor

函数原型:

defn- compute-executors [nimbus storm-id]

函数实现说明:

  1. 获取storm-id(topology-id)对用的stormBase中component-executors形象(每个组件的并行度)。
  2. 获取storm-id对应的storm-conf配置。
  3. 获取storm-id对应Topology.
  4. 调用storm-task-info获取<task-id,component-id>集合,其中task-id对该Topology的所有组件是全局递增的。
  5. 将第4步的结果集转换为<component-id,tasks>并按照升序排序。
  6. 将第1步的结果集<component-id,parallelism>与第5步的结果集进行join得到<component-id,[parallelism,tasks]>集合.
  7. 对第6步的结果集中的每一项进行处理,将tasks集合均匀分布到数目为parallelism的分区上。

功能总结:

获取storm-id对应Topology所有组件的并行度(线程数),获取该Topology中各组件TOPOLOGY_TASK信息,最后的结果使每个线程中均匀分布多个task运行。

Nimbus<一>Storm系列(五)架构分析之Nimbus启动过程的更多相关文章

  1. Storm系列(五)架构分析之Nimbus启动过程

    启动流程图   mk-assignments 功能:对当前集群中所有Topology进行新一轮的任务调度. 实现源码路径: \apache-storm-0.9.4\storm-core\src\clj ...

  2. Storm系列(九)架构分析之Supervisor-同步Nimbus的事件线程

    Supervisor由三个线程组成,一个计时器线程和两个事件线程. 计时器线程负责维持心跳已经更新Zookeeper中的状态,还负责每隔一定的时间将事件线程需要执行的事件添加到其对应的队列中. 两个事 ...

  3. Storm系列(七)架构分析之Scheduler-调度器[DefaultScheduler]

    Storm默认的任务调度器.实现如下: 1  (defn –prepare [this conf]) 2  (defn –schedule [this ^Topologies topologies ^ ...

  4. Storm系列(六)架构分析之Scheduler-调度器[EventScheduler]

    任务调度接口定义: 1  IScheduler{ 2      // conf为当前nimbus的stormp配置 3  void prepare(Map conf); // 初始化 4  // to ...

  5. Storm系列(十三)架构分析之Worker-维护ZMQ连接

    Worker根据Topology的定义及分配到自身的任务情况,计算出发出的消息被那些Task接收,由于Worker上分配的任务可能被调整,因此Worker需要定时的更新这些连接信息. ZMQ连接信息更 ...

  6. Storm系列(十一)架构分析之Supervisor-管理Worker进程的事件线程

    处理流程:   方法原型: (defn sync-processes [supervisor]) 函数说明: Supervisor是一个supervisor-data对象. 从local-state中 ...

  7. Linux第三周——跟踪分析内核的启动过程

    跟踪分析内核的启动过程实验 张潇月<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 这周主要学习的是对内核 ...

  8. Netty源码分析之客户端启动过程

    一.先来看一下客户端示例代码. public class NettyClientTest { public void connect(int port, String host) throws Exc ...

  9. linux内核学习之三 跟踪分析内核的启动过程

    一   前期准备工作       1 搭建环境 1.1下载内核源代码并编译内核 创建目录,并进入该目录: 下载源码: 解压缩,并进入该目录:xz -d linux-3.18.6.tar.xz tar ...

随机推荐

  1. MIT线性代数课程 总结与理解-第一部分

    概述 个人认为线性代数从三个角度,或者说三个工具来阐述了线性关系,分别是: 向量 矩阵 空间 这三个工具有各自的一套方法,而彼此之间又存在这密切的联系,通过这些抽象出来的工具可以用来干一些实际的活,最 ...

  2. C# 动态对象(dynamic)的用法

    说到正确用法,那么首先应该指出一个错误用法: 常有人会拿var这个关键字来和dynamic做比较.实际上,var和dynamic完全是两个概念,根本不应该放在一起做比较.var实际上是编译期抛给我们的 ...

  3. Web中的无状态含义

    REST架构设计是目前非常火热的概念,已经成为构建web服务时应该遵循的事实标准.REST约束中有一条很重要的规则是“无状态”,但“无状态”是个很抽象的概念,对刚刚接触的人来讲,很难深刻形象的理解.今 ...

  4. Qt 学习笔记

    继承自QObject 的Qt类都具有支持信号和槽的能力,并且在子类的实现代码中直接使用connect()函数 pwdLineEdit->setEchoMode(QLineEdit::Passwo ...

  5. Git 添加自己分支 pull request

    1.找到项目地址 这里,我们可以找到项目地址,比如:https://github.com/*****/Cplusplus_Thread_Lib,然后点击页面右上角的 "fork"  ...

  6. sql server 查询表基本信息sql

    SELECT c.name,t.name TYPE,c.max_length,c.precision,c.scale,p.value FROM sys.systypes t INNER JOIN sy ...

  7. HTML,JS禁止鼠标右键、禁止全选、复制、粘贴的方法

    禁止鼠标右键.禁止全选.复制.粘贴: oncontextmenu事件禁用右键菜单: js代码: document.oncontextmenu = function(){ event.returnVal ...

  8. token 小记

    最近了解下基于 Token 的身份验证,跟大伙分享下.很多大型网站也都在用,比如 Facebook,Twitter,Google+,Github 等等,比起传统的身份验证方法,Token 扩展性更强, ...

  9. 【.NET】上传文件,生成缩略图

    类名:Upload using System; using System.Collections; using System.ComponentModel; using System.Data; us ...

  10. A. Alyona and Numbers(CF ROUND 358 DIV2)

    A. Alyona and Numbers time limit per test 1 second memory limit per test 256 megabytes input standar ...