diff options
author | Marcelo Vanzin <vanzin@cloudera.com> | 2016-02-16 11:25:43 -0800 |
---|---|---|
committer | Marcelo Vanzin <vanzin@cloudera.com> | 2016-02-16 11:25:43 -0800 |
commit | c7d00a24da317c9601a9239ac1cf185fb6647352 (patch) | |
tree | 755c4d57910751981ff1afe8abd7b80bd0fbb9b6 | |
parent | 19dc69de795eb08f3bab4988ad88732bf8ca7bae (diff) | |
download | spark-c7d00a24da317c9601a9239ac1cf185fb6647352.tar.gz spark-c7d00a24da317c9601a9239ac1cf185fb6647352.tar.bz2 spark-c7d00a24da317c9601a9239ac1cf185fb6647352.zip |
[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 <vanzin@cloudera.com>
Closes #11165 from vanzin/SPARK-13280.
-rw-r--r-- | streaming/src/main/scala/org/apache/spark/streaming/util/FileBasedWriteAheadLog.scala | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/streaming/src/main/scala/org/apache/spark/streaming/util/FileBasedWriteAheadLog.scala b/streaming/src/main/scala/org/apache/spark/streaming/util/FileBasedWriteAheadLog.scala index 15ad2e27d3..314263f26e 100644 --- a/streaming/src/main/scala/org/apache/spark/streaming/util/FileBasedWriteAheadLog.scala +++ b/streaming/src/main/scala/org/apache/spark/streaming/util/FileBasedWriteAheadLog.scala @@ -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 @@ -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 */ |