fix bug: can not get flow state

This commit is contained in:
judy0131 2020-04-28 15:28:24 +08:00
parent a366f1c1ab
commit 39dabc0eb7
1 changed files with 5 additions and 1 deletions

View File

@ -70,7 +70,10 @@ object HTTPService extends DefaultJsonProtocol with Directives with SprayJsonSup
if(!appID.equals("")){
var result = API.getFlowInfo(appID)
println("getFlowInfo result: " + result)
if (result.equals("")){
val resultMap = OptionUtil.getAny(JSON.parseFull(result)).asInstanceOf[Map[String, Any]]
val flowInfoMap = MapUtil.get(resultMap, "flow").asInstanceOf[Map[String, Any]]
if(!flowInfoMap.contains("state")) {
val yarnInfoJson = API.getFlowLog(appID)
val map = OptionUtil.getAny(JSON.parseFull(yarnInfoJson)).asInstanceOf[Map[String, Any]]
val appMap = MapUtil.get(map, "app").asInstanceOf[Map[String, Any]]
@ -86,6 +89,7 @@ object HTTPService extends DefaultJsonProtocol with Directives with SprayJsonSup
flowInfoMap += ("endTime" -> "")
flowInfoMap += ("stops" -> List())
result = JsonUtil.format(JsonUtil.toJson(Map("flow" -> flowInfoMap)))
println("getFlowInfo on Yarn: " + result)
}
Future.successful(HttpResponse(SUCCESS_CODE, entity = result))
}else{