Github user mridulm commented on a diff in the pull request:
https://github.com/apache/spark/pull/17300#discussion_r107352378
--- Diff:
core/src/test/scala/org/apache/spark/storage/BlockManagerSuite.scala ---
@@ -500,6 +500,30 @@ class BlockManagerSuite extends SparkFunSuite with
Matchers with BeforeAndAfterE
assert(locations.map(_.host).toSet === Set(localHost, localHost,
otherHost))
}
+ test("optimize a location order of blocks with topology information") {
+ val localHost = Utils.localHostName()
+ val otherHost = "otherHost"
+ val localRack = "localRack"
+ val otherRack = "otherRack"
+
+ val bmMaster = mock(classOf[BlockManagerMaster])
+ val bmId1 = BlockManagerId("id1", localHost, 1, Some(localRack))
+ val bmId2 = BlockManagerId("id2", localHost, 2, Some(localRack))
+ val bmId3 = BlockManagerId("id3", otherHost, 3, Some(otherRack))
+ val bmId4 = BlockManagerId("id4", otherHost, 4, Some(otherRack))
+ val bmId5 = BlockManagerId("id5", otherHost, 5, Some(localRack))
+ when(bmMaster.getLocations(mc.any[BlockId]))
+ .thenReturn(Seq(bmId1, bmId2, bmId3, bmId3, bmId4, bmId5))
+
+ val blockManager = makeBlockManager(128, "exec", bmMaster)
+ val getLocations = PrivateMethod[Seq[BlockManagerId]]('getLocations)
+ val locations = blockManager invokePrivate
getLocations(BroadcastBlockId(0))
+ assert(locations.map(_.host).toSet
+ === Set(localHost, localHost, otherHost, otherHost, otherHost))
--- End diff --
Remove `toSet` and make `Set` as `Seq` ?
Making it a Set sort of looses the point of this change (ordering is lost).
Same for topology info below below.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]