YARN-5725. Test uncaught exception in TestContainersMonitorResourceChange.testContainersResourceChange
when setting IP and host (Contributed by Miklos Szegedi via Daniel Templeton)
This commit is contained in:
parent
a2b1ff0257
commit
62b42ef5dd
@ -536,15 +536,21 @@ private void initializeProcessTrees(
|
||||
}
|
||||
|
||||
Container container = context.getContainers().get(containerId);
|
||||
String[] ipAndHost = containerExecutor.getIpAndHost(container);
|
||||
if (ipAndHost != null && ipAndHost[0] != null
|
||||
&& ipAndHost[1] != null) {
|
||||
container.setIpAndHost(ipAndHost);
|
||||
LOG.info(containerId + "'s ip = " + ipAndHost[0]
|
||||
+ ", and hostname = " + ipAndHost[1]);
|
||||
|
||||
if (container != null) {
|
||||
String[] ipAndHost = containerExecutor.getIpAndHost(container);
|
||||
|
||||
if ((ipAndHost != null) && (ipAndHost[0] != null) &&
|
||||
(ipAndHost[1] != null)) {
|
||||
container.setIpAndHost(ipAndHost);
|
||||
LOG.info(containerId + "'s ip = " + ipAndHost[0]
|
||||
+ ", and hostname = " + ipAndHost[1]);
|
||||
} else {
|
||||
LOG.info("Can not get both ip and hostname: "
|
||||
+ Arrays.toString(ipAndHost));
|
||||
}
|
||||
} else {
|
||||
LOG.info("Can not get both ip and hostname: " + Arrays
|
||||
.toString(ipAndHost));
|
||||
LOG.info(containerId + " is missing. Not setting ip and hostname");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -683,11 +689,15 @@ private void reportResourceUsage(ContainerId containerId,
|
||||
long currentPmemUsage, float cpuUsagePercentPerCore) {
|
||||
ContainerImpl container =
|
||||
(ContainerImpl) context.getContainers().get(containerId);
|
||||
NMTimelinePublisher nmMetricsPublisher =
|
||||
container.getNMTimelinePublisher();
|
||||
if (nmMetricsPublisher != null) {
|
||||
nmMetricsPublisher.reportContainerResourceUsage(container,
|
||||
currentPmemUsage, cpuUsagePercentPerCore);
|
||||
if (container != null) {
|
||||
NMTimelinePublisher nmMetricsPublisher =
|
||||
container.getNMTimelinePublisher();
|
||||
if (nmMetricsPublisher != null) {
|
||||
nmMetricsPublisher.reportContainerResourceUsage(container,
|
||||
currentPmemUsage, cpuUsagePercentPerCore);
|
||||
}
|
||||
} else {
|
||||
LOG.info(containerId + " does not exist to report");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
@ -37,6 +38,7 @@
|
||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container;
|
||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEvent;
|
||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType;
|
||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerImpl;
|
||||
import org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor.ContainersMonitorImpl.ProcessTreeInfo;
|
||||
import org.apache.hadoop.yarn.server.nodemanager.executor.ContainerLivenessContext;
|
||||
import org.apache.hadoop.yarn.server.nodemanager.executor.ContainerSignalContext;
|
||||
@ -64,6 +66,7 @@ public class TestContainersMonitorResourceChange {
|
||||
private AsyncDispatcher dispatcher;
|
||||
private Context context;
|
||||
private MockContainerEventHandler containerEventHandler;
|
||||
private ConcurrentMap<ContainerId, Container> containerMap;
|
||||
|
||||
static final int WAIT_MS_PER_LOOP = 20; // 20 milli seconds
|
||||
|
||||
@ -131,8 +134,10 @@ public void setup() {
|
||||
executor = new MockExecutor();
|
||||
dispatcher = new AsyncDispatcher();
|
||||
context = Mockito.mock(Context.class);
|
||||
Mockito.doReturn(new ConcurrentSkipListMap<ContainerId, Container>())
|
||||
.when(context).getContainers();
|
||||
containerMap = new ConcurrentSkipListMap<>();
|
||||
Container container = Mockito.mock(ContainerImpl.class);
|
||||
containerMap.put(getContainerId(1), container);
|
||||
Mockito.doReturn(containerMap).when(context).getContainers();
|
||||
conf = new Configuration();
|
||||
conf.set(
|
||||
YarnConfiguration.NM_CONTAINER_MON_RESOURCE_CALCULATOR,
|
||||
@ -181,7 +186,12 @@ public void testContainersResourceChange() throws Exception {
|
||||
getContainerId(1)).getProcessTree();
|
||||
mockTree.setRssMemorySize(2500L);
|
||||
// verify that this container is killed
|
||||
Thread.sleep(200);
|
||||
for (int waitMs = 0; waitMs < 5000; waitMs += 50) {
|
||||
if (containerEventHandler.isContainerKilled(getContainerId(1))) {
|
||||
break;
|
||||
}
|
||||
Thread.sleep(50);
|
||||
}
|
||||
assertTrue(containerEventHandler
|
||||
.isContainerKilled(getContainerId(1)));
|
||||
// create container 2
|
||||
|
Loading…
Reference in New Issue
Block a user