python解释执行器_python – Spark – 为我的spark作业分配了多少个执行器和内核

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

}

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

同样获取所有属性并打印如下,您也可以获得核心信息..

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

要么

sc.getConf.toDebugString

执行程序spark.driver.cores驱动程序的spark.executor.cores应该具有此值.

Python:

编辑

但是可以使用SparkSession公开的Py4J绑定来访问它.

sc._jsc.sc().getExecutorMemoryStatus()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值