HADOOP-11741. Add LOG.isDebugEnabled() guard for some LOG.debug(). Contributed by Walter Su.

This commit is contained in:
Tsuyoshi Ozawa 2015-03-25 16:36:10 +09:00
parent 80278a5f85
commit 5582b0f1d4
8 changed files with 90 additions and 41 deletions

View File

@ -459,6 +459,9 @@ Release 2.8.0 - UNRELEASED
HADOOP-11737. mockito's version in hadoop-nfs pom.xml shouldn't be HADOOP-11737. mockito's version in hadoop-nfs pom.xml shouldn't be
specified. (Kengo Seki via ozawa) specified. (Kengo Seki via ozawa)
HADOOP-11741. Add LOG.isDebugEnabled() guard for some LOG.debug().
(Walter Su via ozawa)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -2479,8 +2479,10 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
private Document parse(DocumentBuilder builder, URL url) private Document parse(DocumentBuilder builder, URL url)
throws IOException, SAXException { throws IOException, SAXException {
if (!quietmode) { if (!quietmode) {
if (LOG.isDebugEnabled()) {
LOG.debug("parsing URL " + url); LOG.debug("parsing URL " + url);
} }
}
if (url == null) { if (url == null) {
return null; return null;
} }

View File

@ -214,9 +214,11 @@ public class JavaKeyStoreProvider extends KeyProvider {
renameOrFail(path, new Path(path.toString() + "_CORRUPTED_" renameOrFail(path, new Path(path.toString() + "_CORRUPTED_"
+ System.currentTimeMillis())); + System.currentTimeMillis()));
renameOrFail(backupPath, path); renameOrFail(backupPath, path);
if (LOG.isDebugEnabled()) {
LOG.debug(String.format( LOG.debug(String.format(
"KeyStore loaded successfully from '%s' since '%s'" "KeyStore loaded successfully from '%s' since '%s'"
+ "was corrupted !!", backupPath, path)); + "was corrupted !!", backupPath, path));
}
} else { } else {
throw ioe; throw ioe;
} }
@ -265,8 +267,10 @@ public class JavaKeyStoreProvider extends KeyProvider {
try { try {
perm = loadFromPath(pathToLoad, password); perm = loadFromPath(pathToLoad, password);
renameOrFail(pathToLoad, path); renameOrFail(pathToLoad, path);
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("KeyStore loaded successfully from '%s'!!", LOG.debug(String.format("KeyStore loaded successfully from '%s'!!",
pathToLoad)); pathToLoad));
}
if (fs.exists(pathToDelete)) { if (fs.exists(pathToDelete)) {
fs.delete(pathToDelete, true); fs.delete(pathToDelete, true);
} }

View File

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

View File

@ -876,10 +876,13 @@ public class RPC {
getProtocolImplMap(rpcKind).put(new ProtoNameVer(protocolName, version), getProtocolImplMap(rpcKind).put(new ProtoNameVer(protocolName, version),
new ProtoClassProtoImpl(protocolClass, protocolImpl)); new ProtoClassProtoImpl(protocolClass, protocolImpl));
LOG.debug("RpcKind = " + rpcKind + " Protocol Name = " + protocolName + " version=" + version + if (LOG.isDebugEnabled()) {
LOG.debug("RpcKind = " + rpcKind + " Protocol Name = " + protocolName +
" version=" + version +
" ProtocolImpl=" + protocolImpl.getClass().getName() + " ProtocolImpl=" + protocolImpl.getClass().getName() +
" protocolClass=" + protocolClass.getName()); " protocolClass=" + protocolClass.getName());
} }
}
static class VerProtocolImpl { static class VerProtocolImpl {
final long version; final long version;

View File

@ -234,10 +234,12 @@ public abstract class Server {
throw new IllegalArgumentException("ReRegistration of rpcKind: " + throw new IllegalArgumentException("ReRegistration of rpcKind: " +
rpcKind); rpcKind);
} }
if (LOG.isDebugEnabled()) {
LOG.debug("rpcKind=" + rpcKind + LOG.debug("rpcKind=" + rpcKind +
", rpcRequestWrapperClass=" + rpcRequestWrapperClass + ", rpcRequestWrapperClass=" + rpcRequestWrapperClass +
", rpcInvoker=" + rpcInvoker); ", rpcInvoker=" + rpcInvoker);
} }
}
public Class<? extends Writable> getRpcRequestWrapper( public Class<? extends Writable> getRpcRequestWrapper(
RpcKindProto rpcKind) { RpcKindProto rpcKind) {

View File

@ -82,8 +82,10 @@ public class GangliaContext31 extends GangliaContext {
return; return;
} }
if (LOG.isDebugEnabled()) {
LOG.debug("Emitting metric " + name + ", type " + type + ", value " + LOG.debug("Emitting metric " + name + ", type " + type + ", value " +
value + " from hostname" + hostName); value + " from hostname" + hostName);
}
String units = getUnits(name); String units = getUnits(name);
int slope = getSlope(name); int slope = getSlope(name);

View File

@ -164,7 +164,9 @@ public class FileBasedKeyStoresFactory implements KeyStoresFactory {
// configuration property for key password. // configuration property for key password.
keystoreKeyPassword = getPassword( keystoreKeyPassword = getPassword(
conf, keyPasswordProperty, keystorePassword); conf, keyPasswordProperty, keystorePassword);
if (LOG.isDebugEnabled()) {
LOG.debug(mode.toString() + " KeyStore: " + keystoreLocation); LOG.debug(mode.toString() + " KeyStore: " + keystoreLocation);
}
InputStream is = new FileInputStream(keystoreLocation); InputStream is = new FileInputStream(keystoreLocation);
try { try {
@ -172,7 +174,9 @@ public class FileBasedKeyStoresFactory implements KeyStoresFactory {
} finally { } finally {
is.close(); is.close();
} }
if (LOG.isDebugEnabled()) {
LOG.debug(mode.toString() + " Loaded KeyStore: " + keystoreLocation); LOG.debug(mode.toString() + " Loaded KeyStore: " + keystoreLocation);
}
} else { } else {
keystore.load(null, null); keystore.load(null, null);
} }
@ -204,18 +208,24 @@ public class FileBasedKeyStoresFactory implements KeyStoresFactory {
resolvePropertyName(mode, SSL_TRUSTSTORE_RELOAD_INTERVAL_TPL_KEY), resolvePropertyName(mode, SSL_TRUSTSTORE_RELOAD_INTERVAL_TPL_KEY),
DEFAULT_SSL_TRUSTSTORE_RELOAD_INTERVAL); DEFAULT_SSL_TRUSTSTORE_RELOAD_INTERVAL);
if (LOG.isDebugEnabled()) {
LOG.debug(mode.toString() + " TrustStore: " + truststoreLocation); LOG.debug(mode.toString() + " TrustStore: " + truststoreLocation);
}
trustManager = new ReloadingX509TrustManager(truststoreType, trustManager = new ReloadingX509TrustManager(truststoreType,
truststoreLocation, truststoreLocation,
truststorePassword, truststorePassword,
truststoreReloadInterval); truststoreReloadInterval);
trustManager.init(); trustManager.init();
if (LOG.isDebugEnabled()) {
LOG.debug(mode.toString() + " Loaded TrustStore: " + truststoreLocation); LOG.debug(mode.toString() + " Loaded TrustStore: " + truststoreLocation);
}
trustManagers = new TrustManager[]{trustManager}; trustManagers = new TrustManager[]{trustManager};
} else { } else {
if (LOG.isDebugEnabled()) {
LOG.debug("The property '" + locationProperty + "' has not been set, " + LOG.debug("The property '" + locationProperty + "' has not been set, " +
"no TrustStore will be loaded"); "no TrustStore will be loaded");
}
trustManagers = null; trustManagers = null;
} }
} }