Ame*_*url 9 scala apache-spark pyspark
我需要使用这个参数,那么我怎样才能得到工人的数量?像Scala一样,我可以打电话sc.getExecutorMemoryStatus来获得可用的工人数量.但在PySpark中,似乎没有公开API获取此数字.
Ram*_*ram 18
在Scala中,getExecutorStorageStatus并且getExecutorMemoryStatus都返回执行者包括驱动程序的数量.如下面的示例代码段
/** 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
}
Run Code Online (Sandbox Code Playgroud)
@DanielDarabos的回答也证实了这一点.
但是,我不是pyspark的专家.你可以尝试一些相当于这个python的东西......
sc.getConf().get("spark.executor.instances")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15129 次 |
| 最近记录: |