当Samza ApplicationMaster启动时,它做以下的事情:

  1. 通过STREAMING_CONFIG环境变量从YARN获取配置信息(configuration)
  2. 在随机端口上 启动一个JMX server
  3. 实例化一个metrics registry和reporter来追踪计量信息
  4. 将AM向YARN的RM注册
  5. 使用每个stream的PartitionManager来获取总共的partition数量
  6. 从Samza的job configuration里获取总的container数量
  7. 将partition分给container(在Samza AM的dashboard里,称为Task Group)
  8. 为每个container向YARN发送一个ResourceRequest
  9. 每秒向YARN RM poll一次,检查allocated and released containers
SamzaAppMaster的实现
 
并不是提交AppMaster,只是向RM注册这个AppMaster。因为此时,AppMaster已经启动了。
1.在SamzaAppMasterLifecycle对象的onInit()方法中,使用amCient.registerApplicationMaster
2    val response = amClient.registerApplicationMaster (host , state.rpcPort, "%s:%d" format (host, state. trackingPort))
 
amClient对象的类:
 
org.apache.hadoop.yarn.client.api.async.AMRMClientAsync<T extends org.apache.hadoop.yarn.client.api.AMRMClient.ContainerRequest>

 

AMRMClientAsync handles communication with the ResourceManager and provides asynchronous updates on events such as container allocations and completions. It contains a thread that sends periodic heartbeats to the ResourceManager. It should be used by implementing a CallbackHandler:

 class MyCallbackHandler implements AMRMClientAsync.CallbackHandler {
public void onContainersAllocated(List<Container> containers) {
[run tasks on the containers]
} public void onContainersCompleted(List<ContainerStatus> statuses) {
[update progress, check whether app is done]
} public void onNodesUpdated(List<NodeReport> updated) {} public void onReboot() {}
}

The client's lifecycle should be managed similarly to the following:

 AMRMClientAsync asyncClient =
createAMRMClientAsync(appAttId, 1000, new MyCallbackhandler());
asyncClient.init(conf);
asyncClient.start();
RegisterApplicationMasterResponse response = asyncClient
.registerApplicationMaster(appMasterHostname, appMasterRpcPort,
appMasterTrackingUrl);
asyncClient.addContainerRequest(containerRequest);
[... wait for application to complete]
asyncClient.unregisterApplicationMaster(status, appMsg, trackingUrl);
asyncClient.stop();
这个类是用来做为一个Client和RM进行通信,并且注册一个用于回调的对象来处理container 的allocation和completion事件。它启动一个线程,周期性地发送hearbeat至ResourceManager

Samza的ApplicationMaster的更多相关文章

  1. Samza文档翻译 : Architecture

    http://samza.incubator.apache.org/learn/documentation/0.7.0/introduction/architecture.html Samza由三层组 ...

  2. Samza在YARN上的启动过程 =》 之二 submitApplication

    首先,来看怎么构造一个org.apache.hadoop.yarn.client.api.YarnClient class ClientHelper(conf: Configuration) exte ...

  3. Samza在YARN上的启动过程 =》 之一

    运行脚本,提交job 往YARN提交Samza job要使用run-job.sh这个脚本. samza-example/target/bin/run-job.sh  --config-factory= ...

  4. Samza/KafkaAnalysizing

    Apache Samza is a distributed stream processing framework. It uses Apache Kafka for messaging, and A ...

  5. Apache Samza - Reliable Stream Processing atop Apache Kafka and Hadoop YARN

    http://engineering.linkedin.com/data-streams/apache-samza-linkedins-real-time-stream-processing-fram ...

  6. 流式大数据处理的三种框架:Storm,Spark和Samza

    许多分布式计算系统都可以实时或接近实时地处理大数据流.本文将对三种Apache框架分别进行简单介绍,然后尝试快速.高度概述其异同. Apache Storm 在Storm中,先要设计一个用于实时计算的 ...

  7. [转载]流式大数据处理的三种框架:Storm,Spark和Samza

    许多分布式计算系统都可以实时或接近实时地处理大数据流.本文将对三种Apache框架分别进行简单介绍,然后尝试快速.高度概述其异同. Apache Storm 在Storm中,先要设计一个用于实时计算的 ...

  8. 如何设置Samza的metrics

    参考这个里边对API的调用 http://samza.incubator.apache.org/learn/documentation/0.7.0/container/metrics.html 参考这 ...

  9. Samza文档翻译 : Comparison Introduction

    http://samza.incubator.apache.org/learn/documentation/0.7.0/comparisons/introduction.html 这里有一些使得Sam ...

随机推荐

  1. Service通信详解

    1.使用Intent进行异步通讯 在Service任务一旦完成后,就发送广播.开发者只需要实现一个BroadcastReceiver来监听响应既可. Activity.startService启动in ...

  2. win32进阶之路:程序托盘图标+右键弹出菜单

     开场白 本次介绍两个非常棒且实用的技巧:程序托盘图标和右键弹出菜单,效果如下图. 程序托盘图标用了迅雷的图标,右键点击时候会弹出三个选项的菜单. 程序托盘图标设置 我会用尽可能清晰明了的步骤介绍方式 ...

  3. python遍历目录文件脚本的示例

    例子 自己写的一个Python遍历文件脚本,对查到的文件进行特定的处理.没啥技术含量,但是也记录一下吧. 代码如下 复制代码 #!/usr/bin/python# -*- coding: utf-8 ...

  4. TFS2012常见问题及解答

    1.删除workItem工作项(包括Bug,用户场景,任务等) 需要利用到witadmin工具,目录在cd %programfiles%\Microsoft Visual Studio 11.0\Co ...

  5. VS2013编译WEBKIT

    0,安装VS2013:DXSDK_Jun10.exe:QuickTimeSDK.exe 1,WebKit-r174650.tar.bz2 以管理员解压(非管理员解压最后几下总是报错) 2,设置环境变量 ...

  6. 《C#高级编程》

    <C#高级编程>是一本真正的C#技术"字典",长达36章.1200页的内容-涵盖了C#..NET各个方面的基础内容. 当然这本书我没有真正的看过一遍,只是在需要的时候才 ...

  7. java学习笔记_GUI(2)

    import javax.swing.*; import java.awt.event.*; class Gui implements ActionListener{ JButton button = ...

  8. 关于C#正则表达式MatchCollection类的总结,正则表达式的应用

    认识MatchCollection 类 表示通过以迭代方式将正则表达式模式应用于输入字符串所找到的成功匹配的集合. 命名空间:  System.Text.RegularExpressions 属性:C ...

  9. 在Windows下设置环境变量 运行mysql程序变得更容易

    在Windows下设置环境变量,点开始菜单,右键单击我的电脑--属性--高级--环境变量 可以看到PATH的变量是这样的: C:\WINDOWS;C:\WINDOWS\COMMAND   为了让运行m ...

  10. C# 获取中文星期的两种方法

    //方法一 public string Week() { string[] weekdays = { "星期日", "星期一", "星期二" ...