Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/11502#discussion_r55106959
--- Diff: core/src/main/scala/org/apache/spark/storage/BlockManager.scala
---
@@ -868,34 +867,23 @@ private[spark] class BlockManager(
}
logDebug("Put block %s locally took %s".format(blockId,
Utils.getUsedTimeMs(startTimeMs)))
- // Either we're storing bytes and we asynchronously started
replication, or we're storing
- // values and need to serialize and replicate them now:
- if (putLevel.replication > 1) {
- data match {
- case ByteBufferValues(bytes) =>
- if (replicationFuture != null) {
- Await.ready(replicationFuture, Duration.Inf)
- }
- case _ =>
- if (blockWasSuccessfullyStored) {
- val remoteStartTime = System.currentTimeMillis
- // Serialize the block if not already done
- if (bytesAfterPut == null) {
- if (valuesAfterPut == null) {
- throw new SparkException(
- "Underlying put returned neither an Iterator nor bytes!
This shouldn't happen.")
- }
- bytesAfterPut = dataSerialize(blockId, valuesAfterPut)
- }
- replicate(blockId, bytesAfterPut, putLevel)
- logDebug("Put block %s remotely took %s"
- .format(blockId, Utils.getUsedTimeMs(remoteStartTime)))
- }
+ if (replicationFuture != null) {
+ // Wait for asynchronous replication to finish
+ Await.ready(replicationFuture, Duration.Inf)
+ } else if (putLevel.replication > 1 && blockWasSuccessfullyStored) {
+ val remoteStartTime = System.currentTimeMillis
+ val bytesToReplicate = doGetLocal(blockId, putBlockInfo,
asBlockResult = false).getOrElse {
+ throw new SparkException(s"Block $blockId was not found even
though it was just stored")
+ }.asInstanceOf[ByteBuffer]
--- End diff --
style: slightly prefer
```
doGetLocal(...)
.map(_.asInstanceOf[ByteBuffer])
.getOrElse { throw new SparkException(...) }
```
---
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]