-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-24594][YARN] Introducing metrics for YARN #21635
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
Changes from 9 commits
9b033cc
4968ad6
9735525
a8f3146
b0ee4ec
68ba47e
f3781bd
6751ec5
c0c4748
7958525
6761098
0b86788
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,7 @@ import org.apache.spark.deploy.yarn.config._ | |
| import org.apache.spark.deploy.yarn.security.AMCredentialRenewer | ||
| import org.apache.spark.internal.Logging | ||
| import org.apache.spark.internal.config._ | ||
| import org.apache.spark.metrics.MetricsSystem | ||
| import org.apache.spark.rpc._ | ||
| import org.apache.spark.scheduler.cluster.{CoarseGrainedSchedulerBackend, YarnSchedulerBackend} | ||
| import org.apache.spark.scheduler.cluster.CoarseGrainedClusterMessages._ | ||
|
|
@@ -67,6 +68,8 @@ private[spark] class ApplicationMaster(args: ApplicationMasterArguments) extends | |
|
|
||
| private val securityMgr = new SecurityManager(sparkConf) | ||
|
|
||
| private var metricsSystem: Option[MetricsSystem] = None | ||
|
|
||
| // Set system properties for each config entry. This covers two use cases: | ||
| // - The default configuration stored by the SparkHadoopUtil class | ||
| // - The user application creating a new SparkConf in cluster mode | ||
|
|
@@ -309,6 +312,16 @@ private[spark] class ApplicationMaster(args: ApplicationMasterArguments) extends | |
| finish(FinalApplicationStatus.FAILED, | ||
| ApplicationMaster.EXIT_UNCAUGHT_EXCEPTION, | ||
| "Uncaught exception: " + StringUtils.stringifyException(e)) | ||
| } finally { | ||
| try { | ||
| metricsSystem.foreach { ms => | ||
| ms.report() | ||
| ms.stop() | ||
| } | ||
| } catch { | ||
| case e: Exception => | ||
| logInfo("Exception during stopping of the metric system: ", e) | ||
|
||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -434,6 +447,10 @@ private[spark] class ApplicationMaster(args: ApplicationMasterArguments) extends | |
| rpcEnv.setupEndpoint("YarnAM", new AMEndpoint(rpcEnv, driverRef)) | ||
|
|
||
| allocator.allocateResources() | ||
| val ms = MetricsSystem.createMetricsSystem("applicationMaster", sparkConf, securityMgr) | ||
| ms.registerSource(new ApplicationMasterSource(allocator)) | ||
| ms.start() | ||
| metricsSystem = Some(ms) | ||
| reporterThread = launchReporterThread() | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark.deploy.yarn | ||
|
|
||
| import com.codahale.metrics.{Gauge, MetricRegistry} | ||
|
|
||
| import org.apache.spark.metrics.source.Source | ||
|
|
||
| private[spark] class ApplicationMasterSource(yarnAllocator: YarnAllocator) extends Source { | ||
|
|
||
| override val sourceName: String = "applicationMaster" | ||
|
||
| override val metricRegistry: MetricRegistry = new MetricRegistry() | ||
|
|
||
| metricRegistry.register(MetricRegistry.name("numExecutorsFailed"), new Gauge[Int] { | ||
| override def getValue: Int = yarnAllocator.getNumExecutorsFailed | ||
| }) | ||
|
|
||
| metricRegistry.register(MetricRegistry.name("numExecutorsRunning"), new Gauge[Int] { | ||
| override def getValue: Int = yarnAllocator.getNumExecutorsRunning | ||
| }) | ||
|
|
||
| metricRegistry.register(MetricRegistry.name("numReleasedContainers"), new Gauge[Int] { | ||
| override def getValue: Int = yarnAllocator.getNumReleasedContainers | ||
| }) | ||
|
|
||
| metricRegistry.register(MetricRegistry.name("numLocalityAwareTasks"), new Gauge[Int] { | ||
| override def getValue: Int = yarnAllocator.numLocalityAwareTasks | ||
| }) | ||
|
|
||
| metricRegistry.register(MetricRegistry.name("numContainersPendingAllocate"), new Gauge[Int] { | ||
| override def getValue: Int = yarnAllocator.numContainersPendingAllocate | ||
| }) | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to clarify as "The Spark ApplicationMaster when running on YARN."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, updated accordingly.