YARN-7205. Log improvements for the ResourceUtils. (Sunil G via wangda)

Change-Id: I0f5b7a7f68ec5d3e1d52211f83fdd089bc0bfd37


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

Branch: refs/heads/YARN-1011
Commit: 8bcc49e6771ca75f012211e27870a421b19233e7
Parents: b6c2c90
Author: Wangda Tan <wan...@apache.org>
Authored: Wed Oct 11 15:25:28 2017 -0700
Committer: Wangda Tan <wan...@apache.org>
Committed: Wed Oct 11 15:25:28 2017 -0700

----------------------------------------------------------------------
 .../yarn/api/records/ResourceTypeInfo.java      |  7 +--
 .../yarn/util/resource/ResourceUtils.java       | 45 +++++++++++---------
 2 files changed, 30 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/8bcc49e6/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ResourceTypeInfo.java
----------------------------------------------------------------------
diff --git 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ResourceTypeInfo.java
 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ResourceTypeInfo.java
index b6f7f14..8775342 100644
--- 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ResourceTypeInfo.java
+++ 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ResourceTypeInfo.java
@@ -152,9 +152,10 @@ public abstract class ResourceTypeInfo implements 
Comparable<ResourceTypeInfo> {
   @Override
   public String toString() {
     StringBuilder sb = new StringBuilder();
-    sb.append("<name=").append(this.getName()).append(" default-unit=").append(
-        this.getDefaultUnit()).append(" type=" + getResourceType()).append(
-        ">");
+    sb.append(this.getName());
+    if (!this.getDefaultUnit().isEmpty()) {
+      sb.append(" (unit=").append(this.getDefaultUnit()).append(")");
+    }
     return sb.toString();
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/8bcc49e6/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 a1b5f6e..1779899 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
@@ -22,8 +22,6 @@ import com.google.common.annotations.VisibleForTesting;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.api.protocolrecords.ResourceTypes;
 import org.apache.hadoop.yarn.api.records.Resource;
@@ -118,19 +116,21 @@ public class ResourceUtils {
       Map<String, ResourceInformation> res) {
     ResourceInformation ri;
     if (!res.containsKey(MEMORY)) {
-      LOG.info("Adding resource type - name = " + MEMORY + ", units = "
-          + ResourceInformation.MEMORY_MB.getUnits() + ", type = "
-          + ResourceTypes.COUNTABLE);
-      ri = ResourceInformation
-          .newInstance(MEMORY,
-              ResourceInformation.MEMORY_MB.getUnits());
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Adding resource type - name = " + MEMORY + ", units = "
+            + ResourceInformation.MEMORY_MB.getUnits() + ", type = "
+            + ResourceTypes.COUNTABLE);
+      }
+      ri = ResourceInformation.newInstance(MEMORY,
+          ResourceInformation.MEMORY_MB.getUnits());
       res.put(MEMORY, ri);
     }
     if (!res.containsKey(VCORES)) {
-      LOG.info("Adding resource type - name = " + VCORES + ", units = , type = 
"
-          + ResourceTypes.COUNTABLE);
-      ri =
-          ResourceInformation.newInstance(VCORES);
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Adding resource type - name = " + VCORES
+            + ", units = , type = " + ResourceTypes.COUNTABLE);
+      }
+      ri = ResourceInformation.newInstance(VCORES);
       res.put(VCORES, ri);
     }
   }
@@ -343,11 +343,11 @@ public class ResourceUtils {
           }
           try {
             addResourcesFileToConf(resourceFile, conf);
-            LOG.debug("Found " + resourceFile + ", adding to configuration");
           } catch (FileNotFoundException fe) {
-            LOG.debug("Unable to find '" + resourceFile + "'.");
+            if (LOG.isDebugEnabled()) {
+              LOG.debug("Unable to find '" + resourceFile + "'.");
+            }
           }
-
           initializeResourcesMap(conf);
         }
       }
@@ -388,7 +388,9 @@ public class ResourceUtils {
       Configuration conf) throws FileNotFoundException {
     try {
       InputStream ris = getConfInputStream(resourceFile, conf);
-      LOG.debug("Found " + resourceFile + ", adding to configuration");
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Found " + resourceFile + ", adding to configuration");
+      }
       conf.addResource(ris);
     } catch (FileNotFoundException fe) {
       throw fe;
@@ -472,7 +474,10 @@ public class ResourceUtils {
         }
       }
     } catch (FileNotFoundException fe) {
-      LOG.info("Couldn't find node resources file");
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Couldn't find node resources file: "
+            + YarnConfiguration.NODE_RESOURCES_CONFIGURATION_FILE);
+      }
     }
     return nodeResources;
   }
@@ -492,8 +497,10 @@ public class ResourceUtils {
           Long.valueOf(value.substring(0, value.length() - units.length()));
       nodeResources.get(resourceType).setValue(resourceValue);
       nodeResources.get(resourceType).setUnits(units);
-      LOG.debug("Setting value for resource type " + resourceType + " to "
-              + resourceValue + " with units " + units);
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Setting value for resource type " + resourceType + " to "
+            + resourceValue + " with units " + units);
+      }
     }
   }
 


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

Reply via email to