Преглед изворни кода

YARN-6766. Add helper method in FairSchedulerAppsBlock to print app info. Contributed by Riya Khandelwal

Szilard Nemeth пре 2 година
родитељ
комит
0c515b0ef0

+ 16 - 10
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/FairSchedulerAppsBlock.java

@@ -129,6 +129,12 @@ public class FairSchedulerAppsBlock extends HtmlBlock {
     return true;
   }
 
+  private static String printAppInfo(long value) {
+    if (value == -1) {
+      return "N/A";
+    }
+    return String.valueOf(value);
+  }
 
   @Override public void render(Block html) {
     TBODY<TABLE<Hamlet>> tbody = html.
@@ -193,16 +199,16 @@ public class FairSchedulerAppsBlock extends HtmlBlock {
       .append(appInfo.getFinishTime()).append("\",\"")
       .append(appInfo.getState()).append("\",\"")
       .append(appInfo.getFinalStatus()).append("\",\"")
-      .append(appInfo.getRunningContainers() == -1 ? "N/A" : String
-         .valueOf(appInfo.getRunningContainers())).append("\",\"")
-      .append(appInfo.getAllocatedVCores() == -1 ? "N/A" : String
-        .valueOf(appInfo.getAllocatedVCores())).append("\",\"")
-      .append(appInfo.getAllocatedMB() == -1 ? "N/A" : String
-        .valueOf(appInfo.getAllocatedMB())).append("\",\"")
-      .append(appInfo.getReservedVCores() == -1 ? "N/A" : String
-        .valueOf(appInfo.getReservedVCores())).append("\",\"")
-      .append(appInfo.getReservedMB() == -1 ? "N/A" : String
-        .valueOf(appInfo.getReservedMB())).append("\",\"")
+      .append(printAppInfo(appInfo.getRunningContainers()))
+      .append("\",\"")
+      .append(printAppInfo(appInfo.getAllocatedVCores()))
+      .append("\",\"")
+      .append(printAppInfo(appInfo.getAllocatedMB()))
+      .append("\",\"")
+      .append(printAppInfo(appInfo.getReservedVCores()))
+      .append("\",\"")
+      .append(printAppInfo(appInfo.getReservedMB()))
+      .append("\",\"")
       // Progress bar
       .append("<br title='").append(percent)
       .append("'> <div class='").append(C_PROGRESSBAR).append("' title='")