hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z..@apache.org
Subject [07/50] [abbrv] hadoop git commit: YARN-6781. [YARN-3926] ResourceUtils#initializeResourcesMap takes an unnecessary Map parameter. Contributed by Yu-Tang Lin.
Date Wed, 09 May 2018 17:30:26 GMT
YARN-6781. [YARN-3926] ResourceUtils#initializeResourcesMap takes an unnecessary Map parameter.
Contributed by Yu-Tang Lin.

(cherry picked from commit 758b7719430c981a6d4d1644d9d03cd16b981cf3)


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

Branch: refs/heads/yarn-8200
Commit: 80f85be81c32111b5d44eca42a1c8228f37b7e53
Parents: a321c28
Author: Sunil G <sunilg@apache.org>
Authored: Fri Aug 18 19:00:49 2017 +0530
Committer: Jonathan Hung <jhung@linkedin.com>
Committed: Wed May 9 10:05:48 2018 -0700

----------------------------------------------------------------------
 .../hadoop/yarn/util/resource/ResourceUtils.java      | 14 +++++++-------
 .../hadoop/yarn/util/resource/TestResourceUtils.java  |  8 ++++----
 2 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/80f85be8/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/util/resource/ResourceUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/util/resource/ResourceUtils.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/util/resource/ResourceUtils.java
index 5ed5712..997c2c0 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/util/resource/ResourceUtils.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/util/resource/ResourceUtils.java
@@ -201,9 +201,9 @@ public class ResourceUtils {
   }
 
   @VisibleForTesting
-  static void initializeResourcesMap(Configuration conf,
-      Map<String, ResourceInformation> resourceInformationMap) {
+  static void initializeResourcesMap(Configuration conf) {
 
+    Map<String, ResourceInformation> resourceInformationMap = new HashMap<>();
     String[] resourceNames = conf.getStrings(YarnConfiguration.RESOURCE_TYPES);
 
     if (resourceNames != null && resourceNames.length != 0) {
@@ -339,19 +339,18 @@ public class ResourceUtils {
     if (!initializedResources) {
       synchronized (ResourceUtils.class) {
         if (!initializedResources) {
-          Map<String, ResourceInformation> resources = new HashMap<>();
           if (conf == null) {
             conf = new YarnConfiguration();
           }
           try {
             addResourcesFileToConf(resourceFile, conf);
             LOG.debug("Found " + resourceFile + ", adding to configuration");
-            initializeResourcesMap(conf, resources);
+            initializeResourcesMap(conf);
             initializedResources = true;
           } catch (FileNotFoundException fe) {
             LOG.info("Unable to find '" + resourceFile
                 + "'. Falling back to memory and vcores as resources", fe);
-            initializeResourcesMap(conf, resources);
+            initializeResourcesMap(conf);
             initializedResources = true;
           }
         }
@@ -414,11 +413,12 @@ public class ResourceUtils {
   }
 
   @VisibleForTesting
-  public static void resetResourceTypes(Configuration conf) {
+  public static Map<String, ResourceInformation>
+      resetResourceTypes(Configuration conf) {
     synchronized (ResourceUtils.class) {
       initializedResources = false;
     }
-    getResourceTypes(conf);
+    return getResourceTypes(conf);
   }
 
   public static String getUnits(String resourceValue) {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/80f85be8/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/resource/TestResourceUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/resource/TestResourceUtils.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/resource/TestResourceUtils.java
index b530150..4e4671a 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/resource/TestResourceUtils.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/resource/TestResourceUtils.java
@@ -183,8 +183,9 @@ public class TestResourceUtils {
             YarnConfiguration.RESOURCE_TYPES + "." + resources[0] + ".units";
         conf.set(name, resources[1]);
       }
-      Map<String, ResourceInformation> ret = new HashMap<>();
-      ResourceUtils.initializeResourcesMap(conf, ret);
+      Map<String, ResourceInformation> ret =
+          ResourceUtils.resetResourceTypes(conf);
+
       // for test1, 4 - length will be 1, 4
       // for the others, len will be 3
       int len = 3;
@@ -248,9 +249,8 @@ public class TestResourceUtils {
             YarnConfiguration.RESOURCE_TYPES + "." + resources[0] + ".units";
         conf.set(name, resources[1]);
       }
-      Map<String, ResourceInformation> ret = new HashMap<>();
       try {
-        ResourceUtils.initializeResourcesMap(conf, ret);
+        ResourceUtils.initializeResourcesMap(conf);
         Assert.fail("resource map initialization should fail");
       } catch (Exception e) {
         // do nothing


---------------------------------------------------------------------
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