tgravescs commented on a change in pull request #28053: [SPARK-29153][CORE]Add 
ability to merge resource profiles within a stage with Stage Level Scheduling
URL: https://github.com/apache/spark/pull/28053#discussion_r400383898
 
 

 ##########
 File path: 
core/src/main/scala/org/apache/spark/resource/ResourceProfileManager.scala
 ##########
 @@ -61,23 +68,46 @@ private[spark] class ResourceProfileManager(sparkConf: 
SparkConf) extends Loggin
 
   def addResourceProfile(rp: ResourceProfile): Unit = {
     isSupported(rp)
+    writeLock.lock()
+    try {
+      if (!resourceProfileIdToResourceProfile.contains(rp.id)) {
+        resourceProfileIdToResourceProfile.put(rp.id, rp)
+      }
+    } finally {
+      writeLock.unlock()
+    }
     // force the computation of maxTasks and limitingResource now so we don't 
have cost later
     rp.limitingResource(sparkConf)
-    val res = resourceProfileIdToResourceProfile.putIfAbsent(rp.id, rp)
-    if (res == null) {
-      logInfo(s"Added ResourceProfile id: ${rp.id}")
-    }
+    logInfo(s"Added ResourceProfile id: ${rp.id}")
 
 Review comment:
   oops, this should be in side if statement, will update

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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