From 0c515b0ef09b21fcd3e800bf54c1a7920ebf23fc Mon Sep 17 00:00:00 2001 From: Szilard Nemeth Date: Mon, 10 Oct 2022 15:28:27 +0200 Subject: [PATCH] YARN-6766. Add helper method in FairSchedulerAppsBlock to print app info. Contributed by Riya Khandelwal --- .../webapp/FairSchedulerAppsBlock.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/FairSchedulerAppsBlock.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/FairSchedulerAppsBlock.java index f6202cbcc5..c74e2ae3e1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/FairSchedulerAppsBlock.java +++ b/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 @@ protected Boolean hasAccess(RMApp app, HttpServletRequest hsr) { 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> tbody = html. @@ -193,16 +199,16 @@ protected Boolean hasAccess(RMApp app, HttpServletRequest hsr) { .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("