From b245a7f6b43fdf0aff805ea7e9a055144cbf391e Mon Sep 17 00:00:00 2001 From: judy0131 Date: Sun, 19 Jan 2020 10:52:05 +0800 Subject: [PATCH] remove yarn.url configure item --- .../main/scala/cn/piflow/util/ConfigureUtil.scala | 15 ++++++++++++++- .../main/scala/cn/piflow/util/FlowLauncher.scala | 2 +- .../src/main/scala/cn/piflow/api/API.scala | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/piflow-core/src/main/scala/cn/piflow/util/ConfigureUtil.scala b/piflow-core/src/main/scala/cn/piflow/util/ConfigureUtil.scala index e5dde49..160a055 100644 --- a/piflow-core/src/main/scala/cn/piflow/util/ConfigureUtil.scala +++ b/piflow-core/src/main/scala/cn/piflow/util/ConfigureUtil.scala @@ -70,8 +70,21 @@ object ConfigureUtil { piflowBundlePath } + def getYarnResourceManagerWebAppAddress() : String = { + var yarnResourceManagerWebAppAddress = PropertyUtil.getPropertyValue("yarn.url") + if(yarnResourceManagerWebAppAddress == null){ + var port = "8088" + val yarnHostName = PropertyUtil.getPropertyValue("yarn.resourcemanager.hostname") + if(PropertyUtil.getPropertyValue("yarn.resourcemanager.webapp.address.port") != null){ + port = PropertyUtil.getPropertyValue("yarn.resourcemanager.webapp.address.port") + } + yarnResourceManagerWebAppAddress = "http://" + yarnHostName + ":" + port + "/ws/v1/cluster/apps/" + } + yarnResourceManagerWebAppAddress + } + def main(args: Array[String]): Unit = { - val piflowBundlePath = getPiFlowBundlePath() + val temp = getYarnResourceManagerWebAppAddress() } } diff --git a/piflow-core/src/main/scala/cn/piflow/util/FlowLauncher.scala b/piflow-core/src/main/scala/cn/piflow/util/FlowLauncher.scala index f609d6e..0200f4d 100644 --- a/piflow-core/src/main/scala/cn/piflow/util/FlowLauncher.scala +++ b/piflow-core/src/main/scala/cn/piflow/util/FlowLauncher.scala @@ -71,7 +71,7 @@ object FlowLauncher { println("Stop Flow !!!!!!!!!!!!!!!!!!!!!!!!!!") //yarn application kill appId - val url = PropertyUtil.getPropertyValue("yarn.url") + appID + "/state" + val url = ConfigureUtil.getYarnResourceManagerWebAppAddress() + appID + "/state" val client = HttpClients.createDefault() val put:HttpPut = new HttpPut(url) val body ="{\"state\":\"KILLED\"}" diff --git a/piflow-server/src/main/scala/cn/piflow/api/API.scala b/piflow-server/src/main/scala/cn/piflow/api/API.scala index f0d36d3..d3a6b5d 100644 --- a/piflow-server/src/main/scala/cn/piflow/api/API.scala +++ b/piflow-server/src/main/scala/cn/piflow/api/API.scala @@ -202,7 +202,7 @@ object API { def stopFlowOnYarn(appID : String) : String = { //yarn application kill appId - val url = PropertyUtil.getPropertyValue("yarn.url") + appID + "/state" + val url = ConfigureUtil.getYarnResourceManagerWebAppAddress() + appID + "/state" val client = HttpClients.createDefault() val put:HttpPut = new HttpPut(url) val body ="{\"state\":\"KILLED\"}" @@ -224,7 +224,7 @@ object API { } def getFlowLog(appID : String) : String = { - val url = PropertyUtil.getPropertyValue("yarn.url") + appID + val url = ConfigureUtil.getYarnResourceManagerWebAppAddress() + appID val client = HttpClients.createDefault() val get:HttpGet = new HttpGet(url)