YARN-5607. Document TestContainerResourceUsage#waitForContainerCompletion. Contributed by Susheel Gupta
This commit is contained in:
parent
8eda456d37
commit
29f2230cb6
|
@ -1011,6 +1011,31 @@ public class MockRM extends ResourceManager {
|
|||
LOG.info("app is removed from scheduler, " + appId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait until a container has reached a completion state.
|
||||
* The timeout is 20 seconds.
|
||||
* @param nm A mock nodemanager
|
||||
* @param rm A mock resourcemanager
|
||||
* @param amContainerId The id of an am container
|
||||
* @param container A container
|
||||
* @throws Exception
|
||||
* if interrupted while waiting for the completion transition
|
||||
* or an unexpected error while MockNM is hearbeating.
|
||||
*/
|
||||
public static void waitForContainerCompletion(MockRM rm, MockNM nm,
|
||||
ContainerId amContainerId, RMContainer container) throws Exception {
|
||||
ContainerId containerId = container.getContainerId();
|
||||
if (null != rm.scheduler.getRMContainer(containerId)) {
|
||||
if (containerId.equals(amContainerId)) {
|
||||
rm.waitForState(nm, containerId, RMContainerState.COMPLETED);
|
||||
} else {
|
||||
rm.waitForState(nm, containerId, RMContainerState.KILLED);
|
||||
}
|
||||
} else {
|
||||
rm.drainEvents();
|
||||
}
|
||||
}
|
||||
|
||||
private void drainEventsImplicitly() {
|
||||
if (!disableDrainEventsImplicitly) {
|
||||
drainEvents();
|
||||
|
|
|
@ -348,7 +348,7 @@ public class TestContainerResourceUsage {
|
|||
// If keepRunningContainers is false, all live containers should now
|
||||
// be completed. Calculate the resource usage metrics for all of them.
|
||||
for (RMContainer c : rmContainers) {
|
||||
waitforContainerCompletion(rm, nm, amContainerId, c);
|
||||
MockRM.waitForContainerCompletion(rm, nm, amContainerId, c);
|
||||
AggregateAppResourceUsage ru = calculateContainerResourceMetrics(c);
|
||||
memorySeconds += ru.getMemorySeconds();
|
||||
vcoreSeconds += ru.getVcoreSeconds();
|
||||
|
@ -400,7 +400,7 @@ public class TestContainerResourceUsage {
|
|||
|
||||
// Calculate container usage metrics for second attempt.
|
||||
for (RMContainer c : rmContainers) {
|
||||
waitforContainerCompletion(rm, nm, amContainerId, c);
|
||||
MockRM.waitForContainerCompletion(rm, nm, amContainerId, c);
|
||||
AggregateAppResourceUsage ru = calculateContainerResourceMetrics(c);
|
||||
memorySeconds += ru.getMemorySeconds();
|
||||
vcoreSeconds += ru.getVcoreSeconds();
|
||||
|
@ -417,20 +417,6 @@ public class TestContainerResourceUsage {
|
|||
return;
|
||||
}
|
||||
|
||||
private void waitforContainerCompletion(MockRM rm, MockNM nm,
|
||||
ContainerId amContainerId, RMContainer container) throws Exception {
|
||||
ContainerId containerId = container.getContainerId();
|
||||
if (null != rm.scheduler.getRMContainer(containerId)) {
|
||||
if (containerId.equals(amContainerId)) {
|
||||
rm.waitForState(nm, containerId, RMContainerState.COMPLETED);
|
||||
} else {
|
||||
rm.waitForState(nm, containerId, RMContainerState.KILLED);
|
||||
}
|
||||
} else {
|
||||
rm.drainEvents();
|
||||
}
|
||||
}
|
||||
|
||||
private AggregateAppResourceUsage calculateContainerResourceMetrics(
|
||||
RMContainer rmContainer) {
|
||||
Resource resource = rmContainer.getContainer().getResource();
|
||||
|
|
Loading…
Reference in New Issue