YARN-9177. Use resource map for app metrics in TestCombinedSystemMetricsPublisher for branch-2

This commit is contained in:
Jonathan Hung 2019-01-08 15:36:11 -05:00
parent 7f614f7cee
commit 08923e324a
1 changed files with 12 additions and 2 deletions

View File

@ -30,7 +30,9 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
@ -46,6 +48,7 @@ import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.Priority; import org.apache.hadoop.yarn.api.records.Priority;
import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.api.records.ResourceInformation;
import org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState; import org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState;
import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity; import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity;
import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntityType; import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntityType;
@ -481,9 +484,16 @@ public class TestCombinedSystemMetricsPublisher {
when(rmApp.getCurrentAppAttempt()).thenReturn(appAttempt); when(rmApp.getCurrentAppAttempt()).thenReturn(appAttempt);
when(rmApp.getFinalApplicationStatus()).thenReturn( when(rmApp.getFinalApplicationStatus()).thenReturn(
FinalApplicationStatus.UNDEFINED); FinalApplicationStatus.UNDEFINED);
Map<String, Long> resourceMap = new HashMap<>();
resourceMap
.put(ResourceInformation.MEMORY_MB.getName(), (long) Integer.MAX_VALUE);
resourceMap.put(ResourceInformation.VCORES.getName(), Long.MAX_VALUE);
Map<String, Long> preemptedMap = new HashMap<>();
preemptedMap
.put(ResourceInformation.MEMORY_MB.getName(), (long) Integer.MAX_VALUE);
when(rmApp.getRMAppMetrics()).thenReturn( when(rmApp.getRMAppMetrics()).thenReturn(
new RMAppMetrics(Resource.newInstance(0, 0), 0, 0, Integer.MAX_VALUE, new RMAppMetrics(Resource.newInstance(0, 0), 0, 0, resourceMap,
Long.MAX_VALUE, Integer.MAX_VALUE, Long.MAX_VALUE)); preemptedMap));
when(rmApp.getApplicationTags()).thenReturn( when(rmApp.getApplicationTags()).thenReturn(
Collections.<String> emptySet()); Collections.<String> emptySet());
ApplicationSubmissionContext appSubmissionContext = ApplicationSubmissionContext appSubmissionContext =