-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-26790][CORE] Change approach for retrieving executor logs and attributes: self-retrieve #23706
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
[SPARK-26790][CORE] Change approach for retrieving executor logs and attributes: self-retrieve #23706
Changes from all commits
a9579b5
6a3ef10
23d5432
cf44bb4
6970d50
7992091
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 |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /* | ||
| * 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.executor | ||
|
|
||
| import java.net.URL | ||
|
|
||
| import org.apache.spark.SparkEnv | ||
| import org.apache.spark.deploy.SparkHadoopUtil | ||
| import org.apache.spark.internal.Logging | ||
| import org.apache.spark.rpc.RpcEnv | ||
| import org.apache.spark.util.YarnContainerInfoHelper | ||
|
|
||
| /** | ||
| * Custom implementation of CoarseGrainedExecutorBackend for YARN resource manager. | ||
| * This class extracts executor log URLs and executor attributes from system environment which | ||
| * properties are available for container being set via YARN. | ||
| */ | ||
| private[spark] class YarnCoarseGrainedExecutorBackend( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we have some comments here as to what does this class do?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry missed this. Just addressed. |
||
| rpcEnv: RpcEnv, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: indent args and extends one more level.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sorry I'm not sure I understand correctly. All args are 4 spaces and
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I swear I saw 2 spaces here when I looked at this code before. Ignore me. |
||
| driverUrl: String, | ||
| executorId: String, | ||
| hostname: String, | ||
| cores: Int, | ||
| userClassPath: Seq[URL], | ||
| env: SparkEnv) | ||
| extends CoarseGrainedExecutorBackend( | ||
| rpcEnv, | ||
| driverUrl, | ||
| executorId, | ||
| hostname, | ||
| cores, | ||
| userClassPath, | ||
| env) with Logging { | ||
|
|
||
| private lazy val hadoopConfiguration = SparkHadoopUtil.get.newConfiguration(env.conf) | ||
|
|
||
| override def extractLogUrls: Map[String, String] = { | ||
| YarnContainerInfoHelper.getLogUrls(hadoopConfiguration, container = None) | ||
| .getOrElse(Map()) | ||
| } | ||
|
|
||
| override def extractAttributes: Map[String, String] = { | ||
| YarnContainerInfoHelper.getAttributes(hadoopConfiguration, container = None) | ||
| .getOrElse(Map()) | ||
| } | ||
| } | ||
|
|
||
| private[spark] object YarnCoarseGrainedExecutorBackend extends Logging { | ||
|
|
||
| def main(args: Array[String]): Unit = { | ||
| val createFn: (RpcEnv, CoarseGrainedExecutorBackend.Arguments, SparkEnv) => | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I'm using |
||
| CoarseGrainedExecutorBackend = { case (rpcEnv, arguments, env) => | ||
| new YarnCoarseGrainedExecutorBackend(rpcEnv, arguments.driverUrl, arguments.executorId, | ||
| arguments.hostname, arguments.cores, arguments.userClassPath, env) | ||
| } | ||
| val backendArgs = CoarseGrainedExecutorBackend.parseArguments(args, | ||
| this.getClass.getCanonicalName.stripSuffix("$")) | ||
| CoarseGrainedExecutorBackend.run(backendArgs, createFn) | ||
| System.exit(0) | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,9 @@ private[spark] object YarnContainerInfoHelper extends Logging { | |
| val yarnConf = new YarnConfiguration(conf) | ||
| Some(Map( | ||
| "HTTP_SCHEME" -> getYarnHttpScheme(yarnConf), | ||
| "NM_HOST" -> getNodeManagerHost(container), | ||
| "NM_PORT" -> getNodeManagerPort(container), | ||
| "NM_HTTP_PORT" -> getNodeManagerHttpPort(container), | ||
| "NM_HTTP_ADDRESS" -> getNodeManagerHttpAddress(container), | ||
| "CLUSTER_ID" -> getClusterId(yarnConf).getOrElse(""), | ||
| "CONTAINER_ID" -> ConverterUtils.toString(getContainerId(container)), | ||
|
|
@@ -97,7 +100,22 @@ private[spark] object YarnContainerInfoHelper extends Logging { | |
|
|
||
| def getNodeManagerHttpAddress(container: Option[Container]): String = container match { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same applies to all methods: now we don't have an actual usage to pass Container as parameter, but it's still safer given that it's independent on context of process. Would we want to leave this as it is, or remove this and add a note to class (or methods) javadoc? |
||
| case Some(c) => c.getNodeHttpAddress | ||
| case None => System.getenv(Environment.NM_HOST.name()) + ":" + | ||
| System.getenv(Environment.NM_HTTP_PORT.name()) | ||
| case None => getNodeManagerHost(None) + ":" + getNodeManagerHttpPort(None) | ||
| } | ||
|
|
||
| def getNodeManagerHost(container: Option[Container]): String = container match { | ||
| case Some(c) => c.getNodeHttpAddress.split(":")(0) | ||
| case None => System.getenv(Environment.NM_HOST.name()) | ||
| } | ||
|
|
||
| def getNodeManagerHttpPort(container: Option[Container]): String = container match { | ||
| case Some(c) => c.getNodeHttpAddress.split(":")(1) | ||
| case None => System.getenv(Environment.NM_HTTP_PORT.name()) | ||
| } | ||
|
|
||
| def getNodeManagerPort(container: Option[Container]): String = container match { | ||
| case Some(_) => "-1" // Just return invalid port given we cannot retrieve the value | ||
| case None => System.getenv(Environment.NM_PORT.name()) | ||
| } | ||
|
|
||
| } | ||
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.
You want
classNameForEntry.stripSuffix("$"), either here or in the caller, or the help message will be wrong.Uh oh!
There was an error while loading. Please reload this page.
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.
Nice finding! Maybe I'm still thinking many things in Java way. Will address.