Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ConeyLiu committed Mar 22, 2017
1 parent 926ea25 commit 56f5231
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ private[spark] class BlockManager(

/**
* Return a list of locations for the given block, prioritizing the local machine since
* multiple block managers can share the same host, then try to get the same rack data.
* multiple block managers can share the same host, followed by hosts on the same rack.
*/
private def getLocations(blockId: BlockId): Seq[BlockManagerId] = {
val locs = Random.shuffle(master.getLocations(blockId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ class BlockManagerSuite extends SparkFunSuite with Matchers with BeforeAndAfterE
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))
assert(locations.map(_.host) === Seq(localHost, localHost, otherHost))
}

test("optimize a location order of blocks with topology information") {
Expand All @@ -513,15 +513,14 @@ class BlockManagerSuite extends SparkFunSuite with Matchers with BeforeAndAfterE
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))
.thenReturn(Seq(bmId1, bmId2, bmId5, bmId3, bmId4))

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))
assert(locations.flatMap(_.topologyInfo).toSet
=== Set(localRack, localRack, localRack, otherRack, otherRack))
assert(locations.map(_.host) === Seq(localHost, localHost, otherHost, otherHost, otherHost))
assert(locations.flatMap(_.topologyInfo)
=== Seq(localRack, localRack, localRack, otherRack, otherRack))
}

test("SPARK-9591: getRemoteBytes from another location when Exception throw") {
Expand Down

0 comments on commit 56f5231

Please sign in to comment.