squito commented on a change in pull request #24499: [SPARK-25888][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_r281681850
 
 

 ##########
 File path: 
core/src/test/scala/org/apache/spark/storage/BlockManagerInfoSuite.scala
 ##########
 @@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.storage
+
+import java.util.{HashMap => JHashMap}
+
+import scala.collection.JavaConverters._
+
+import org.apache.spark.SparkFunSuite
+
+class BlockManagerInfoSuite extends SparkFunSuite {
+
+  def testWithShuffleServiceOnOff(testName: String)
+      (f: (Boolean, BlockManagerInfo) => Unit): Unit = {
+    Seq(true, false).foreach { svcEnabled =>
+      val bmInfo = new BlockManagerInfo(
+        BlockManagerId("executor0", "host", 1234, None),
+        timeMs = 300,
+        maxOnHeapMem = 10000,
+        maxOffHeapMem = 20000,
+        slaveEndpoint = null,
+        if (svcEnabled) Some(new JHashMap[BlockId, BlockStatus]) else None)
+      test(s"$testName externalShuffleServiceEnabled=$svcEnabled") {
+        f(svcEnabled, bmInfo)
+      }
+    }
+  }
+
+  testWithShuffleServiceOnOff("broadcast block") { (_, bmInfo) =>
+    val broadcastId: BlockId = BroadcastBlockId(0, "field1")
+    bmInfo.updateBlockInfo(
+      broadcastId, StorageLevel.MEMORY_AND_DISK, memSize = 200, diskSize = 100)
+    assert(bmInfo.blocks.asScala ===
+      Map(broadcastId -> BlockStatus(StorageLevel.MEMORY_AND_DISK, 0, 100)))
+    assert(bmInfo.exclusiveCachedBlocks.isEmpty)
+    assert(bmInfo.remainingMem === 29800)
+  }
+
+  testWithShuffleServiceOnOff("RDD block with MEMORY_ONLY") { (svcEnabled, 
bmInfo) =>
+    val rddId: BlockId = RDDBlockId(0, 0)
+    bmInfo.updateBlockInfo(rddId, StorageLevel.MEMORY_ONLY, memSize = 200, 
diskSize = 0)
+    assert(bmInfo.blocks.asScala ===
+      Map(rddId -> BlockStatus(StorageLevel.MEMORY_ONLY, 200, 0)))
+    assert(bmInfo.exclusiveCachedBlocks === Set(rddId))
+    assert(bmInfo.remainingMem === 29800)
+    if (svcEnabled) {
+      assert(bmInfo.externalShuffleServiceBlockStatus.get.isEmpty)
+    }
+  }
+
+  testWithShuffleServiceOnOff("RDD block with MEMORY_AND_DISK") { (svcEnabled, 
bmInfo) =>
+    val rddId: BlockId = RDDBlockId(0, 0)
+    bmInfo.updateBlockInfo(
+      rddId, StorageLevel.MEMORY_AND_DISK, memSize = 200, diskSize = 400)
 
 Review comment:
   yes I was wondering the same thing -- I agree the effective storage level 
can't be both memory and disk on initial storage.  I hadn't confirmed whether 
it could never become both memory and disk eventually, though -- eg. there 
isn't space initially, so it gets written to disk, but then later on other RDDs 
are unpersisted, but the RDD is accessed again, so it gets promoted to being in 
memory, and the files on disk are still there.  See the 
`maybeCacheDiskBytesInMemory` / `maybeCacheDiskValuesInMemory`: 
https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/storage/BlockManager.scala#L774-L776
   
   so the test case may still be useful, but its not actually the more 
important part of a _requested_  MEMORY_AND_DISK storage level that marcelo and 
I were concerned about

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