This is an automated email from the ASF dual-hosted git repository.
journey pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new ba3adbd [FIXBUG][common]fix yarn applications status cause
NPE(#3645) (#3648)
ba3adbd is described below
commit ba3adbd34b8b260f01e92b25612cfdb5c2370f6e
Author: 小清 <[email protected]>
AuthorDate: Mon Sep 7 10:36:43 2020 +0800
[FIXBUG][common]fix yarn applications status cause NPE(#3645) (#3648)
* fix #3645
fix get yarn applications status from yarn server,http code return 404, get
yarn applications status cause NullPointerException
* Update HadoopUtils.java
* Update HadoopUtils.java
---
.../dolphinscheduler/common/utils/HadoopUtils.java | 34 +++++++++++++---------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java
index cc75624..68d0350 100644
---
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java
+++
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java
@@ -195,7 +195,7 @@ public class HadoopUtils implements Closeable {
*/
String appUrl = "";
- if (StringUtils.isEmpty(rmHaIds)){
+ if (StringUtils.isEmpty(rmHaIds)) {
//single resourcemanager enabled
appUrl = appAddress;
yarnEnabled = true;
@@ -206,7 +206,7 @@ public class HadoopUtils implements Closeable {
logger.info("application url : {}", appUrl);
}
- if(StringUtils.isBlank(appUrl)){
+ if (StringUtils.isBlank(appUrl)) {
throw new Exception("application url is blank");
}
return String.format(appUrl, applicationId);
@@ -417,25 +417,33 @@ public class HadoopUtils implements Closeable {
String applicationUrl = getApplicationUrl(applicationId);
logger.info("applicationUrl={}", applicationUrl);
- String responseContent ;
- if
(PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE,
false)) {
- responseContent =
KerberosHttpClient.get(applicationUrl);
- } else {
- responseContent = HttpUtils.get(applicationUrl);
- }
+ String responseContent;
+ if
(PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE,
false)) {
+ responseContent = KerberosHttpClient.get(applicationUrl);
+ } else {
+ responseContent = HttpUtils.get(applicationUrl);
+ }
if (responseContent != null) {
ObjectNode jsonObject = JSONUtils.parseObject(responseContent);
+ if (!jsonObject.has("app")) {
+ return ExecutionStatus.FAILURE;
+ }
result = jsonObject.path("app").path("finalStatus").asText();
+
} else {
//may be in job history
String jobHistoryUrl = getJobHistoryUrl(applicationId);
logger.info("jobHistoryUrl={}", jobHistoryUrl);
responseContent = HttpUtils.get(jobHistoryUrl);
- ObjectNode jsonObject = JSONUtils.parseObject(responseContent);
- if (!jsonObject.has("job")){
+ if (null != responseContent) {
+ ObjectNode jsonObject = JSONUtils.parseObject(responseContent);
+ if (!jsonObject.has("job")) {
+ return ExecutionStatus.FAILURE;
+ }
+ result = jsonObject.path("job").path("state").asText();
+ } else {
return ExecutionStatus.FAILURE;
}
- result = jsonObject.path("job").path("state").asText();
}
switch (result) {
@@ -474,7 +482,7 @@ public class HadoopUtils implements Closeable {
/**
* hdfs resource dir
*
- * @param tenantCode tenant code
+ * @param tenantCode tenant code
* @param resourceType resource type
* @return hdfs resource dir
*/
@@ -679,7 +687,7 @@ public class HadoopUtils implements Closeable {
ObjectNode jsonObject = JSONUtils.parseObject(retStr);
//get ResourceManager state
- if (!jsonObject.has("clusterInfo")){
+ if (!jsonObject.has("clusterInfo")) {
return null;
}
return jsonObject.get("clusterInfo").path("haState").asText();