ソースを参照

HADOOP-19281. MetricsSystemImpl should not print INFO message in CLI (#7071)

Replaced all LOG.info with LOG.debug

Contributed by Sarveksha Yeshavantha Raju
Sarveksha Yeshavantha Raju 7 ヶ月 前
コミット
01401d71ef

+ 5 - 9
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsConfig.java

@@ -26,12 +26,12 @@ import static java.security.AccessController.*;
 
 import java.nio.charset.StandardCharsets;
 import java.security.PrivilegedAction;
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.hadoop.thirdparty.com.google.common.base.Joiner;
 import org.apache.hadoop.thirdparty.com.google.common.base.Splitter;
 import org.apache.hadoop.thirdparty.com.google.common.collect.Iterables;
 import org.apache.hadoop.thirdparty.com.google.common.collect.Maps;
@@ -106,8 +106,8 @@ class MetricsConfig extends SubsetConfiguration {
 
   /**
    * Load configuration from a list of files until the first successful load
-   * @param conf  the configuration object
-   * @param files the list of filenames to try
+   * @param prefix The prefix of the configuration.
+   * @param fileNames the list of filenames to try.
    * @return  the configuration object
    */
   static MetricsConfig loadFirst(String prefix, String... fileNames) {
@@ -119,10 +119,7 @@ class MetricsConfig extends SubsetConfiguration {
         fh.setFileName(fname);
         fh.load();
         Configuration cf = pcf.interpolatedConfiguration();
-        LOG.info("Loaded properties from {}", fname);
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("Properties: {}", toString(cf));
-        }
+        LOG.debug("Loaded properties from {}: {}", fname, cf);
         MetricsConfig mc = new MetricsConfig(cf, prefix);
         LOG.debug("Metrics Config: {}", mc);
         return mc;
@@ -135,8 +132,7 @@ class MetricsConfig extends SubsetConfiguration {
         throw new MetricsConfigException(e);
       }
     }
-    LOG.warn("Cannot locate configuration: tried " +
-             Joiner.on(",").join(fileNames));
+    LOG.debug("Cannot locate configuration: tried {}", Arrays.asList(fileNames));
     // default to an empty configuration
     return new MetricsConfig(new PropertiesConfiguration(), prefix);
   }

+ 9 - 10
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSystemImpl.java

@@ -155,7 +155,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
     ++refCount;
     if (monitoring) {
       // in mini cluster mode
-      LOG.info(this.prefix +" metrics system started (again)");
+      LOG.debug("{} metrics system started (again)", prefix);
       return this;
     }
     switch (initMode()) {
@@ -169,7 +169,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
         }
         break;
       case STANDBY:
-        LOG.info(prefix +" metrics system started in standby mode");
+        LOG.debug("{} metrics system started in standby mode", prefix);
     }
     initSystemMBean();
     return this;
@@ -188,7 +188,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
     configure(prefix);
     startTimer();
     monitoring = true;
-    LOG.info(prefix +" metrics system started");
+    LOG.debug("{} metrics system started", prefix);
     for (Callback cb : callbacks) cb.postStart();
     for (Callback cb : namedCallbacks.values()) cb.postStart();
   }
@@ -202,18 +202,18 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
     }
     if (!monitoring) {
       // in mini cluster mode
-      LOG.info(prefix +" metrics system stopped (again)");
+      LOG.debug("{} metrics system stopped (again)", prefix);
       return;
     }
     for (Callback cb : callbacks) cb.preStop();
     for (Callback cb : namedCallbacks.values()) cb.preStop();
-    LOG.info("Stopping "+ prefix +" metrics system...");
+    LOG.debug("Stopping {} metrics system...", prefix);
     stopTimer();
     stopSources();
     stopSinks();
     clearConfigs();
     monitoring = false;
-    LOG.info(prefix +" metrics system stopped.");
+    LOG.debug("{} metrics system stopped.", prefix);
     for (Callback cb : callbacks) cb.postStop();
     for (Callback cb : namedCallbacks.values()) cb.postStop();
   }
@@ -302,7 +302,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
     sinks.put(name, sa);
     allSinks.put(name, sink);
     sa.start();
-    LOG.info("Registered sink "+ name);
+    LOG.debug("Registered sink {}", name);
   }
 
   @Override
@@ -375,8 +375,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
             }
           }
         }, millis, millis);
-    LOG.info("Scheduled Metric snapshot period at " + (period / 1000)
-        + " second(s).");
+    LOG.debug("Scheduled Metric snapshot period at {} second(s).", period / 1000);
   }
 
   synchronized void onTimerEvent() {
@@ -609,7 +608,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
       MBeans.unregister(mbeanName);
       mbeanName = null;
     }
-    LOG.info(prefix +" metrics system shutdown complete.");
+    LOG.debug("{} metrics system shutdown complete.", prefix);
     return true;
   }