hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From inigo...@apache.org
Subject hadoop git commit: YARN-8843. updateNodeResource does not support units for memory. Contributed by Manikandan R.
Date Mon, 08 Oct 2018 17:05:25 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 7c13872cb -> 745f64012


YARN-8843. updateNodeResource does not support units for memory. Contributed by Manikandan
R.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/745f6401
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/745f6401
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/745f6401

Branch: refs/heads/trunk
Commit: 745f64012a2a912d5f0a36bbda89dc638e1715cb
Parents: 7c13872
Author: Inigo Goiri <inigoiri@apache.org>
Authored: Mon Oct 8 10:05:18 2018 -0700
Committer: Inigo Goiri <inigoiri@apache.org>
Committed: Mon Oct 8 10:05:18 2018 -0700

----------------------------------------------------------------------
 .../java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java  | 9 ++++++++-
 .../org/apache/hadoop/yarn/client/cli/TestRMAdminCLI.java   | 7 ++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/745f6401/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java
index a24c398..068eaa8 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java
@@ -77,6 +77,7 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.RemoveFromClusterNodeLa
 import org.apache.hadoop.yarn.server.api.protocolrecords.ReplaceLabelsOnNodeRequest;
 import org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceRequest;
 import org.apache.hadoop.yarn.util.ConverterUtils;
+import org.apache.hadoop.yarn.util.UnitsConversionUtil;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.Resources;
 
@@ -930,8 +931,14 @@ public class RMAdminCLI extends HAAdmin {
         if (resourceTypesFromRM.containsKey(resName)) {
           String[] resourceValue = ResourceUtils.parseResourceValue(resValue);
           if (resourceValue.length == 2) {
+            long value = Long.parseLong(resourceValue[1]);
+            if (!resourceTypesFromRM.get(resName).getUnits()
+                .equals(resourceValue[0])) {
+              value = UnitsConversionUtil.convert(resourceValue[0],
+                  resourceTypesFromRM.get(resName).getUnits(), value);
+            }
             ResourceInformation ri = ResourceInformation.newInstance(resName,
-                resourceValue[0], Long.parseLong(resourceValue[1]));
+                resourceValue[0], value);
             resource.setResourceInformation(resName, ri);
           } else {
             throw new IllegalArgumentException("Invalid resource value: " +

http://git-wip-us.apache.org/repos/asf/hadoop/blob/745f6401/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestRMAdminCLI.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestRMAdminCLI.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestRMAdminCLI.java
index 1f4b493..4d0aea2 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestRMAdminCLI.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestRMAdminCLI.java
@@ -325,7 +325,7 @@ public class TestRMAdminCLI {
   public void testUpdateNodeResourceTypes() throws Exception {
     String nodeIdStr = "0.0.0.0:0";
     String resourceTypes =
-        "memory-mb=1024Mi,vcores=1,resource1=3Gi,resource2=2m";
+        "memory-mb=1Gi,vcores=1,resource1=3Gi,resource2=2m";
     String[] args = {"-updateNodeResource", nodeIdStr, resourceTypes};
     assertEquals(0, rmAdminCLI.run(args));
     ArgumentCaptor<UpdateNodeResourceRequest> argument =
@@ -342,6 +342,11 @@ public class TestRMAdminCLI {
         ResourceInformation.newInstance("resource2", "m", 2));
 
     ResourceOption resource = resourceMap.get(nodeId);
+    // Ensure memory-mb has been converted to "Mi"
+    assertEquals(1024,
+        resource.getResource().getResourceInformation("memory-mb").getValue());
+    assertEquals("Mi",
+        resource.getResource().getResourceInformation("memory-mb").getUnits());
     assertNotNull("resource for " + nodeIdStr + " shouldn't be null.",
         resource);
     assertEquals("resource value for " + nodeIdStr + " is not as expected.",


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message