SbloodyS commented on code in PR #11119:
URL: https://github.com/apache/dolphinscheduler/pull/11119#discussion_r935086190


##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java:
##########
@@ -446,39 +447,39 @@ public ExecutionStatus getApplicationStatus(String 
applicationId) throws BaseExc
         if (StringUtils.isEmpty(applicationId)) {
             return null;
         }
+        String result = getResult(applicationId, "app", false);
+        if (result == null) {
+            //may be in job history
+            result = getResult(applicationId, "job", true);
+        }
+        return getExecutionStatus(result);
+    }
 
-        String result;
-        String applicationUrl = getApplicationUrl(applicationId);
-        logger.debug("generate yarn application url, applicationUrl={}", 
applicationUrl);
-
-        String responseContent = 
Boolean.TRUE.equals(PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE,
 false)) ? KerberosHttpClient.get(applicationUrl) : 
HttpUtils.get(applicationUrl);
+    private String getResult(String applicationId, String filedName, boolean 
isHistory) throws BaseException {
+        String url = isHistory ? getJobHistoryUrl(applicationId) : 
getApplicationUrl(applicationId);
+        logger.debug("generate yarn application url or job history application 
url, url={}", url);
+        String responseContent = 
Boolean.TRUE.equals(PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE,
 false)) ? KerberosHttpClient.get(url) : HttpUtils.get(url);
         if (responseContent != null) {
             ObjectNode jsonObject = JSONUtils.parseObject(responseContent);
-            if (!jsonObject.has("app")) {
-                return ExecutionStatus.FAILURE;
+            if (!jsonObject.has(filedName)) {
+                return Constants.FAILED;
             }
-            result = jsonObject.path("app").path("finalStatus").asText();

Review Comment:
   I think we could add the `UNDEFINED` logic here instead of making such a big 
change. WDYT?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to