Spark - How many Executors and Cores are allocated to my spark job
<p>Spark architecture is entirely revolves around the concept of executors and cores. I would like to see practically how many executors and cores running for my spark application running in a cluster. </p>

<p>I was trying to use below snippet in my application but no luck.</p>

<pre><code>val conf = new SparkConf().setAppName("ExecutorTestJob")
val sc = new SparkContext(conf)
conf.get("spark.executor.instances")
conf.get("spark.executor.cores")
</code></pre>

<p>Is there any way to get those values using <code>SparkContext</code> Object or <code>SparkConf</code> object etc..</p>

<p>This is python Example to get number of cores (including master's)
    <code>def workername():
    import socket
    return str(socket.gethostname())
anrdd=sc.parallelize(['',''])
namesRDD = anrdd.flatMap(lambda e: (1,workername()))
namesRDD.count()</code></p>

python scala hadoop apache-spark executors