Skip to content

Commit 0661773

Browse files
committed
Minor changes based on PR comments.
1 parent a55a65c commit 0661773

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

core/src/main/scala/org/apache/spark/storage/BlockManager.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ private[spark] class BlockManager(
820820
val peersFailedToReplicateTo = new ArrayBuffer[BlockManagerId]
821821
val tLevel = StorageLevel(
822822
level.useDisk, level.useMemory, level.useOffHeap, level.deserialized, 1)
823-
val startTime = System.nanoTime
823+
val startTime = System.currentTimeMillis
824824
val random = new Random(blockId.hashCode)
825825

826826
var replicationFailed = false
@@ -871,7 +871,7 @@ private[spark] class BlockManager(
871871
blockTransferService.uploadBlockSync(
872872
peer.host, peer.port, blockId.toString, new NioByteBufferManagedBuffer(data), tLevel)
873873
logTrace(s"Replicated $blockId of ${data.limit()} bytes to $peer in %f ms"
874-
.format((System.currentTimeMillis - onePeerStartTime) / 1e3))
874+
.format((System.currentTimeMillis - onePeerStartTime)))
875875
peersReplicatedTo += peer
876876
peersForReplication -= peer
877877
replicationFailed = false
@@ -892,7 +892,7 @@ private[spark] class BlockManager(
892892
done = true
893893
}
894894
}
895-
val timeTakeMs = (System.currentTimeMillis - startTime) / 1e3
895+
val timeTakeMs = (System.currentTimeMillis - startTime)
896896
logDebug(s"Replicating $blockId of ${data.limit()} bytes to " +
897897
s"${peersReplicatedTo.size} peer(s) took $timeTakeMs ms")
898898
if (peersReplicatedTo.size < numPeersToReplicateTo) {

core/src/main/scala/org/apache/spark/storage/BlockManagerId.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class BlockManagerId private (
5959

6060
def port: Int = port_
6161

62-
def isDriver = (executorId == "<driver>")
62+
def isDriver: Boolean = (executorId == "<driver>")
6363

6464
override def writeExternal(out: ObjectOutput) {
6565
out.writeUTF(executorId_)

core/src/test/scala/org/apache/spark/storage/BlockManagerSuite.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,6 @@ class BlockManagerSuite extends FunSuite with Matchers with BeforeAndAfter
13721372
}
13731373

13741374
test("block replication - replication failures") {
1375-
13761375
/*
13771376
Create a system of three block managers / stores. One of them (say, failableStore)
13781377
cannot receive blocks. So attempts to use that as replication target fails.
@@ -1383,13 +1382,12 @@ class BlockManagerSuite extends FunSuite with Matchers with BeforeAndAfter
13831382
| |
13841383
-----/works/-----> store1 <----/fails/------
13851384
1386-
We are first going to add a normal store and a failable store, and test
1387-
whether 2x replication fails to create two copies of a block.
1388-
Then we are going to add the third normal store,
1385+
We are first going to add a normal block manager (i.e. store) and the failable block
1386+
manager (i.e. failableStore), and test whether 2x replication fails to create two
1387+
copies of a block. Then we are going to add another normal block manager (i.e., store1),
13891388
and test that now 2x replication works as the new store will be used for replication.
13901389
*/
13911390

1392-
13931391
// Insert a block with 2x replication and return the number of copies of the block
13941392
def replicateAndGetNumCopies(blockId: String): Int = {
13951393
store.putSingle(blockId, new Array[Byte](1000), StorageLevel.MEMORY_AND_DISK_2)
@@ -1490,7 +1488,7 @@ class BlockManagerSuite extends FunSuite with Matchers with BeforeAndAfter
14901488
i => makeBlockManager(storeSize, s"store$i")
14911489
}
14921490

1493-
storageLevels.foreach {storageLevel =>
1491+
storageLevels.foreach { storageLevel =>
14941492
// Put the block into one of the stores
14951493
val blockId = new TestBlockId(
14961494
"block-with-" + storageLevel.description.replace(" ", "-").toLowerCase)

0 commit comments

Comments
 (0)