sarutak commented on code in PR #54575:
URL: https://github.com/apache/spark/pull/54575#discussion_r2884856707
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -122,6 +127,43 @@ private[history] class FsHistoryProvider(conf: SparkConf,
clock: Clock)
// Visible for testing
private[history] val fs: FileSystem = new
Path(logDir).getFileSystem(hadoopConf)
+ // Map from logDir to its FileSystem, for multi-path support.
+ // Visible for testing
+ private[history] val logDirFs: Map[String, FileSystem] = logDirs.map { dir =>
+ dir -> new Path(dir).getFileSystem(hadoopConf)
+ }.toMap
+
+ // Map from logDir to display name for UI
+ private val logDirToDisplayName: Map[String, String] = {
+ val names = conf.get(HISTORY_LOG_DIR_NAMES).map(_.split(",",
-1).map(_.trim))
+ names match {
+ case Some(n) if n.length == logDirs.length =>
+ val mapping = logDirs.zip(n).map { case (dir, name) =>
+ dir -> (if (name.nonEmpty) name else dir)
+ }
+ val displayNames = mapping.map(_._2)
+ val duplicates = displayNames.groupBy(identity).filter(_._2.size >
1).keys
+ require(duplicates.isEmpty,
+ s"Duplicate display names found in ${HISTORY_LOG_DIR_NAMES.key}: " +
+ s"${duplicates.mkString(", ")}")
+ mapping.toMap
+ case Some(n) =>
+ logWarning(s"${HISTORY_LOG_DIR_NAMES.key} has ${n.length} names but " +
+ s"${logDirs.length} directories were specified. Falling back to full
paths.")
+ logDirs.map(d => d -> d).toMap
+ case None =>
+ logDirs.map(d => d -> d).toMap
+ }
+ }
+
+ // Normalized logDir paths for efficient and safe matching
+ private val normalizedLogDirs: Seq[(Path, String, String)] = logDirs.map {
dir =>
+ val path = new Path(dir)
+ val dirFs = logDirFs(dir)
+ val normalized = path.makeQualified(dirFs.getUri,
dirFs.getWorkingDirectory)
+ (normalized, logDirToDisplayName(dir), dir)
+ }.sortBy(-_._1.depth()) // Sort by depth descending for longest prefix match
Review Comment:
Thanks. Update the doc.
https://github.com/apache/spark/pull/54575/changes#diff-5451393354374ef994bc816d1c0a86459be726bd231dc37b4385707be6b56921R176
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]