hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjs...@apache.org
Subject [22/50] [abbrv] hadoop git commit: HADOOP-11741. Add LOG.isDebugEnabled() guard for some LOG.debug(). Contributed by Walter Su.
Date Fri, 27 Mar 2015 06:34:24 GMT
HADOOP-11741. Add LOG.isDebugEnabled() guard for some LOG.debug(). Contributed by Walter Su.


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

Branch: refs/heads/YARN-2928
Commit: 86682fb89f15ed7006aca9585589fbf266a3e399
Parents: e6bcb7e
Author: Tsuyoshi Ozawa <ozawa@apache.org>
Authored: Wed Mar 25 16:36:10 2015 +0900
Committer: Zhijie Shen <zjshen@apache.org>
Committed: Thu Mar 26 23:29:46 2015 -0700

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt |  3 +
 .../org/apache/hadoop/conf/Configuration.java   |  4 +-
 .../hadoop/crypto/key/JavaKeyStoreProvider.java | 14 +++--
 .../apache/hadoop/ha/ActiveStandbyElector.java  | 65 +++++++++++++-------
 .../main/java/org/apache/hadoop/ipc/RPC.java    |  9 ++-
 .../main/java/org/apache/hadoop/ipc/Server.java |  8 ++-
 .../metrics/ganglia/GangliaContext31.java       |  6 +-
 .../security/ssl/FileBasedKeyStoresFactory.java | 22 +++++--
 8 files changed, 90 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/86682fb8/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index cdb88d2..e3cadf5 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -459,6 +459,9 @@ Release 2.8.0 - UNRELEASED
     HADOOP-11737. mockito's version in hadoop-nfs’ pom.xml shouldn't be
     specified. (Kengo Seki via ozawa)
 
+    HADOOP-11741. Add LOG.isDebugEnabled() guard for some LOG.debug().
+    (Walter Su via ozawa)
+
   OPTIMIZATIONS
 
   BUG FIXES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/86682fb8/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
index 753f515..8a312ff 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
@@ -2479,7 +2479,9 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
   private Document parse(DocumentBuilder builder, URL url)
       throws IOException, SAXException {
     if (!quietmode) {
-      LOG.debug("parsing URL " + url);
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("parsing URL " + url);
+      }
     }
     if (url == null) {
       return null;

http://git-wip-us.apache.org/repos/asf/hadoop/blob/86682fb8/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/JavaKeyStoreProvider.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/JavaKeyStoreProvider.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/JavaKeyStoreProvider.java
index c0d510d..091cab5 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/JavaKeyStoreProvider.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/JavaKeyStoreProvider.java
@@ -214,9 +214,11 @@ public class JavaKeyStoreProvider extends KeyProvider {
         renameOrFail(path, new Path(path.toString() + "_CORRUPTED_"
             + System.currentTimeMillis()));
         renameOrFail(backupPath, path);
-        LOG.debug(String.format(
-            "KeyStore loaded successfully from '%s' since '%s'"
-                + "was corrupted !!", backupPath, path));
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(String.format(
+              "KeyStore loaded successfully from '%s' since '%s'"
+                  + "was corrupted !!", backupPath, path));
+        }
       } else {
         throw ioe;
       }
