vanzin commented on a change in pull request #24499: [SPARK-27677][Core] Serve 
local disk persisted blocks by the external service after releasing executor by 
dynamic allocation
URL: https://github.com/apache/spark/pull/24499#discussion_r285740065
 
 

 ##########
 File path: 
core/src/main/scala/org/apache/spark/storage/BlockManagerMasterEndpoint.scala
 ##########
 @@ -149,29 +162,70 @@ class BlockManagerMasterEndpoint(
     // First remove the metadata for the given RDD, and then asynchronously 
remove the blocks
     // from the slaves.
 
+    // The message sent to the slaves to remove the RDD
+    val removeMsg = RemoveRdd(rddId)
+
     // Find all blocks for the given RDD, remove the block from both 
blockLocations and
-    // the blockManagerInfo that is tracking the blocks.
+    // the blockManagerInfo that is tracking the blocks and create the futures 
which asynchronously
+    // remove the blocks from slaves and gives back the number of removed 
blocks
     val blocks = blockLocations.asScala.keys.flatMap(_.asRDDId).filter(_.rddId 
== rddId)
+    val blocksToDeleteByShuffleService =
+      new mutable.HashMap[BlockManagerId, mutable.HashSet[RDDBlockId]]
+
     blocks.foreach { blockId =>
-      val bms: mutable.HashSet[BlockManagerId] = blockLocations.get(blockId)
-      bms.foreach(bm => 
blockManagerInfo.get(bm).foreach(_.removeBlock(blockId)))
-      blockLocations.remove(blockId)
+      val bms: mutable.HashSet[BlockManagerId] = blockLocations.remove(blockId)
+
+      val (bmIdExtShuffle, bmIdExecutor) = bms.partition(_.port == 
externalShuffleServicePort)
+      if (bmIdExecutor.isEmpty && bmIdExtShuffle.nonEmpty) {
+        // when original executor is already removed use the shuffle service 
to remove the blocks
+        bmIdExtShuffle.foreach { bmIdForShuffleService =>
+          val blockIdsToDel = 
blocksToDeleteByShuffleService.getOrElseUpdate(bmIdForShuffleService,
+            new mutable.HashSet[RDDBlockId]())
+          blockIdsToDel += blockId
+          blockStatusByShuffleService.get(bmIdForShuffleService).foreach { 
blockStatus =>
+            blockStatus.remove(blockId)
+          }
+        }
+      } else {
+        bmIdExecutor.foreach { bm =>
+          blockManagerInfo.get(bm).foreach { bmInfo =>
+            bmInfo.removeBlock(blockId)
+          }
+        }
+      }
     }
+    val removeRddFromExecutorsFutures = blockManagerInfo.values.map { bmInfo =>
+      askRemoveRddFromExecutor(removeMsg, bmInfo)
 
 Review comment:
   I'm not seeing too much benefit from putting this in a separate method.

----------------------------------------------------------------
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