Skip to content

Commit

Permalink
metrics code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-williams committed Feb 13, 2015
1 parent 56287db commit 31d2c30
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions core/src/main/scala/org/apache/spark/metrics/MetricsConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,23 @@ private[spark] class MetricsConfig(val configFile: Option[String]) extends Loggi
setDefaultProperties(properties)

// If spark.metrics.conf is not set, try to get file in class path
(configFile match {
case Some(f) => {
logInfo(s"Loading MetricsConfig file: $f")
Some(new FileInputStream(f))
val isOpt: Option[InputStream] = configFile.map(new FileInputStream(_)).orElse {
try {
Option(Utils.getSparkClassLoader.getResourceAsStream(METRICS_CONF))
} catch {
case e: Exception =>
logError("Error loading default configuration file", e)
None
}
case None =>
try {
Some(Utils.getSparkClassLoader.getResourceAsStream(METRICS_CONF))
} catch {
case e: Exception => {
logError("Error loading default configuration file", e)
None
}
}
}).foreach(is =>
}

isOpt.foreach { is =>
try {
properties.load(is)
} finally {
is.close()
}
)
}

propertyCategories = subProperties(properties, INSTANCE_REGEX)
if (propertyCategories.contains(DEFAULT_PREFIX)) {
Expand Down

0 comments on commit 31d2c30

Please sign in to comment.