squito commented on a change in pull request #19194: [SPARK-20589] Allow 
limiting task concurrency per stage
URL: https://github.com/apache/spark/pull/19194#discussion_r248842045
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/ExecutorAllocationManager.scala
 ##########
 @@ -659,6 +677,35 @@ private[spark] class ExecutorAllocationManager(
     // place the executors.
     private val stageIdToExecutorPlacementHints = new mutable.HashMap[Int, 
(Int, Map[String, Int])]
 
+    override def onJobStart(jobStart: SparkListenerJobStart): Unit = {
+      var jobGroupId = if (jobStart.properties != null) {
+        jobStart.properties.getProperty(SparkContext.SPARK_JOB_GROUP_ID)
+      } else {
+        null
+      }
+
+      val maxConTasks = if (jobGroupId != null &&
+        conf.contains(s"spark.job.$jobGroupId.maxConcurrentTasks")) {
+        conf.get(s"spark.job.$jobGroupId.maxConcurrentTasks").toInt
+      } else {
+        Int.MaxValue
+      }
+
+      if (maxConTasks <= 0) {
+        throw new IllegalArgumentException(
+          "Maximum Concurrent Tasks should be set greater than 0 for the job 
to progress.")
+      }
+
+      if (jobGroupId == null || 
!conf.contains(s"spark.job.$jobGroupId.maxConcurrentTasks")) {
+        jobGroupId = DEFAULT_JOB_GROUP
+      }
 
 Review comment:
   this can be simplified to
   
   ```scala
   val jobGroupId = if (jobStart.properties != null) {
           
Option(jobStart.properties.getProperty(SparkContext.SPARK_JOB_GROUP_ID)).getOrElse(DEFAULT_JOB_GROUP)
         } else {
           DEFAULT_JOB_GROUP
         }
     val maxConTasks = 
conf.getOption(s"spark.job.$jobGroupId.maxConcurrentTasks").map(_.toInt).getOrElse(Int.MaxValue)
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to