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/monitor/ContainerMetrics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainerMetrics.java index a6aa337239..2a958494e8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainerMetrics.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainerMetrics.java @@ -274,7 +274,7 @@ public void recordCpuUsage( } public void recordProcessId(String processId) { - registry.tag(PROCESSID_INFO, processId); + registry.tag(PROCESSID_INFO, processId, true); } public void recordResourceLimit(int vmemLimit, int pmemLimit, int cpuVcores) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainerMetrics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainerMetrics.java index 1840d62f12..8b2bff1c28 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainerMetrics.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainerMetrics.java @@ -206,4 +206,21 @@ public void testContainerMetricsHistogram() throws Exception { } Assert.assertEquals(expectedValues.keySet(), testResults); } + + @Test + public void testContainerMetricsUpdateContainerPid() { + ContainerId containerId = mock(ContainerId.class); + ContainerMetrics metrics = ContainerMetrics.forContainer(containerId, + 100, 1); + + String origPid = "1234"; + metrics.recordProcessId(origPid); + assertEquals(origPid, metrics.registry.getTag( + ContainerMetrics.PROCESSID_INFO.name()).value()); + + String newPid = "4321"; + metrics.recordProcessId(newPid); + assertEquals(newPid, metrics.registry.getTag( + ContainerMetrics.PROCESSID_INFO.name()).value()); + } }