Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/9143#discussion_r43435131
--- Diff:
streaming/src/main/scala/org/apache/spark/streaming/scheduler/ReceivedBlockTracker.scala
---
@@ -195,30 +219,35 @@ private[streaming] class ReceivedBlockTracker(
timeToAllocatedBlocks --= batchTimes
}
+ def resolveEvent(event: ReceivedBlockTrackerLogEvent): Unit = {
+ event match {
+ case CombinedReceivedBlockTrackerLogEvent(events) =>
+ BatchedWriteAheadLog.deaggregate(events).foreach(resolveEvent)
+ case BlockAdditionEvent(receivedBlockInfo) =>
+ insertAddedBlock(receivedBlockInfo)
+ case BatchAllocationEvent(time, allocatedBlocks) =>
+ insertAllocatedBatch(time, allocatedBlocks)
+ case BatchCleanupEvent(batchTimes) =>
+ cleanupBatches(batchTimes)
+ }
+ }
+
writeAheadLogOption.foreach { writeAheadLog =>
logInfo(s"Recovering from write ahead logs in
${checkpointDirOption.get}")
writeAheadLog.readAll().asScala.foreach { byteBuffer =>
logTrace("Recovering record " + byteBuffer)
- Utils.deserialize[ReceivedBlockTrackerLogEvent](
- byteBuffer.array, Thread.currentThread().getContextClassLoader)
match {
- case BlockAdditionEvent(receivedBlockInfo) =>
- insertAddedBlock(receivedBlockInfo)
- case BatchAllocationEvent(time, allocatedBlocks) =>
- insertAllocatedBatch(time, allocatedBlocks)
- case BatchCleanupEvent(batchTimes) =>
- cleanupBatches(batchTimes)
- }
+ resolveEvent(Utils.deserialize[ReceivedBlockTrackerLogEvent](
+ byteBuffer.array, Thread.currentThread().getContextClassLoader))
}
}
}
/** Write an update to the tracker to the write ahead log */
- private def writeToLog(record: ReceivedBlockTrackerLogEvent) {
- if (isWriteAheadLogEnabled) {
- logDebug(s"Writing to log $record")
- writeAheadLogOption.foreach { logManager =>
- logManager.write(ByteBuffer.wrap(Utils.serialize(record)),
clock.getTimeMillis())
- }
+ private[streaming] def writeToLog(record: ReceivedBlockTrackerLogEvent):
Boolean = {
+ if (!isWriteAheadLogEnabled) return true
+ writeAheadLogOption.exists { logManager =>
--- End diff --
This is hard to read, as we dont usually use exists. Mind using simple `if`
statements here. The exists of the WAL is already being checked in the above if.
---
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]