当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. VS2010与QT的集成开发环境

    http://blog.csdn.net/hbsong75/article/details/9293773 QT与Java有点类似,也是一种跨平台的软件(当然在windows平台和Linux平台需要安 ...

  2. C盘空间不足,释放C盘空间

    最近电脑总是特别卡,后来发现C盘空间严重不足,只剩下几十兆,以前最严重的时候是剩下0kb可以,怎一个惨字了得... 我所知道的C盘空间不足会导致的几个主要问题有: 1)拷贝大文件会失败.因为拷贝和剪切 ...

  3. Cisco中删除flash通过tftp服务器恢复

    首先我们来看一下,Cisco路由器中的flash文件.通过show flash 命令来查看. 这时可以看到flash的版本是c1841-ipbasek9-mz.124-12.bin 下面我们删除这个f ...

  4. 资源汇集:nginx教程从入门到精通

    http://linux.cn/article-4279-1.html

  5. 如何让Eclipse的智能提示像VS一样霸气

    说起来用 Eclipse 也有一段时间了,相信每一个用过的人都知道他的智能提示功能真的是糟糕透了,与 VisualStudio2008 简直不是一个档次的!我就纳闷了,他为什么不弄好一点呢!今天我实在 ...

  6. Kernel Panic常见原因以及解决方法

    Technorati 标签: Kernel Panic 出现原因 1. Linux在中断处理程序中,它不处于任何一个进程上下文,如果使用可能睡眠的函数,则系统调度会被破坏,导致kernel panic ...

  7. setTimeout/setInterval执行时机

    setTimeout()和setInterval()经常被用来处理延时和定时任务.setTimeout() 方法用于在指定的毫秒数后调用函数或计算表达式,而setInterval()则可以在每隔指定的 ...

  8. C中浮点数转字符串

    求浮点数转换成字符串,如何才能获得比较正确的字符串.用printf("%f\n", (float)5); 这种方式转换出来的结果是 5.000000 ,末尾都会带6位小数. 控制精 ...

  9. Thinkcmf 在新浪云上的部署问题

    最近要开发一个社团主页,于是想到了CMF内容管理系统的,但是直接在自己的服务器测试成本太高,于是选择了在新浪云上进行部署测试. 但是在安装Thinkcmf的过程中产生了一些技术性的问题.但最后终于在自 ...

  10. JavaScript 常用方法总结

    经常使用的 JS 方法,今天记下,以便以后查询 /* 手机类型判断 */ var BrowserInfo = { userAgent: navigator.userAgent.toLowerCase( ...