Github user manuzhang commented on a diff in the pull request:
https://github.com/apache/incubator-gearpump/pull/231#discussion_r145602983
--- Diff:
experiments/yarn/src/main/scala/org/apache/gearpump/experiments/yarn/client/AppMasterResolver.scala
---
@@ -75,3 +64,38 @@ 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.getOriginalTrackingUrl}" +
"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)
+ connection.connect()
+ val status = connection.getResponseCode
+
+ var stream: java.io.InputStream = connection.getErrorStream
--- End diff --
Shall we check `status` first since otherwise there is no need to check
`stream` ?
---