Revert "YARN-10947. Simplify AbstractCSQueue#initializeQueueState. Contributed by Andras Gyori"

This reverts commit de526e166c.

With this commit, the patch of
https://issues.apache.org/jira/browse/YARN-10850 has been committed.
This commit is contained in:
Szilard Nemeth 2022-03-03 16:38:56 +01:00
parent 22fe79cee3
commit 1c27c69f44
2 changed files with 3 additions and 71 deletions

View File

@ -137,7 +137,9 @@ public List<ContainerReport> getContainers(ApplicationAttemptId
ApplicationId appId = applicationAttemptId.getApplicationId(); ApplicationId appId = applicationAttemptId.getApplicationId();
ApplicationReport appReport = getApplicationReport(appId); ApplicationReport appReport = getApplicationReport(appId);
Map<String, String> filters = new HashMap<>(); Map<String, String> filters = new HashMap<>();
filters.put("appattemptId", applicationAttemptId.toString()); filters.put("infofilters", "SYSTEM_INFO_PARENT_ENTITY eq {\"id\":\"" +
applicationAttemptId.toString() +
"\",\"type\":\"YARN_APPLICATION_ATTEMPT\"}");
List<TimelineEntity> entities = readerClient.getContainerEntities( List<TimelineEntity> entities = readerClient.getContainerEntities(
appId, "ALL", filters, 0, null); appId, "ALL", filters, 0, null);
List<ContainerReport> containers = List<ContainerReport> containers =

View File

@ -22,7 +22,6 @@
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport; import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport;
@ -46,11 +45,8 @@
import org.junit.Test; import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -111,72 +107,6 @@ public void testGetAppAttemptReport() throws IOException, YarnException {
isEqualTo("test original tracking url"); isEqualTo("test original tracking url");
} }
@Test
public void testGetContainerByAppAttempt() throws IOException, YarnException {
int applicationId = 1;
ApplicationId appId = ApplicationId.newInstance(0, applicationId);
ApplicationAttemptId appAttemptId =
ApplicationAttemptId.newInstance(appId, 1);
ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
when(spyTimelineReaderClient.getContainerEntities(
appId, "ALL",
ImmutableMap.of("appattemptId", appAttemptId.toString()),
0, null))
.thenReturn(Arrays.asList(createContainerEntity(containerId)));
when(spyTimelineReaderClient.getApplicationEntity(appId, "ALL", null))
.thenReturn(createApplicationTimelineEntity(appId, true,
false));
List<ContainerReport> containerList = client.getContainers(appAttemptId);
assertThat(containerList.size()).isEqualTo(1);
assertThat(containerList.get(0).getContainerId().getApplicationAttemptId()
.getApplicationId().getId()).isEqualTo(applicationId);
}
@Test
public void testGetMultipleContainersByAppAttempt() throws IOException, YarnException {
int numContainers = 4;
int applicationId = 3;
int applicationAttemptId = 3;
ApplicationId appMultiple = ApplicationId.newInstance(0, applicationId);
ApplicationAttemptId appAttemptIdMultiple =
ApplicationAttemptId.newInstance(appMultiple, applicationAttemptId);
List<TimelineEntity> containerEntities = new ArrayList<>();
for (int containerId = 0; containerId < numContainers; ++containerId) {
containerEntities.add(createContainerEntity(ContainerId.newContainerId(
appAttemptIdMultiple, containerId)));
}
when(spyTimelineReaderClient.getContainerEntities(
appMultiple, "ALL",
ImmutableMap.of("appattemptId", appAttemptIdMultiple.toString()),
0, null))
.thenReturn(containerEntities);
when(spyTimelineReaderClient.getApplicationEntity(appMultiple, "ALL", null))
.thenReturn(createApplicationTimelineEntity(appMultiple, true,
false));
List<ContainerReport> containerListMultiple = client.getContainers(appAttemptIdMultiple);
assertThat(containerListMultiple.size()).isEqualTo(numContainers);
for (int containerIdx = 0; containerIdx < containerListMultiple.size(); ++containerIdx) {
ContainerReport report = containerListMultiple.get(containerIdx);
assertThat(report.getContainerId().getContainerId()).isEqualTo(containerIdx);
assertThat(report.getContainerId().getApplicationAttemptId().getAttemptId())
.isEqualTo(applicationAttemptId);
assertThat(report.getContainerId().getApplicationAttemptId().getApplicationId().getId())
.isEqualTo(applicationId);
}
}
@Test @Test
public void testGetAppReport() throws IOException, YarnException { public void testGetAppReport() throws IOException, YarnException {
final ApplicationId appId = ApplicationId.newInstance(0, 1); final ApplicationId appId = ApplicationId.newInstance(0, 1);