gearpump-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From titikakatoo <...@git.apache.org>
Subject [GitHub] incubator-gearpump pull request #231: [GEARPUMP-355] Fix YarnAppMaster addre...
Date Fri, 20 Oct 2017 16:04:22 GMT
Github user titikakatoo commented on a diff in the pull request:

    https://github.com/apache/incubator-gearpump/pull/231#discussion_r146003668
  
    --- Diff: experiments/yarn/src/main/scala/org/apache/gearpump/experiments/yarn/client/AppMasterResolver.scala
---
    @@ -75,3 +65,40 @@ class AppMasterResolver(yarnClient: YarnClient, system: ActorSystem)
{
         result
       }
     }
    +
    +object AppMasterResolver {
    +  val LOG = LogUtil.getLogger(getClass)
    +
    +  def resolveAppMasterAddress(report: ApplicationReport, system: ActorSystem): ActorRef
= {
    +    val appMasterPath = s"${report.getTrackingURL}/supervisor-actor-path"
    +    LOG.info(s"appMasterPath=$appMasterPath")
    +
    +    val connectionFactory: URLConnectionFactory = URLConnectionFactory
    +      .newDefaultURLConnectionFactory(new YarnConfiguration())
    +    val url: URL = new URL(appMasterPath)
    +    val connection: HttpURLConnection = connectionFactory.openConnection(url)
    +      .asInstanceOf[HttpURLConnection]
    +    connection.setInstanceFollowRedirects(true)
    +
    +    try {
    +      connection.connect()
    +    } catch {
    +      case e: IOException =>
    +        LOG.error(s"Failed to connect to AppMaster" + e.getMessage)
    +    }
    +
    +    val status = connection.getResponseCode
    +    if (status == 200) {
    +      val stream: java.io.InputStream = connection.getInputStream
    +      val response = IOUtils.toString(stream, StandardCharsets.UTF_8)
    +      LOG.info("Successfully resolved AppMaster address: " + response)
    +      connection.disconnect()
    +      AkkaHelper.actorFor(system, response)
    +    } else {
    +      connection.disconnect()
    +      throw new IOException("Fail to resolve AppMaster address, please make sure " +
    +        s"${report.getOriginalTrackingUrl} is accessible...")
    --- End diff --
    
    @manuzhang getTrackingURL was merged already in the master branch.


---

Mime
View raw message