From 144a55f0e3ba302327baf2e98d1e07b953dcbbfd Mon Sep 17 00:00:00 2001 From: Shane Kumpf Date: Fri, 14 Sep 2018 10:41:55 -0600 Subject: [PATCH] YARN-8045. Reduce log output from container status calls. Contributed by Craig Condit --- .../ContainerManagerImpl.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java index b89e2ddd06..27a7c80515 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java @@ -1474,10 +1474,37 @@ protected ContainerStatus getContainerStatusInternal(ContainerId containerID, } } ContainerStatus containerStatus = container.cloneAndGetContainerStatus(); - LOG.info("Returning " + containerStatus); + logContainerStatus("Returning ", containerStatus); return containerStatus; } + private void logContainerStatus(String prefix, ContainerStatus status) { + StringBuilder sb = new StringBuilder(); + sb.append(prefix); + sb.append("ContainerStatus: ["); + sb.append("ContainerId: "); + sb.append(status.getContainerId()).append(", "); + sb.append("ExecutionType: "); + sb.append(status.getExecutionType()).append(", "); + sb.append("State: "); + sb.append(status.getState()).append(", "); + sb.append("Capability: "); + sb.append(status.getCapability()).append(", "); + sb.append("Diagnostics: "); + sb.append(LOG.isDebugEnabled() ? status.getDiagnostics() : "..."); + sb.append(", "); + sb.append("ExitStatus: "); + sb.append(status.getExitStatus()).append(", "); + sb.append("IP: "); + sb.append(status.getIPs()).append(", "); + sb.append("Host: "); + sb.append(status.getHost()).append(", "); + sb.append("ContainerSubState: "); + sb.append(status.getContainerSubState()); + sb.append("]"); + LOG.info(sb.toString()); + } + @Private @VisibleForTesting protected void authorizeGetAndStopContainerRequest(ContainerId containerId,