Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Address the comments
  • Loading branch information
jerryshao committed May 2, 2015
commit d237ba587b01d6fe297ba6702369e17cc58e2f78
Original file line number Diff line number Diff line change
Expand Up @@ -147,25 +147,8 @@ private[spark] class ExecutorAllocationManager(
private val executor =
ThreadUtils.newDaemonSingleThreadScheduledExecutor("spark-dynamic-executor-allocation")

// Metric source for ExecutorAllocationManager to expose the its internal executor allocation
// status to MetricsSystem.
private[spark] val executorAllocationManagerSource = new Source {
val sourceName = "ExecutorAllocationManager"
val metricRegistry = new MetricRegistry()

private def registerGauge[T](name: String, value: => T, defaultValue: T): Unit = {
metricRegistry.register(MetricRegistry.name("executors", name), new Gauge[T] {
override def getValue: T = synchronized { Option(value).getOrElse(defaultValue) }
})
}

registerGauge("numberExecutorsToAdd", numExecutorsToAdd, 0)
registerGauge("numberExecutorsPending", numExecutorsPending, 0)
registerGauge("numberExecutorsPendingToRemove", executorsPendingToRemove.size, 0)
registerGauge("numberAllExecutors", executorIds.size, 0)
registerGauge("numberTargetExecutors", targetNumExecutors(), 0)
registerGauge("numberMaxNeededExecutors", maxNumExecutorsNeeded(), 0)
}
// Metric source for ExecutorAllocationManager to expose internal status to MetricsSystem.
private[spark] val executorAllocationManagerSource = new ExecutorAllocationManagerSource

/**
* Verify that the settings specified through the config are valid.
Expand Down Expand Up @@ -602,6 +585,26 @@ private[spark] class ExecutorAllocationManager(
}
}

// Metric source for ExecutorAllocationManager to expose the its internal executor allocation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "the" and "its" are redundant. Also, this should be a block-style comment.

// status to MetricsSystem.
// Note: these metrics may not be stable across Spark version.
private[spark] class ExecutorAllocationManagerSource extends Source {
val sourceName = "ExecutorAllocationManager"
val metricRegistry = new MetricRegistry()

private def registerGauge[T](name: String, value: => T, defaultValue: T): Unit = {
metricRegistry.register(MetricRegistry.name("executors", name), new Gauge[T] {
override def getValue: T = synchronized { Option(value).getOrElse(defaultValue) }
})
}

registerGauge("numberExecutorsToAdd", numExecutorsToAdd, 0)
registerGauge("numberExecutorsPending", numExecutorsPending, 0)
registerGauge("numberExecutorsPendingToRemove", executorsPendingToRemove.size, 0)
registerGauge("numberAllExecutors", executorIds.size, 0)
registerGauge("numberTargetExecutors", targetNumExecutors(), 0)
registerGauge("numberMaxNeededExecutors", maxNumExecutorsNeeded(), 0)
}
}

private object ExecutorAllocationManager {
Expand Down