Browse Source

YARN-4151. Fix findbugs errors in hadoop-yarn-server-common module. (Meng Ding via wangda)

(cherry picked from commit e2a02702178db60150cc0c2253d48b8532a474c2)
Wangda Tan 9 years ago
parent
commit
e552775545

+ 3 - 0
hadoop-yarn-project/CHANGES.txt

@@ -774,6 +774,9 @@ Release 2.8.0 - UNRELEASED
     YARN-4115. Reduce loglevel of ContainerManagementProtocolProxy to Debug
     (adhoot via rkanter)
 
+    YARN-4151. Fix findbugs errors in hadoop-yarn-server-common module.
+    (Meng Ding via wangda)
+
 Release 2.7.2 - UNRELEASED
 
   INCOMPATIBLE CHANGES

+ 4 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/records/impl/pb/NodeStatusPBImpl.java

@@ -293,7 +293,7 @@ public class NodeStatusPBImpl extends NodeStatus {
   }
 
   @Override
-  public ResourceUtilization getContainersUtilization() {
+  public synchronized ResourceUtilization getContainersUtilization() {
     NodeStatusProtoOrBuilder p =
         this.viaProto ? this.proto : this.builder;
     if (!p.hasContainersUtilization()) {
@@ -303,7 +303,7 @@ public class NodeStatusPBImpl extends NodeStatus {
   }
 
   @Override
-  public void setContainersUtilization(
+  public synchronized void setContainersUtilization(
       ResourceUtilization containersUtilization) {
     maybeInitBuilder();
     if (containersUtilization == null) {
@@ -315,7 +315,7 @@ public class NodeStatusPBImpl extends NodeStatus {
   }
 
   @Override
-  public ResourceUtilization getNodeUtilization() {
+  public synchronized ResourceUtilization getNodeUtilization() {
     NodeStatusProtoOrBuilder p =
         this.viaProto ? this.proto : this.builder;
     if (!p.hasNodeUtilization()) {
@@ -325,7 +325,7 @@ public class NodeStatusPBImpl extends NodeStatus {
   }
 
   @Override
-  public void setNodeUtilization(
+  public synchronized void setNodeUtilization(
       ResourceUtilization nodeUtilization) {
     maybeInitBuilder();
     if (nodeUtilization == null) {

+ 1 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebPageUtils.java

@@ -51,8 +51,7 @@ public class WebPageUtils {
     sb.append("[\n")
       .append("{'sType':'string', 'aTargets': [0]")
       .append(", 'mRender': parseHadoopID }")
-      .append("\n, {'sType':'numeric', 'aTargets': " +
-          (isFairSchedulerPage ? "[6, 7]": "[6, 7]"))
+      .append("\n, {'sType':'numeric', 'aTargets': [6, 7]")
       .append(", 'mRender': renderHadoopDate }")
       .append("\n, {'sType':'numeric', bSearchable:false, 'aTargets':");
     if (isFairSchedulerPage) {

+ 9 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebServices.java

@@ -167,6 +167,9 @@ public class WebServices {
     } catch (Exception e) {
       rewrapAndThrowException(e);
     }
+    if (appReports == null) {
+      return allApps;
+    }
     for (ApplicationReport appReport : appReports) {
 
       if (checkAppStates &&
@@ -266,6 +269,9 @@ public class WebServices {
       rewrapAndThrowException(e);
     }
     AppAttemptsInfo appAttemptsInfo = new AppAttemptsInfo();
+    if (appAttemptReports == null) {
+      return appAttemptsInfo;
+    }
     for (ApplicationAttemptReport appAttemptReport : appAttemptReports) {
       AppAttemptInfo appAttemptInfo = new AppAttemptInfo(appAttemptReport);
       appAttemptsInfo.add(appAttemptInfo);
@@ -336,6 +342,9 @@ public class WebServices {
       rewrapAndThrowException(e);
     }
     ContainersInfo containersInfo = new ContainersInfo();
+    if (containerReports == null) {
+      return containersInfo;
+    }
     for (ContainerReport containerReport : containerReports) {
       ContainerInfo containerInfo = new ContainerInfo(containerReport);
       containersInfo.add(containerInfo);