@@ -265,8 +267,10 @@ public class JavaKeyStoreProvider extends KeyProvider {
     try {
       perm = loadFromPath(pathToLoad, password);
       renameOrFail(pathToLoad, path);
-      LOG.debug(String.format("KeyStore loaded successfully from '%s'!!",
-          pathToLoad));
+      if (LOG.isDebugEnabled()) {
+        LOG.debug(String.format("KeyStore loaded successfully from '%s'!!",
+            pathToLoad));
+      }
       if (fs.exists(pathToDelete)) {
         fs.delete(pathToDelete, true);
       }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/86682fb8/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java
index 947baa9..e520a16 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java
@@ -256,7 +256,9 @@ public class ActiveStandbyElector implements StatCallback, StringCallback
{
     appData = new byte[data.length];
     System.arraycopy(data, 0, appData, 0, data.length);
 
-    LOG.debug("Attempting active election for " + this);
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("Attempting active election for " + this);
+    }
     joinElectionInternal();
   }
   
@@ -406,9 +408,11 @@ public class ActiveStandbyElector implements StatCallback, StringCallback
{
   public synchronized void processResult(int rc, String path, Object ctx,
       String name) {
     if (isStaleClient(ctx)) return;
-    LOG.debug("CreateNode result: " + rc + " for path: " + path
-        + " connectionState: " + zkConnectionState +
-        "  for " + this);
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("CreateNode result: " + rc + " for path: " + path
+          + " connectionState: " + zkConnectionState +
+          "  for " + this);
+    }
 
     Code code = Code.get(rc);
     if (isSuccess(code)) {
@@ -467,10 +471,11 @@ public class ActiveStandbyElector implements StatCallback, StringCallback
{
     
     assert wantToBeInElection :
         "Got a StatNode result after quitting election";
-    
-    LOG.debug("StatNode result: " + rc + " for path: " + path
-        + " connectionState: " + zkConnectionState + " for " + this);
-        
+
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("StatNode result: " + rc + " for path: " + path
+          + " connectionState: " + zkConnectionState + " for " + this);
+    }
 
     Code code = Code.get(rc);
     if (isSuccess(code)) {
@@ -535,10 +540,12 @@ public class ActiveStandbyElector implements StatCallback, StringCallback
{
   synchronized void processWatchEvent(ZooKeeper zk, WatchedEvent event) {
     Event.EventType eventType = event.getType();
     if (isStaleClient(zk)) return;
-    LOG.debug("Watcher event type: " + eventType + " with state:"
-        + event.getState() + " for path:" + event.getPath()
-        + " connectionState: " + zkConnectionState
-        + " for " + this);
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("Watcher event type: " + eventType + " with state:"
+          + event.getState() + " for path:" + event.getPath()
+          + " connectionState: " + zkConnectionState
+          + " for " + this);
+    }
 
     if (eventType == Event.EventType.None) {
       // the connection state has changed
@@ -597,7 +604,9 @@ public class ActiveStandbyElector implements StatCallback, StringCallback
{
         monitorActiveStatus();
         break;
       default:
-        LOG.debug("Unexpected node event: " + eventType + " for path: " + path);
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Unexpected node event: " + eventType + " for path: " + path);
+        }
         monitorActiveStatus();
       }
 
@@ -646,7 +655,9 @@ public class ActiveStandbyElector implements StatCallback, StringCallback
{
 
   private void monitorActiveStatus() {
     assert wantToBeInElection;
-    LOG.debug("Monitoring active leader for " + this);
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("Monitoring active leader for " + this);
+    }
     statRetryCount = 0;
     monitorLockNodeAsync();
   }
@@ -737,7 +748,9 @@ public class ActiveStandbyElector implements StatCallback, StringCallback
{
     int connectionRetryCount = 0;
     boolean success = false;
     while(!success && connectionRetryCount < maxRetryNum) {
-      LOG.debug("Establishing zookeeper connection for " + this);
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Establishing zookeeper connection for " + this);
+      }
       try {
         createConnection();
         success = true;
@@ -765,7 +778,9 @@ public class ActiveStandbyElector implements StatCallback, StringCallback
{
       watcher = null;
     }
     zkClient = getNewZooKeeper();
-    LOG.debug("Created new connection for " + this);
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("Created new connection for " + this);
+    }
   }
 
   @InterfaceAudience.Private
@@ -773,7 +788,9 @@ public class ActiveStandbyElector implements StatCallback, StringCallback
{
     if (zkClient == null) {
       return;
     }
-    LOG.debug("Terminating ZK connection for " + this);
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("Terminating ZK connection for " + this);
+    }
     ZooKeeper tempZk = zkClient;
     zkClient = null;
     watcher = null;
@@ -800,8 +817,10 @@ public class ActiveStandbyElector implements StatCallback, StringCallback
{
     try {
       Stat oldBreadcrumbStat = fenceOldActive();
       writeBreadCrumbNode(oldBreadcrumbStat);
-      
-      LOG.debug("Becoming active for " + this);
+
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Becoming active for " + this);
+      }
       appClient.becomeActive();
       state = State.ACTIVE;
       return true;
@@ -906,7 +925,9 @@ public class ActiveStandbyElector implements StatCallback, StringCallback
{
 
   private void becomeStandby() {
     if (state != State.STANDBY) {
-      LOG.debug("Becoming standby for " + this);
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Becoming standby for " + this);
+      }
       state = State.STANDBY;
       appClient.becomeStandby();
     }
@@ -914,7 +935,9 @@ public class ActiveStandbyElector implements StatCallback, StringCallback
{
 
   private void enterNeutralMode() {
     if (state != State.NEUTRAL) {
-      LOG.debug("Entering neutral mode for " + this);
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Entering neutral mode for " + this);
+      }
       state = State.NEUTRAL;
       appClient.enterNeutralMode();
     }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/86682fb8/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RPC.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RPC.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RPC.java
index 8ada0ff..4766175 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RPC.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RPC.java
@@ -876,9 +876,12 @@ public class RPC {
 
      getProtocolImplMap(rpcKind).put(new ProtoNameVer(protocolName, version),
          new ProtoClassProtoImpl(protocolClass, protocolImpl)); 
-     LOG.debug("RpcKind = " + rpcKind + " Protocol Name = " + protocolName +  " version="
+ version +
-         " ProtocolImpl=" + protocolImpl.getClass().getName() + 
-         " protocolClass=" + protocolClass.getName());
+     if (LOG.isDebugEnabled()) {
+       LOG.debug("RpcKind = " + rpcKind + " Protocol Name = " + protocolName +
+           " version=" + version +
+           " ProtocolImpl=" + protocolImpl.getClass().getName() +
+           " protocolClass=" + protocolClass.getName());
+     }
    }
    
    static class VerProtocolImpl {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/86682fb8/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
index d2d61b3..9aa362e 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
@@ -234,9 +234,11 @@ public abstract class Server {
       throw new IllegalArgumentException("ReRegistration of rpcKind: " +
           rpcKind);      
     }
-    LOG.debug("rpcKind=" + rpcKind + 
-        ", rpcRequestWrapperClass=" + rpcRequestWrapperClass + 
-        ", rpcInvoker=" + rpcInvoker);
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("rpcKind=" + rpcKind +
+          ", rpcRequestWrapperClass=" + rpcRequestWrapperClass +
+          ", rpcInvoker=" + rpcInvoker);
+    }
   }
   
   public Class<? extends Writable> getRpcRequestWrapper(

http://git-wip-us.apache.org/repos/asf/hadoop/blob/86682fb8/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/ganglia/GangliaContext31.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/ganglia/GangliaContext31.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/ganglia/GangliaContext31.java
index f35ad18..9ad2d39 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/ganglia/GangliaContext31.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/ganglia/GangliaContext31.java
@@ -82,8 +82,10 @@ public class GangliaContext31 extends GangliaContext {
       return;
     }
 
-    LOG.debug("Emitting metric " + name + ", type " + type + ", value " + 
-      value + " from hostname" + hostName);
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("Emitting metric " + name + ", type " + type + ", value " +
+          value + " from hostname" + hostName);
+    }
 
     String units = getUnits(name);
     int slope = getSlope(name);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/86682fb8/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/FileBasedKeyStoresFactory.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/FileBasedKeyStoresFactory.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/FileBasedKeyStoresFactory.java
index 609c71f..41634a8 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/FileBasedKeyStoresFactory.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/FileBasedKeyStoresFactory.java
@@ -164,7 +164,9 @@ public class FileBasedKeyStoresFactory implements KeyStoresFactory {
       // configuration property for key password.
       keystoreKeyPassword = getPassword(
           conf, keyPasswordProperty, keystorePassword);
-      LOG.debug(mode.toString() + " KeyStore: " + keystoreLocation);
+      if (LOG.isDebugEnabled()) {
+        LOG.debug(mode.toString() + " KeyStore: " + keystoreLocation);
+      }
 
       InputStream is = new FileInputStream(keystoreLocation);
       try {
@@ -172,7 +174,9 @@ public class FileBasedKeyStoresFactory implements KeyStoresFactory {
       } finally {
         is.close();
       }
-      LOG.debug(mode.toString() + " Loaded KeyStore: " + keystoreLocation);
+      if (LOG.isDebugEnabled()) {
+        LOG.debug(mode.toString() + " Loaded KeyStore: " + keystoreLocation);
+      }
     } else {
       keystore.load(null, null);
     }
@@ -204,18 +208,24 @@ public class FileBasedKeyStoresFactory implements KeyStoresFactory {
               resolvePropertyName(mode, SSL_TRUSTSTORE_RELOAD_INTERVAL_TPL_KEY),
               DEFAULT_SSL_TRUSTSTORE_RELOAD_INTERVAL);
 
-      LOG.debug(mode.toString() + " TrustStore: " + truststoreLocation);
+      if (LOG.isDebugEnabled()) {
+        LOG.debug(mode.toString() + " TrustStore: " + truststoreLocation);
+      }
 
       trustManager = new ReloadingX509TrustManager(truststoreType,
           truststoreLocation,
           truststorePassword,
           truststoreReloadInterval);
       trustManager.init();
-      LOG.debug(mode.toString() + " Loaded TrustStore: " + truststoreLocation);
+      if (LOG.isDebugEnabled()) {
+        LOG.debug(mode.toString() + " Loaded TrustStore: " + truststoreLocation);
+      }
       trustManagers = new TrustManager[]{trustManager};
     } else {
-      LOG.debug("The property '" + locationProperty + "' has not been set, " +
-          "no TrustStore will be loaded");
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("The property '" + locationProperty + "' has not been set, " +
+            "no TrustStore will be loaded");
+      }
       trustManagers = null;
     }
   }


Mime
View raw message