Github user andrewor14 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3652#discussion_r22066707
  
    --- Diff: 
yarn/src/main/scala/org/apache/spark/deploy/yarn/YarnRMClient.scala ---
    @@ -54,15 +82,45 @@ trait YarnRMClient {
        * @param status The final status of the AM.
        * @param diagnostics Diagnostics message to include in the final status.
        */
    -  def unregister(status: FinalApplicationStatus, diagnostics: String = 
""): Unit
    +  def unregister(status: FinalApplicationStatus, diagnostics: String = 
""): Unit = synchronized {
    +    if (registered) {
    +      amClient.unregisterApplicationMaster(status, diagnostics, 
uiHistoryAddress)
    +    }
    +  }
     
       /** Returns the attempt ID. */
    -  def getAttemptId(): ApplicationAttemptId
    +  def getAttemptId(): ApplicationAttemptId = {
    +    val containerIdString = 
System.getenv(ApplicationConstants.Environment.CONTAINER_ID.name())
    +    val containerId = ConverterUtils.toContainerId(containerIdString)
    +    containerId.getApplicationAttemptId()
    +  }
     
       /** Returns the configuration for the AmIpFilter to add to the Spark UI. 
*/
    -  def getAmIpFilterParams(conf: YarnConfiguration, proxyBase: String): 
Map[String, String]
    +  def getAmIpFilterParams(conf: YarnConfiguration, proxyBase: String): 
Map[String, String] = {
    +    // Figure out which scheme Yarn is using. Note the method seems to 
have been added after 2.2,
    +    // so not all stable releases have it.
    +    val prefix = Try(classOf[WebAppUtils].getMethod("getHttpSchemePrefix", 
classOf[Configuration])
    +      .invoke(null, conf).asInstanceOf[String]).getOrElse("http://";)
    +
    +    // If running a new enough Yarn, use the HA-aware API for retrieving 
the RM addresses.
    +    try {
    +      val method = 
classOf[WebAppUtils].getMethod("getProxyHostsAndPortsForAmFilter",
    +        classOf[Configuration])
    +      val proxies = method.invoke(null, conf).asInstanceOf[JList[String]]
    +      val hosts = proxies.map { proxy => proxy.split(":")(0) }
    +      val uriBases = proxies.map { proxy => prefix + proxy + proxyBase }
    +      Map("PROXY_HOSTS" -> hosts.mkString(","), "PROXY_URI_BASES" -> 
uriBases.mkString(","))
    +    } catch {
    +      case e: NoSuchMethodException =>
    +        val proxy = WebAppUtils.getProxyHostAndPort(conf)
    +        val parts = proxy.split(":")
    +        val uriBase = prefix + proxy + proxyBase
    +        Map("PROXY_HOST" -> parts(0), "PROXY_URI_BASE" -> uriBase)
    +    }
    +  }
     
       /** Returns the maximum number of attempts to register the AM. */
    -  def getMaxRegAttempts(conf: YarnConfiguration): Int
    +  def getMaxRegAttempts(conf: YarnConfiguration) =
    --- End diff --
    
    should keep return type


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to