Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-13280] [streaming] Use a better logger name for FileBasedWriteAheadLog. #11165

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,18 @@ private[streaming] class FileBasedWriteAheadLog(
import FileBasedWriteAheadLog._

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

private val threadpoolName = s"WriteAheadLogManager $callerNameTag"
private val threadpoolName = {
"WriteAheadLogManager" + callerName.map(c => s" for $c").getOrElse("")
}
private val threadpool = ThreadUtils.newDaemonCachedThreadPool(threadpoolName, 20)
private val executionContext = ExecutionContext.fromExecutorService(threadpool)
override protected val logName = s"WriteAheadLogManager $callerNameTag"

override protected def logName = {
getClass.getName.stripSuffix("$") +
callerName.map("_" + _).getOrElse("").replaceAll("[ ]", "_")
}

private var currentLogPath: Option[String] = None
private var currentLogWriter: FileBasedWriteAheadLogWriter = null
Expand Down Expand Up @@ -253,8 +259,12 @@ private[streaming] object FileBasedWriteAheadLog {
}

def getCallerName(): Option[String] = {
val stackTraceClasses = Thread.currentThread.getStackTrace().map(_.getClassName)
stackTraceClasses.find(!_.contains("WriteAheadLog")).flatMap(_.split("\\.").lastOption)
val blacklist = Seq("WriteAheadLog", "Logging", "java.lang", "scala.")
Thread.currentThread.getStackTrace()
.map(_.getClassName)
.find { c => !blacklist.exists(c.contains) }
.flatMap(_.split("\\.").lastOption)
.flatMap(_.split("\\$\\$").headOption)
}

/** Convert a sequence of files to a sequence of sorted LogInfo objects */
Expand Down