Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9143#discussion_r42721825
  
    --- Diff: 
streaming/src/main/scala/org/apache/spark/streaming/scheduler/ReceivedBlockTracker.scala
 ---
    @@ -195,31 +285,56 @@ private[streaming] class ReceivedBlockTracker(
           timeToAllocatedBlocks --= batchTimes
         }
     
    +    def resolveEvent(event: ReceivedBlockTrackerLogEvent): Unit = {
    +      event match {
    +        case CombinedRBTLogEvent(events) => 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) {
    +  private def writeToLog(record: ReceivedBlockTrackerLogEvent): Boolean = {
         if (isWriteAheadLogEnabled) {
    -      logDebug(s"Writing to log $record")
           writeAheadLogOption.foreach { logManager =>
    +        logTrace(s"Writing record: $record")
             logManager.write(ByteBuffer.wrap(Utils.serialize(record)), 
clock.getTimeMillis())
           }
         }
    +    true
    +  }
    +
    +  import WALWriteStatus._
    +
    +  /**
    +   * Adds LogEvents to a queue so that they can be batched and written to 
the WAL.
    +   * Exposed for testing.
    +   */
    +  private[streaming] def writeToLogAsync(event: 
ReceivedBlockTrackerLogEvent): Boolean = {
    --- End diff --
    
    `writeToLogAsync` looks confusing. Actually, `async` usually means putting 
the work in another thread and return immediately, and it should run pretty 
fast. But in this method, it actually needs to wait for the result.


---
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]

Reply via email to