Skip to content

Commit

Permalink
[SPARK-50805][CORE] Move method nameForAppAndAttempt to `o.a.s.u.Ut…
Browse files Browse the repository at this point in the history
…ils`

### 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]>
  • Loading branch information
pan3793 authored and dongjoon-hyun committed Jan 14, 2025
1 parent 8858a4c commit e62697f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,7 @@ object EventLogFileWriter {
}

def nameForAppAndAttempt(appId: String, appAttemptId: Option[String]): String = {
val base = Utils.sanitizeDirName(appId)
if (appAttemptId.isDefined) {
base + "_" + Utils.sanitizeDirName(appAttemptId.get)
} else {
base
}
Utils.nameForAppAndAttempt(appId, appAttemptId)
}

def codecName(log: Path): Option[String] = {
Expand Down
9 changes: 9 additions & 0 deletions core/src/main/scala/org/apache/spark/util/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2954,6 +2954,15 @@ private[spark] object Utils
str.replaceAll("[ :/]", "-").replaceAll("[.${}'\"]", "_").toLowerCase(Locale.ROOT)
}

def nameForAppAndAttempt(appId: String, appAttemptId: Option[String]): String = {
val base = sanitizeDirName(appId)
if (appAttemptId.isDefined) {
base + "_" + sanitizeDirName(appAttemptId.get)
} else {
base
}
}

def isClientMode(conf: SparkConf): Boolean = {
"client".equals(conf.get(SparkLauncher.DEPLOY_MODE, "client"))
}
Expand Down

0 comments on commit e62697f

Please sign in to comment.