《深入理解Spark:核心思想与源码分析》——3.10节创建和启动ExecutorAllocationManager...
本節(jié)書摘來自華章社區(qū)《深入理解Spark:核心思想與源碼分析》一書中的第3章,第3.10節(jié)創(chuàng)建和啟動(dòng)ExecutorAllocationManager,作者耿嘉安,更多章節(jié)內(nèi)容可以訪問云棲社區(qū)“華章社區(qū)”公眾號(hào)查看
3.10 創(chuàng)建和啟動(dòng)ExecutorAllocationManager
ExecutorAllocationManager用于對(duì)已分配的Executor進(jìn)行管理,創(chuàng)建和啟動(dòng)Executor-AllocationManager的代碼如下。 private[spark] val executorAllocationManager: Option[ExecutorAllocationManager] =if (conf.getBoolean("spark.dynamicAllocation.enabled", false)) {Some(new ExecutorAllocationManager(this, listenerBus, conf))} else {None} executorAllocationManager.foreach(_.start())默認(rèn)情況下不會(huì)創(chuàng)建ExecutorAllocationManager,可以修改屬性spark.dynamicAllocation.enabled為true來創(chuàng)建。ExecutorAllocationManager可以設(shè)置動(dòng)態(tài)分配最小Executor數(shù)量、動(dòng)態(tài)分配最大Executor數(shù)量、每個(gè)Executor可以運(yùn)行的Task數(shù)量等配置信息,并對(duì)配置信息進(jìn)行校驗(yàn)。start方法將ExecutorAllocationListener加入listenerBus中,ExecutorAllocationListener通過監(jiān)聽listenerBus里的事件,動(dòng)態(tài)添加、刪除Executor。并且通過Thread不斷添加Executor,遍歷Executor,將超時(shí)的Executor殺掉并移除。ExecutorAllocationListener的實(shí)現(xiàn)與其他SparkListener類似,不再贅述。ExecutorAllocationManager的關(guān)鍵代碼見代碼清單3-47。
代碼清單3-47 ExecutorAllocationManager的關(guān)鍵代碼
根據(jù)3.4.1節(jié)的內(nèi)容,我們知道listenerBus內(nèi)置了線程listenerThread,此線程不斷從eventQueue中拉出事件對(duì)象,調(diào)用監(jiān)聽器的監(jiān)聽方法。要啟動(dòng)此線程,需要調(diào)用listenerBus的start方法,代碼如下。
listenerBus.start() 《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的《深入理解Spark:核心思想与源码分析》——3.10节创建和启动ExecutorAllocationManager...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 《R语言初学指南》一2.3 找到R脚本中
- 下一篇: Property with #39;re