squito commented on a change in pull request #24554: [SPARK-27622][Core] 
Avoiding the network when block manager fetches disk persisted RDD blocks from 
the same host
URL: https://github.com/apache/spark/pull/24554#discussion_r289155081
 
 

 ##########
 File path: core/src/test/scala/org/apache/spark/storage/BlockManagerSuite.scala
 ##########
 @@ -567,6 +608,137 @@ class BlockManagerSuite extends SparkFunSuite with 
Matchers with BeforeAndAfterE
     assert(store.getRemoteBytes("list1").isEmpty)
   }
 
+  Seq(
+    StorageLevel(useDisk = true, useMemory = false, deserialized = false),
+    StorageLevel(useDisk = true, useMemory = false, deserialized = true)
+  ).foreach { storageLevel =>
+    test(s"SPARK-27622: avoid the network when block requested from same host, 
$storageLevel") {
+      conf.set("spark.shuffle.io.maxRetries", "0")
+       val noFetcher = new MockBlockTransferService(0) {
+        override def fetchBlockSync(
+            host: String,
+            port: Int,
+            execId: String,
+            blockId: String,
+            tempFileManager: DownloadFileManager): ManagedBuffer = {
+          fail("Fetching over network is not expected when the block is 
requested from same host")
+        }
+      }
+      val store1 = makeBlockManager(8000, "executor1", this.master, 
Some(noFetcher))
+      val store2 = makeBlockManager(8000, "executor2", this.master, 
Some(noFetcher))
+      val blockId = "list"
+      val array = new Array[Byte](4000)
+      store2.putIterator(blockId, List(array).iterator, storageLevel, true)
+
+      // check getRemoteBytes
+      val bytesViaStore1 = store1.getRemoteBytes(blockId)
+      assert(bytesViaStore1.isDefined, "list expected to be accessed")
+      val expectedContent = 
store2.getBlockData(blockId).nioByteBuffer().array()
+      assert(bytesViaStore1.get.toArray === expectedContent)
 
 Review comment:
   with an empty array this isn't very useful, it would still pass under some 
errors (eg. you somehow get the length but no content so are left with an 
initialized array).  You can fill it with random bytes or even just a looping 
1,2,3,4,...

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