spark 2.1.1

系统中希望监控spark on yarn任务的执行进度,但是监控过程发现提交任务之后执行进度总是10%,直到执行成功或者失败,进度会突然变为100%,很神奇,

下面看spark on yarn任务提交过程:

spark on yarn提交任务时会把mainClass修改为Client

childMainClass = "org.apache.spark.deploy.yarn.Client"

spark-submit过程详见:https://www.cnblogs.com/barneywill/p/9820684.html

下面看Client执行过程:

org.apache.spark.deploy.yarn.Client

  def main(argStrings: Array[String]) {
...
val sparkConf = new SparkConf
// SparkSubmit would use yarn cache to distribute files & jars in yarn mode,
// so remove them from sparkConf here for yarn mode.
sparkConf.remove("spark.jars")
sparkConf.remove("spark.files")
val args = new ClientArguments(argStrings)
new Client(args, sparkConf).run()
... def run(): Unit = {
this.appId = submitApplication()
... def submitApplication(): ApplicationId = {
...
val containerContext = createContainerLaunchContext(newAppResponse)
... private def createContainerLaunchContext(newAppResponse: GetNewApplicationResponse)
: ContainerLaunchContext = {
...
val amClass =
if (isClusterMode) {
Utils.classForName("org.apache.spark.deploy.yarn.ApplicationMaster").getName
} else {
Utils.classForName("org.apache.spark.deploy.yarn.ExecutorLauncher").getName
}

这里调用过程为Client.main->run->submitApplication->createContainerLaunchContext,然后会设置amClass,最终都会调用到ApplicationMaster,因为ExecutorLauncher内部也是调用ApplicationMaster,如下:

org.apache.spark.deploy.yarn.ExecutorLauncher

object ExecutorLauncher {

  def main(args: Array[String]): Unit = {
ApplicationMaster.main(args)
} }

下面看ApplicationMaster:

org.apache.spark.deploy.yarn.ApplicationMaster

  def main(args: Array[String]): Unit = {
...
SparkHadoopUtil.get.runAsSparkUser { () =>
master = new ApplicationMaster(amArgs, new YarnRMClient)
System.exit(master.run())
}
... final def run(): Int = {
...
if (isClusterMode) {
runDriver(securityMgr)
} else {
runExecutorLauncher(securityMgr)
}
... private def registerAM(
_sparkConf: SparkConf,
_rpcEnv: RpcEnv,
driverRef: RpcEndpointRef,
uiAddress: String,
securityMgr: SecurityManager) = {
...
allocator = client.register(driverUrl,
driverRef,
yarnConf,
_sparkConf,
uiAddress,
historyAddress,
securityMgr,
localResources) allocator.allocateResources()
reporterThread = launchReporterThread()
...
private def launchReporterThread(): Thread = {
// The number of failures in a row until Reporter thread give up
val reporterMaxFailures = sparkConf.get(MAX_REPORTER_THREAD_FAILURES) val t = new Thread {
override def run() {
var failureCount = 0
while (!finished) {
try {
if (allocator.getNumExecutorsFailed >= maxNumExecutorFailures) {
finish(FinalApplicationStatus.FAILED,
ApplicationMaster.EXIT_MAX_EXECUTOR_FAILURES,
s"Max number of executor failures ($maxNumExecutorFailures) reached")
} else {
logDebug("Sending progress")
allocator.allocateResources()
}
...

这里调用过程为ApplicationMaster.main->run,run中会调用runDriver或者runExecutorLauncher,最终都会调用到registerAM,其中会调用YarnAllocator.allocateResources,然后在launchReporterThread中会启动一个thread,其中也会不断调用YarnAllocator.allocateResources,下面看YarnAllocator:

org.apache.spark.deploy.yarn.YarnAllocator

  def allocateResources(): Unit = synchronized {
updateResourceRequests() val progressIndicator = 0.1f
// Poll the ResourceManager. This doubles as a heartbeat if there are no pending container
// requests.
val allocateResponse = amClient.allocate(progressIndicator)

可见这里会设置进度为0.1,即10%,而且是硬编码,所以spark on yarn的执行进度一直为10%,所以想监控spark on yarn的任务进度看来是徒劳的;

【原创】大叔经验分享(19)spark on yarn提交任务之后执行进度总是10%的更多相关文章

  1. 【原创】大叔经验分享(21)yarn中查看每个应用实时占用的内存和cpu资源

    在yarn中的application详情页面 http://resourcemanager/cluster/app/$applicationId 或者通过application命令 yarn appl ...

  2. 【原创】大叔经验分享(5)oozie提交spark任务如何添加依赖

    spark任务添加依赖的方式: 1 如果是local方式运行,可以通过--jars来添加依赖: 2 如果是yarn方式运行,可以通过spark.yarn.jars来添加依赖: 这两种方式在oozie上 ...

  3. 【原创】大叔经验分享(47)yarn开启日志归集

    yarn开启日志归集功能,除了配置之外 yarn.log-aggregation-enable=true 还要检查/tmp/logs目录是否存在以及权限,尤其是在开启kerberos之后,有些目录可能 ...

  4. 【原创】大叔经验分享(9)yarn重要配置yarn.nodemanager.local-dirs

    yarn中有一个比较重要的配置yarn.nodemanager.local-dirs,如果配置的不好,在饱和状态运行下集群会出现很多问题:1 默认配置${hadoop.tmp.dir}/nm-loca ...

  5. 【原创】大叔经验分享(4)Yarn ResourceManager页面如何实现主被自动切换

    hdfs.yarn.hbase这些组件的master支持多个,实现自动主备切换,其中hdfs.hbase无论访问主master或者备master都可以正常访问页面,但是yarn比较特别,只有主mast ...

  6. 【原创】大叔经验分享(46)用户提交任务到yarn报错

    用户提交任务到yarn时有可能遇到下面的错误: 1) Requested user anything is not whitelisted and has id 980,which is below ...

  7. 【原创】大叔经验分享(48)oozie中通过shell执行impala

    oozie中通过shell执行impala,脚本如下: $ cat test_impala.sh #!/bin/sh /usr/bin/kinit -kt /tmp/impala.keytab imp ...

  8. 【原创】经验分享:一个小小emoji尽然牵扯出来这么多东西?

    前言 之前也分享过很多工作中踩坑的经验: 一个线上问题的思考:Eureka注册中心集群如何实现客户端请求负载及故障转移? [原创]经验分享:一个Content-Length引发的血案(almost.. ...

  9. spark利用yarn提交任务报:YARN application has exited unexpectedly with state UNDEFINED

    spark用yarn提交任务会报ERROR cluster.YarnClientSchedulerBackend: YARN application has exited unexpectedly w ...

随机推荐

  1. 爬虫之BS&Xpath

    BeautifulSoup 一 简介 简单来说,Beautiful Soup是python的一个库,最主要的功能是从网页抓取数据.官方解释如下: ''' Beautiful Soup提供一些简单的.p ...

  2. PS调出韩式米黄色室内婚纱照片

    原图: Camera Raw打开原图. 光线调整,压暗白色,保留高光细节,少量对比黑色压暗. 降低整体饱和. 曲线调整,压暗高光明度. 减红加青(融合色彩). 中间调,靠近暗部区域加蓝,靠近亮部区域加 ...

  3. Solving the Top ERP and CRM Metadata Challenges with erwin & Silwood

    Registrationhttps://register.gotowebinar.com/register/3486582555108619010 Solving the Top ERP and CR ...

  4. HDU 2571 命运(简单dp)

    传送门 真是刷越多题,越容易满足.算是一道很简单的DP了.终于可以自己写出来了. 二维矩阵每个点都有一个幸运值,要求从左上走到右下最多能积累多少幸运值. 重点就是左上右下必须都踩到. dp[i][j] ...

  5. Memory Layout for Multiple and Virtual Inheritance

    Memory Layout for Multiple and Virtual Inheritance(By Edsko de Vries, January 2006)Warning. This art ...

  6. SQL中GROUP BY用法示例(转)

    工作中又用到了写SQL 好多年不用了 再拿过来温习下: 不觉豁然开朗 概述 GROUP BY我们可以先从字面上来理解,GROUP表示分组,BY后面写字段名,就表示根据哪个字段进行分组,如果有用Exce ...

  7. C++(1):error: invalid conversion from ‘void (*)()’ to ‘void (*)(int)

    void signaldemo_test(void) { struct itimerval tv, otv; signal(SIGALRM, sigFunc); //how long to run t ...

  8. 包管理工具之Pipenv

    pipenv 都包含什么? pipenv 是 Pipfile 主要倡导者.requests 作者 Kenneth Reitz 写的一个命令行工具,主要包含了Pipfile.pip.click.requ ...

  9. 1.2浅谈Spring-Spring结构

    时隔很多天的我又回来....最近发展了一下自己的爱好,所以拖了很长时间. 前面我们从概念性上分析了spring的特性 这里我们附上Spring框架的结构图 我们简单的来说一些这个框架图 我们从下往上看 ...

  10. CMDB服务器管理系统【s5day90】:API构造可插拔式插件逻辑

    1.服务器端目录结构: 1.__init__.py from django.conf import settings from repository import models import impo ...