YARN-5805. Add isDebugEnabled check for debug logs in nodemanager (Bibin A Chundatt via Varun Saxena)

This commit is contained in:
Varun Saxena 2016-11-01 14:51:17 +05:30
parent 7ba74befcf
commit 310aa4686e
11 changed files with 75 additions and 46 deletions

View File

@ -556,9 +556,10 @@ public class DefaultContainerExecutor extends ContainerExecutor {
String user = ctx.getUser();
String pid = ctx.getPid();
Signal signal = ctx.getSignal();
LOG.debug("Sending signal " + signal.getValue() + " to pid " + pid
+ " as user " + user);
if (LOG.isDebugEnabled()) {
LOG.debug("Sending signal " + signal.getValue() + " to pid " + pid
+ " as user " + user);
}
if (!containerIsAlive(pid)) {
return false;
}

View File

@ -239,7 +239,9 @@ public class DeletionService extends AbstractService {
boolean error = false;
if (null == user) {
if (baseDirs == null || baseDirs.size() == 0) {
LOG.debug("NM deleting absolute path : " + subDir);
if (LOG.isDebugEnabled()) {
LOG.debug("NM deleting absolute path : " + subDir);
}
try {
lfs.delete(subDir, true);
} catch (IOException e) {
@ -249,7 +251,9 @@ public class DeletionService extends AbstractService {
} else {
for (Path baseDir : baseDirs) {
Path del = subDir == null? baseDir : new Path(baseDir, subDir);
LOG.debug("NM deleting path : " + del);
if (LOG.isDebugEnabled()) {
LOG.debug("NM deleting path : " + del);
}
try {
lfs.delete(del, true);
} catch (IOException e) {
@ -260,7 +264,10 @@ public class DeletionService extends AbstractService {
}
} else {
try {
LOG.debug("Deleting path: [" + subDir + "] as user: [" + user + "]");
if (LOG.isDebugEnabled()) {
LOG.debug(
"Deleting path: [" + subDir + "] as user: [" + user + "]");
}
if (baseDirs == null || baseDirs.size() == 0) {
delService.exec.deleteAsUser(new DeletionAsUserContext.Builder()
.setUser(user)

View File

@ -549,7 +549,9 @@ public class AMRMProxyService extends AbstractService implements
AMRMProxyService.this.stopApplication(event.getApplicationID());
break;
default:
LOG.debug("AMRMProxy is ignoring event: " + event.getType());
if (LOG.isDebugEnabled()) {
LOG.debug("AMRMProxy is ignoring event: " + event.getType());
}
break;
}
} else {

View File

@ -591,8 +591,10 @@ public class ApplicationImpl implements Application {
try {
ApplicationId applicationID = event.getApplicationID();
LOG.debug("Processing " + applicationID + " of type " + event.getType());
if (LOG.isDebugEnabled()) {
LOG.debug(
"Processing " + applicationID + " of type " + event.getType());
}
ApplicationState oldState = stateMachine.getCurrentState();
ApplicationState newState = null;
try {

View File

@ -1641,8 +1641,9 @@ public class ContainerImpl implements Container {
this.writeLock.lock();
ContainerId containerID = event.getContainerID();
LOG.debug("Processing " + containerID + " of type " + event.getType());
if (LOG.isDebugEnabled()) {
LOG.debug("Processing " + containerID + " of type " + event.getType());
}
ContainerState oldState = stateMachine.getCurrentState();
ContainerState newState = null;
try {

View File

@ -571,8 +571,9 @@ public class ContainerLaunch implements Callable<Integer> {
+ " No cleanup needed to be done");
return;
}
LOG.debug("Marking container " + containerIdStr + " as inactive");
if (LOG.isDebugEnabled()) {
LOG.debug("Marking container " + containerIdStr + " as inactive");
}
// this should ensure that if the container process has not launched
// by this time, it will never be launched
exec.deactivateContainer(containerId);
@ -596,10 +597,10 @@ public class ContainerLaunch implements Callable<Integer> {
// kill process
if (processId != null) {
String user = container.getUser();
LOG.debug("Sending signal to pid " + processId
+ " as user " + user
+ " for container " + containerIdStr);
if (LOG.isDebugEnabled()) {
LOG.debug("Sending signal to pid " + processId + " as user " + user
+ " for container " + containerIdStr);
}
final Signal signal = sleepDelayBeforeSigKill > 0
? Signal.TERM
: Signal.KILL;
@ -611,12 +612,11 @@ public class ContainerLaunch implements Callable<Integer> {
.setPid(processId)
.setSignal(signal)
.build());
LOG.debug("Sent signal " + signal + " to pid " + processId
+ " as user " + user
+ " for container " + containerIdStr
+ ", result=" + (result? "success" : "failed"));
if (LOG.isDebugEnabled()) {
LOG.debug("Sent signal " + signal + " to pid " + processId
+ " as user " + user + " for container " + containerIdStr
+ ", result=" + (result ? "success" : "failed"));
}
if (sleepDelayBeforeSigKill > 0) {
new DelayedProcessKiller(container, user,
processId, sleepDelayBeforeSigKill, Signal.KILL, exec).start();
@ -744,8 +744,10 @@ public class ContainerLaunch implements Callable<Integer> {
String containerIdStr =
container.getContainerId().toString();
String processId = null;
LOG.debug("Accessing pid for container " + containerIdStr
+ " from pid file " + pidFilePath);
if (LOG.isDebugEnabled()) {
LOG.debug("Accessing pid for container " + containerIdStr
+ " from pid file " + pidFilePath);
}
int sleepCounter = 0;
final int sleepInterval = 100;
@ -754,8 +756,10 @@ public class ContainerLaunch implements Callable<Integer> {
while (true) {
processId = ProcessIdFileReader.getProcessId(pidFilePath);
if (processId != null) {
LOG.debug("Got pid " + processId + " for container "
+ containerIdStr);
if (LOG.isDebugEnabled()) {
LOG.debug(
"Got pid " + processId + " for container " + containerIdStr);
}
break;
}
else if ((sleepCounter*sleepInterval) > maxKillWaitTime) {

View File

@ -190,8 +190,9 @@ public class LocalizedResource implements EventHandler<ResourceEvent> {
this.writeLock.lock();
Path resourcePath = event.getLocalResourceRequest().getPath();
LOG.debug("Processing " + resourcePath + " of type " + event.getType());
if (LOG.isDebugEnabled()) {
LOG.debug("Processing " + resourcePath + " of type " + event.getType());
}
ResourceState oldState = this.stateMachine.getCurrentState();
ResourceState newState = null;
try {

View File

@ -41,7 +41,9 @@ public class LocalizerTokenSelector implements
LOG.debug("Using localizerTokenSelector.");
for (Token<? extends TokenIdentifier> token : tokens) {
LOG.debug("Token of kind " + token.getKind() + " is found");
if (LOG.isDebugEnabled()) {
LOG.debug("Token of kind " + token.getKind() + " is found");
}
if (LocalizerTokenIdentifier.KIND.equals(token.getKind())) {
return (Token<LocalizerTokenIdentifier>) token;
}

View File

@ -446,9 +446,10 @@ public class ContainersMonitorImpl extends AbstractService implements
if (pId == null || !isResourceCalculatorAvailable()) {
continue; // processTree cannot be tracked
}
LOG.debug("Constructing ProcessTree for : PID = " + pId
+ " ContainerId = " + containerId);
if (LOG.isDebugEnabled()) {
LOG.debug("Constructing ProcessTree for : PID = " + pId
+ " ContainerId = " + containerId);
}
ResourceCalculatorProcessTree pTree = ptInfo.getProcessTree();
pTree.updateProcessTree(); // update process-tree
long currentVmemUsage = pTree.getVirtualMemorySize();
@ -527,9 +528,9 @@ public class ContainersMonitorImpl extends AbstractService implements
if (pId != null) {
// pId will be null, either if the container is not spawned yet
// or if the container's pid is removed from ContainerExecutor
LOG.debug("Tracking ProcessTree " + pId
+ " for the first time");
if (LOG.isDebugEnabled()) {
LOG.debug("Tracking ProcessTree " + pId + " for the first time");
}
ResourceCalculatorProcessTree pt =
ResourceCalculatorProcessTree.
getResourceCalculatorProcessTree(

View File

@ -191,8 +191,10 @@ public class NMTokenSecretManagerInNM extends BaseNMTokenSecretManager {
public synchronized void appFinished(ApplicationId appId) {
List<ApplicationAttemptId> appAttemptList = appToAppAttemptMap.get(appId);
if (appAttemptList != null) {
LOG.debug("Removing application attempts NMToken keys for application "
+ appId);
if (LOG.isDebugEnabled()) {
LOG.debug("Removing application attempts NMToken keys for application "
+ appId);
}
for (ApplicationAttemptId appAttemptId : appAttemptList) {
removeAppAttemptKey(appAttemptId);
}
@ -226,8 +228,10 @@ public class NMTokenSecretManagerInNM extends BaseNMTokenSecretManager {
if (oldKey == null
|| oldKey.getMasterKey().getKeyId() != identifier.getKeyId()) {
// Update key only if it is modified.
LOG.debug("NMToken key updated for application attempt : "
+ identifier.getApplicationAttemptId().toString());
if (LOG.isDebugEnabled()) {
LOG.debug("NMToken key updated for application attempt : "
+ identifier.getApplicationAttemptId().toString());
}
if (identifier.getKeyId() == currentMasterKey.getMasterKey()
.getKeyId()) {
updateAppAttemptKey(appAttemptId, currentMasterKey);
@ -243,7 +247,9 @@ public class NMTokenSecretManagerInNM extends BaseNMTokenSecretManager {
}
public synchronized void setNodeId(NodeId nodeId) {
LOG.debug("updating nodeId : " + nodeId);
if (LOG.isDebugEnabled()) {
LOG.debug("updating nodeId : " + nodeId);
}
this.nodeId = nodeId;
}

View File

@ -48,8 +48,9 @@ public class ProcessIdFileReader {
if (path == null) {
throw new IOException("Trying to access process id from a null path");
}
LOG.debug("Accessing pid from pid file " + path);
if (LOG.isDebugEnabled()) {
LOG.debug("Accessing pid from pid file " + path);
}
String processId = null;
BufferedReader bufReader = null;
@ -97,9 +98,10 @@ public class ProcessIdFileReader {
bufReader.close();
}
}
LOG.debug("Got pid "
+ (processId != null? processId : "null")
+ " from path " + path);
if (LOG.isDebugEnabled()) {
LOG.debug("Got pid " + (processId != null ? processId : "null")
+ " from path " + path);
}
return processId;
}