hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asur...@apache.org
Subject [35/50] [abbrv] hadoop git commit: YARN-6781. [YARN-3926] ResourceUtils#initializeResourcesMap takes an unnecessary Map parameter. Contributed by Yu-Tang Lin.
Date Tue, 12 Sep 2017 20:41:50 GMT
YARN-6781. [YARN-3926] ResourceUtils#initializeResourcesMap takes an unnecessary Map parameter.
Contributed by Yu-Tang Lin.


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

Branch: refs/heads/YARN-5972
Commit: 758b7719430c981a6d4d1644d9d03cd16b981cf3
Parents: df38555
Author: Sunil G <sunilg@apache.org>
Authored: Fri Aug 18 19:00:49 2017 +0530
Committer: Wangda Tan <wangda@apache.org>
Committed: Tue Sep 12 09:19:12 2017 -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/758b7719/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/758b7719/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