HeartSaVioR commented on a change in pull request #28412:
URL: https://github.com/apache/spark/pull/28412#discussion_r437784544
##########
File path:
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala
##########
@@ -1197,6 +1213,78 @@ private[history] class FsHistoryProvider(conf:
SparkConf, clock: Clock)
KVUtils.open(newStorePath, metadata)
}
+ private def createHybridStore(
+ dm: HistoryServerDiskManager,
+ appId: String,
+ attempt: AttemptInfoWrapper,
+ metadata: AppStatusStoreMetadata): KVStore = {
+
+ var retried = false
+ var hybridStore: HybridStore = null
+ while (hybridStore == null) {
+ val reader = EventLogFileReader(fs, new Path(logDir, attempt.logPath),
+ attempt.lastIndex)
+ val isCompressed = reader.compressionCodec.isDefined
+
+ // Throws an exception if the memory space is not enough
+ memoryManager.lease(appId, attempt.info.attemptId, reader.totalSize,
isCompressed)
+
+ logInfo(s"Leasing disk manager space for app $appId /
${attempt.info.attemptId}...")
+ val lease = dm.lease(reader.totalSize, isCompressed)
+ val isLeaseRolledBack = new
java.util.concurrent.atomic.AtomicBoolean(false)
+ var store: HybridStore = null
+ try {
+ store = new HybridStore()
+ val levelDB = KVUtils.open(lease.tmpPath, metadata)
+ store.setLevelDB(levelDB)
+ rebuildAppStore(store, reader, attempt.info.lastUpdated.getTime())
+
+ // Start the background thread to dump data to levelDB when writing to
+ // InMemoryStore is completed.
+ store.switchToLevelDB(new HybridStore.SwitchToLevelDBListener {
Review comment:
The reason to split is that retrial logic is only valid for replaying -
that said, only in-memory store is used while replaying, and you don't need to
prepare Level DB and deal with disk lease (acquire/rollback) at that time. You
just need to deal with it "after" replaying which should simplify the logic.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]