Skip to content

Commit

Permalink
[SPARK-2924] Required by scala 2.11, only one function/ctor amongst o…
Browse files Browse the repository at this point in the history
…verriden alternatives, can have default argument.
  • Loading branch information
ScrapCodes committed Oct 10, 2014
1 parent 14f222f commit d9785c3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
19 changes: 17 additions & 2 deletions core/src/main/scala/org/apache/spark/util/FileLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,27 @@ private[spark] class FileLogger(
def this(
logDir: String,
sparkConf: SparkConf,
compress: Boolean = false,
overwrite: Boolean = true) = {
compress: Boolean,
overwrite: Boolean) = {
this(logDir, sparkConf, SparkHadoopUtil.get.newConfiguration(sparkConf), compress = compress,
overwrite = overwrite)
}

def this(
logDir: String,
sparkConf: SparkConf,
compress: Boolean) = {
this(logDir, sparkConf, SparkHadoopUtil.get.newConfiguration(sparkConf), compress = compress,
overwrite = true)
}

def this(
logDir: String,
sparkConf: SparkConf) = {
this(logDir, sparkConf, SparkHadoopUtil.get.newConfiguration(sparkConf), compress = false,
overwrite = true)
}

private val dateFormat = new ThreadLocal[SimpleDateFormat]() {
override def initialValue(): SimpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ class FileLoggerSuite extends FunSuite with BeforeAndAfter {

test("Logging when directory already exists") {
// Create the logging directory multiple times
new FileLogger(logDirPathString, new SparkConf, overwrite = true).start()
new FileLogger(logDirPathString, new SparkConf, overwrite = true).start()
new FileLogger(logDirPathString, new SparkConf, overwrite = true).start()
new FileLogger(logDirPathString, new SparkConf, compress = false, overwrite = true).start()
new FileLogger(logDirPathString, new SparkConf, compress = false, overwrite = true).start()
new FileLogger(logDirPathString, new SparkConf, compress = false, overwrite = true).start()

// If overwrite is not enabled, an exception should be thrown
intercept[IOException] {
new FileLogger(logDirPathString, new SparkConf, overwrite = false).start()
new FileLogger(logDirPathString, new SparkConf, compress = false, overwrite = false).start()
}
}

Expand Down

0 comments on commit d9785c3

Please sign in to comment.