ExecutorBackend的异常处理

来源:互联网 发布:淘宝主页全屏轮播 编辑:程序博客网 时间:2024/06/06 08:24

5.3.4    ExecutorBackend的异常处理  

CoarseGrainedExecutorBackend在运行中出现异常,将调用exitExecutor方法进行处理,处理以后系统退出。exitExecutor这个函数可以由其他子类重载来处理,executor执行的退出方式不同。例如:当executor挂掉了,后台程序可能不会让父进程也挂掉。如果需通知Driver,Driver将清理挂掉的executor的数据。

CoarseGrainedExecutorBackend的exitExecutor方法源码:

1.             protected def exitExecutor(code: Int,

2.                                      reason: String,

3.                                      throwable:Throwable = null,

4.                                      notifyDriver:Boolean = true) = {

5.             val message = "Executorself-exiting due to : " + reason

6.             if (throwable != null) {

7.               logError(message, throwable)

8.             } else {

9.               logError(message)

10.          }

11.       

12.          if (notifyDriver &&driver.nonEmpty) {

13.            driver.get.ask[Boolean](

14.              RemoveExecutor(executorId,new ExecutorLossReason(reason))

15.            ).onFailure { case e =>

16.              logWarning(s"Unableto notify the driver due to " + e.getMessage, e)

17.            }(ThreadUtils.sameThread)

18.          }

19.       

20.          System.exit(code)

21.        }

22.      }

 

CoarseGrainedExecutorBackend在运行中可能出现的异常情况,将调用exitExecutor方法处理:

l  Executor向Driver注册RegisterExecutor失败。

l  Executor收到Driver的RegisteredExecutor注册成功消息以后,创建Executor实例失败。

l  Driver返回Executor注册失败消息RegisterExecutorFailed。

l  Executor收到Driver的LaunchTask启动任务消息,但是executor为null。

l  Executor收到Driver的KillTask消息,但是executor为null。

l  Executor和Driver失去连接。

 

 

原创粉丝点击