Skip to content

Commit c7d00a2

Browse files
author
Marcelo Vanzin
committed
[SPARK-13280][STREAMING] Use a better logger name for FileBasedWriteAheadLog.
The new logger name is under the org.apache.spark namespace. The detection of the caller name was also enhanced a bit to ignore some common things that show up in the call stack. Author: Marcelo Vanzin <[email protected]> Closes #11165 from vanzin/SPARK-13280.
1 parent 19dc69d commit c7d00a2

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

streaming/src/main/scala/org/apache/spark/streaming/util/FileBasedWriteAheadLog.scala

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,18 @@ private[streaming] class FileBasedWriteAheadLog(
5757
import FileBasedWriteAheadLog._
5858

5959
private val pastLogs = new ArrayBuffer[LogInfo]
60-
private val callerNameTag = getCallerName.map(c => s" for $c").getOrElse("")
60+
private val callerName = getCallerName
6161

62-
private val threadpoolName = s"WriteAheadLogManager $callerNameTag"
62+
private val threadpoolName = {
63+
"WriteAheadLogManager" + callerName.map(c => s" for $c").getOrElse("")
64+
}
6365
private val threadpool = ThreadUtils.newDaemonCachedThreadPool(threadpoolName, 20)
6466
private val executionContext = ExecutionContext.fromExecutorService(threadpool)
65-
override protected val logName = s"WriteAheadLogManager $callerNameTag"
67+
68+
override protected def logName = {
69+
getClass.getName.stripSuffix("$") +
70+
callerName.map("_" + _).getOrElse("").replaceAll("[ ]", "_")
71+
}
6672

6773
private var currentLogPath: Option[String] = None
6874
private var currentLogWriter: FileBasedWriteAheadLogWriter = null
@@ -253,8 +259,12 @@ private[streaming] object FileBasedWriteAheadLog {
253259
}
254260

255261
def getCallerName(): Option[String] = {
256-
val stackTraceClasses = Thread.currentThread.getStackTrace().map(_.getClassName)
257-
stackTraceClasses.find(!_.contains("WriteAheadLog")).flatMap(_.split("\\.").lastOption)
262+
val blacklist = Seq("WriteAheadLog", "Logging", "java.lang", "scala.")
263+
Thread.currentThread.getStackTrace()
264+
.map(_.getClassName)
265+
.find { c => !blacklist.exists(c.contains) }
266+
.flatMap(_.split("\\.").lastOption)
267+
.flatMap(_.split("\\$\\$").headOption)
258268
}
259269

260270
/** Convert a sequence of files to a sequence of sorted LogInfo objects */

0 commit comments

Comments
 (0)