2016-08-26 6 views
3

スパーク・アーキテクチャは、エグゼキュータとコアの概念を中心に展開されています。クラスタ内で実行されているスパーク・アプリケーション用に実行されているエグゼキュータおよびコアの数を実際に確認したいと思います。スパーク - スパーク・ジョブに割り当てられる実行者とコアの数

私はアプリケーションで以下のスニペットを使用しようとしましたが、運はありませんでした。

val conf = new SparkConf().setAppName("ExecutorTestJob") 
val sc = new SparkContext(conf) 
conf.get("spark.executor.instances") 
conf.get("spark.executor.cores") 

SparkContextオブジェクトまたはSparkConfオブジェクトなどを使用してこれらの値を取得する方法はありますが...

+1

あなたは、SparkのUIに見ることができます。 http:// :4040に行き、 "Executors"タブを押してください。これはクラスタ管理者によって異なります。 –

+1

クリシュナ、あなたは手に入れられましたか?お気軽に質問してください –

+0

テストできましたか? –

答えて

7

スカーラ(プログラム的な方法):

getExecutorStorageStatusgetExecutorMemoryStatusの両方がドライバを含むエグゼキュータの数を返します。 以下のようなスニペットです。

/** Method that just returns the current active/registered executors 
     * excluding the driver. 
     * @param sc The spark context to retrieve registered executors. 
     * @return a list of executors each in the form of host:port. 
     */ 
     def currentActiveExecutors(sc: SparkContext): Seq[String] = { 
     val allExecutors = sc.getExecutorMemoryStatus.map(_._1) 
     val driverHost: String = sc.getConf.get("spark.driver.host") 
     allExecutors.filter(! _.split(":")(0).equals(driverHost)).toList 
     } 

sc.getConf.getInt("spark.executor.instances", 1) 

同様にあなたが同様にコア情報を得ることができます。.. spark.driver.coresドライバがこの値を持っている必要があり執行のための

sc.getConf.getAll.mkString("\n") 

OR

sc.getConf.toDebugString 

ほとんどspark.executor.coresをすべてのプロパティを取得し、以下のように印刷します。

のPython:

Above methods getExecutorStorageStatus and getExecutorMemoryStatus, In python api were not implemented

EDIT しかしSparkSessionから露出Py4Jバインディングを使用してアクセスすることができます。

sc._jsc.sc().getExecutorMemoryStatus()

-1

これは(修士含む)コアの数を取得するのpython例である def workername(): import socket return str(socket.gethostname()) anrdd=sc.parallelize(['','']) namesRDD = anrdd.flatMap(lambda e: (1,workername())) namesRDD.count()

関連する問題