YARN-8035. Uncaught exception in ContainersMonitorImpl during relaunch due to the process ID changing. Contributed by Shane Kumpf.

This commit is contained in:
Miklos Szegedi 2018-04-03 10:01:00 -07:00
parent 5a174f8ac6
commit 2d06d885c8
2 changed files with 18 additions and 1 deletions

View File

@ -274,7 +274,7 @@ public class ContainerMetrics implements MetricsSource {
} }
public void recordProcessId(String processId) { 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) { public void recordResourceLimit(int vmemLimit, int pmemLimit, int cpuVcores) {

View File

@ -206,4 +206,21 @@ public class TestContainerMetrics {
} }
Assert.assertEquals(expectedValues.keySet(), testResults); 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());
}
} }