怎么在Yarn集群中分配Container

本篇內(nèi)容介紹了“怎么在Yarn集群中分配Container”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

成都創(chuàng)新互聯(lián)公司專注于企業(yè)成都全網(wǎng)營銷、網(wǎng)站重做改版、集美網(wǎng)站定制設(shè)計、自適應(yīng)品牌網(wǎng)站建設(shè)、H5頁面制作、商城網(wǎng)站制作、集團公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計等建站業(yè)務(wù),價格優(yōu)惠性價比高,為集美等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。

YarnAllocator從字面意思來看,也應(yīng)該知道是在Yarn集群中分配Container的。

private[yarn] class YarnAllocator(
    driverUrl: String,
    driverRef: RpcEndpointRef,
    conf: YarnConfiguration,
    sparkConf: SparkConf,
    amClient: AMRMClient[ContainerRequest],
    appAttemptId: ApplicationAttemptId,
    securityMgr: SecurityManager,
    localResources: Map[String, LocalResource],
    resolver: SparkRackResolver,
    clock: Clock = new SystemClock)

其中driverUrl就是Driver的地址。當(dāng)用YarnAllocator分配Container來運行Executors時,這些Executors要聯(lián)系的Driver地址就是構(gòu)造函數(shù)里的driverRef參數(shù)。

requestTotalExecutorsWithPreferredLocalities方法是分配多個Executor的,先將分配請求保存在隊列里,然后在守護線程中異步的創(chuàng)建Executor。

def requestTotalExecutorsWithPreferredLocalities(
      requestedTotal: Int,
      localityAwareTasks: Int,
      hostToLocalTaskCount: Map[String, Int],
      nodeBlacklist: Set[String]): Boolean = synchronized {
    this.numLocalityAwareTasks = localityAwareTasks
    this.hostToLocalTaskCounts = hostToLocalTaskCount
    if (requestedTotal != targetNumExecutors) {
      logInfo(s"Driver requested a total number of $requestedTotal executor(s).")
      targetNumExecutors = requestedTotal
      allocatorBlacklistTracker.setSchedulerBlacklistedNodes(nodeBlacklist)
      true
    } else {
      false
    }
  }

targetNumExecutors就是說明要申請創(chuàng)建多少個Executor的意思。具體的實際創(chuàng)建動作是在runAllocatedContainers中執(zhí)行的。

         launcherPool.execute(() => {
            try {
              new ExecutorRunnable(
                Some(container),
                conf,
                sparkConf,
                driverUrl,
                executorId,
                executorHostname,
                executorMemory,
                executorCores,
                appAttemptId.getApplicationId.toString,
                securityMgr,
                localResources
              ).run()
              updateInternalState()
            } catch {
              
            }

這一段就是在分配的Container上創(chuàng)建Executor的過程,用ExecutorRunner來包裝的。其中的driverUrl就是構(gòu)造函數(shù)中帶過來的driver的地址。

可見每個driver都會創(chuàng)建一個屬于自己的單獨的YarnAllocator。

順便說一句,很多人以前Spark是集群,實際上Spark本身只是一種計算方式,可以看成它只是jar包。Spark的driver運行時才會去申請Executor,向Yarn申請或者向Standalone集群申請。Standalone集群是指Master和Worker,不是指Spark core,更不是指SparkContext。

“怎么在Yarn集群中分配Container”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!

分享文章:怎么在Yarn集群中分配Container
本文鏈接:http://muchs.cn/article22/gdihcc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊、云服務(wù)器、網(wǎng)站制作、手機網(wǎng)站建設(shè)、App設(shè)計

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)