Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/13932#discussion_r111204141
--- Diff:
core/src/test/scala/org/apache/spark/storage/BlockReplicationPolicySuite.scala
---
@@ -68,7 +68,60 @@ class BlockReplicationPolicySuite extends SparkFunSuite
logDebug(s"Random peers : ${secondPass.mkString(", ")}")
assert(secondPass.toSet.size === numReplicas)
}
+ }
+
+ protected def generateBlockManagerIds(count: Int, racks: Seq[String]):
Seq[BlockManagerId] = {
+ (1 to count).map{i =>
+ BlockManagerId(s"Exec-$i", s"Host-$i", 10000 + i,
Some(racks(Random.nextInt(racks.size))))
+ }
+ }
+}
+
+class TopologyAwareBlockReplicationPolicyBehavior extends
RandomBlockReplicationPolicyBehavior {
+ override val replicationPolicy = new BasicBlockReplicationPolicy
+
+ test("All peers in the same rack") {
+ val racks = Seq("/default-rack")
+ val numBlockManager = 10
+ (1 to 10).foreach {numReplicas =>
+ val peers = generateBlockManagerIds(numBlockManager, racks)
+ val blockManager = BlockManagerId("Driver", "Host-driver", 10001,
Some(racks.head))
+
+ val prioritizedPeers = replicationPolicy.prioritize(
+ blockManager,
+ peers,
+ mutable.HashSet.empty,
+ blockId,
+ numReplicas
+ )
+ assert(prioritizedPeers.toSet.size == numReplicas)
+ assert(prioritizedPeers.forall(p => p.host != blockManager.host))
+ }
}
+ test("Peers in 2 racks") {
--- End diff --
fixed by https://github.com/apache/spark/pull/17624
---
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]