StandaloneAppClient是什么

  介绍

这篇文章主要介绍”StandaloneAppClient是什么”,在日常操作中,相信很多人在StandaloneAppClient是什么问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答“StandaloneAppClient是什么”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

StandaloneAppClient是什么?这个很容易搞混淆。其实StandaloneAppClient不是SparkApplication,它主要是用在ScheduleBackend中的。

独立集群环境中,ScheduleBackend是用的StandaloneScheduleBackend,它继承了CoarseGrainedSchedulerBackend类。

StandaloneScheduleBackend里面用了一个叫StandaloneAppClient的类,这个StandaloneAppClient很具有迷惑性,其实它的主要功能是替换CoarseGrainedSchedulerBackend的资源申请的方法,改为向主申请资源,我们看看相关代码片段就行了。

先看他启动的时候:

 private  def  tryRegisterAllMasters():,数组(JFuture [_]],=, {
  ,,,,,for  (masterAddress  & lt;作用;masterRpcAddresses),油品收率{
  ,,,,,,,registerMasterThreadPool.submit (new  Runnable  {
  ,,,,,,,,,override  def 运行():,Unit =, try  {
  ,,,,,,,,,,,if  (registered.get), {
  ,,,,,,,,,,,,,回来
  ,,,,,,,,,,,}
  ,,,,,,,,,,,logInfo (“Connecting 用master “, +, masterAddress.toSparkURL  +,“…“)
  ,,,,,,,,,,,val  masterRef =, rpcEnv.setupEndpointRef (masterAddress, Master.ENDPOINT_NAME)
  ,,,,,,,,,,,masterRef.send (RegisterApplication (appDescription,,自我))
  ,,,,,,,,,},{catch 
  ,,,,,,,,,}
  ,,,,,,,})
  ,,,,,}
  ,,,}

向主人发送RegisterApplication消息,将本appDesc注册给主人,这个和DriverDescription注册到主人是有点区别的。

再比如资源申请的代码:

<>之前,def  requestTotalExecutors (requestedTotal: Int):,未来(布尔),=,{   ,,,if  (endpoint.get  !=, null ,,, appId.get  !=, null), {   ,,,,,endpoint.get.ask(布尔)(RequestExecutors (appId.get, requestedTotal))   ,,,},{else    ,,,,,logWarning (“Attempted 用request  executors  before  driver  fully 初始化!”)   ,,,,,Future.successful(假)   ,,,}   以前,,}

就是向主人发送RequestExecutor消息申请执行人资源。

StandaloneAppClient是什么