Spark: get number of cluster cores programmatically

后端 未结 4 1912
庸人自扰
庸人自扰 2020-12-09 05:35

I run my spark application in yarn cluster. In my code I use number available cores of queue for creating partitions on my dataset:

Dataset ds = ...
ds.coale         


        
4条回答
  •  庸人自扰
    2020-12-09 05:53

    According to Databricks if the driver and executors are of the same node type, this is the way to go:

    java.lang.Runtime.getRuntime.availableProcessors * (sc.statusTracker.getExecutorInfos.length -1)
    

提交回复
热议问题