Skip to content

Commit e62697f

Browse files
pan3793dongjoon-hyun
authored andcommitted
[SPARK-50805][CORE] Move method nameForAppAndAttempt to o.a.s.u.Utils
### What changes were proposed in this pull request? Pure refactor, move method `nameForAppAndAttempt` from `EventLogFileWriter` to `o.a.s.u.Utils`. ### Why are the changes needed? The method could be reused in several other places, e.g. #49440 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Pass GHA. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #49476 from pan3793/SPARK-50805. Authored-by: Cheng Pan <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 8858a4c commit e62697f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

core/src/main/scala/org/apache/spark/deploy/history/EventLogFileWriters.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,7 @@ object EventLogFileWriter {
187187
}
188188

189189
def nameForAppAndAttempt(appId: String, appAttemptId: Option[String]): String = {
190-
val base = Utils.sanitizeDirName(appId)
191-
if (appAttemptId.isDefined) {
192-
base + "_" + Utils.sanitizeDirName(appAttemptId.get)
193-
} else {
194-
base
195-
}
190+
Utils.nameForAppAndAttempt(appId, appAttemptId)
196191
}
197192

198193
def codecName(log: Path): Option[String] = {

core/src/main/scala/org/apache/spark/util/Utils.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2954,6 +2954,15 @@ private[spark] object Utils
29542954
str.replaceAll("[ :/]", "-").replaceAll("[.${}'\"]", "_").toLowerCase(Locale.ROOT)
29552955
}
29562956

2957+
def nameForAppAndAttempt(appId: String, appAttemptId: Option[String]): String = {
2958+
val base = sanitizeDirName(appId)
2959+
if (appAttemptId.isDefined) {
2960+
base + "_" + sanitizeDirName(appAttemptId.get)
2961+
} else {
2962+
base
2963+
}
2964+
}
2965+
29572966
def isClientMode(conf: SparkConf): Boolean = {
29582967
"client".equals(conf.get(SparkLauncher.DEPLOY_MODE, "client"))
29592968
}

0 commit comments

Comments
 (0)