In the scala, getExecutorStorageStatus and getExecutorMemoryStatus both return a number of artists, including the driver. Example fragment as below
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 } active / registered executors 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 } registered executors. 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 } 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 } Seq [String] = { 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 } spark.driver.host") 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 } ) ( 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 }
But python api it has not been implemented
@DanielDarabos ? Answer also confirms this.
However, I am not an expert in pyspark. You can try something like this python ...
sc.getConf.getInt("spark.executor.instances", 1)
source share