title: Spark: get number of cluster cores programmatically
body: <p>I run my spark application in yarn cluster. In my code I use number available cores of queue for creating partitions on my dataset:</p>
  
  <pre><code>Dataset ds = ...
  ds.coalesce(config.getNumberOfCores());
  </code></pre>
  
  <p>My question: how can I get number available cores of queue by programmatically way and not by configuration?</p>