From 174f3a96b10a0ab0fd8aed1b0f904ca5f0c3f268 Mon Sep 17 00:00:00 2001 From: Jim Brennan Date: Tue, 23 Mar 2021 18:21:45 +0000 Subject: [PATCH] YARN-10697. Resources are displayed in bytes in UI for schedulers other than capacity. Contributed by Bilwa S T. --- .../apache/hadoop/yarn/api/records/Resource.java | 16 +++++++++++++++- .../webapp/MetricsOverviewTable.java | 12 ++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Resource.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Resource.java index 83e1c5fe09..b91658f759 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Resource.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Resource.java @@ -31,6 +31,7 @@ import org.apache.hadoop.classification.InterfaceStability.Evolving; import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.yarn.api.ApplicationMasterProtocol; import org.apache.hadoop.yarn.api.protocolrecords.ResourceTypes; import org.apache.hadoop.yarn.api.records.impl.LightWeightResource; @@ -465,9 +466,13 @@ public int compareTo(Resource other) { @Override public String toString() { + return getFormattedString(String.valueOf(getMemorySize())); + } + + private String getFormattedString(String memory) { StringBuilder sb = new StringBuilder(); - sb.append("