日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

《深入理解Spark:核心思想与源码分析》——3.10节创建和启动ExecutorAllocationManager...

發(fā)布時(shí)間:2025/5/22 编程问答 67 豆豆
生活随笔 收集整理的這篇文章主要介紹了 《深入理解Spark:核心思想与源码分析》——3.10节创建和启动ExecutorAllocationManager... 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

本節(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)鍵代碼

private val intervalMillis: Long = 100 private var clock: Clock = new RealClock private val listener = new ExecutorAllocationListener def start(): Unit = {listenerBus.addListener(listener)startPolling() }private def startPolling(): Unit = {val t = new Thread {override def run(): Unit = {while (true) {try {schedule()} catch {case e: Exception => logError("Exception in dynamic executor allocation thread!", e)}Thread.sleep(intervalMillis)}}}t.setName("spark-dynamic-executor-allocation")t.setDaemon(true)t.start() }

根據(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)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。