|
18 | 18 |
|
19 | 19 | package org.apache.hadoop.yarn.server.resourcemanager; |
20 | 20 |
|
| 21 | +import static org.mockito.Matchers.any; |
| 22 | +import static org.mockito.Matchers.anyLong; |
21 | 23 | import static org.mockito.Matchers.isA; |
22 | 24 | import static org.mockito.Mockito.mock; |
23 | 25 | import static org.mockito.Mockito.spy; |
24 | 26 | import static org.mockito.Mockito.timeout; |
25 | | -import static org.mockito.Mockito.times; |
26 | 27 | import static org.mockito.Mockito.verify; |
27 | 28 | import static org.mockito.Mockito.when; |
28 | 29 |
|
29 | | -import com.google.common.base.Supplier; |
30 | 30 | import java.io.File; |
31 | 31 | import java.io.FileOutputStream; |
32 | 32 | import java.io.IOException; |
|
87 | 87 | import org.apache.hadoop.yarn.server.api.protocolrecords.NMContainerStatus; |
88 | 88 | import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; |
89 | 89 | import org.apache.hadoop.yarn.server.api.records.NodeAction; |
| 90 | +import org.apache.hadoop.yarn.server.resourcemanager.metrics.SystemMetricsPublisher; |
90 | 91 | import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager; |
91 | 92 | import org.apache.hadoop.yarn.server.resourcemanager.recovery.MemoryRMStateStore; |
92 | 93 | import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore; |
|
113 | 114 | import org.junit.Assert; |
114 | 115 | import org.junit.Before; |
115 | 116 | import org.junit.Test; |
| 117 | +import org.mockito.Mockito; |
116 | 118 |
|
| 119 | +import com.google.common.base.Supplier; |
117 | 120 | import com.google.common.collect.ImmutableMap; |
118 | 121 | import com.google.common.collect.Sets; |
119 | 122 |
|
@@ -896,7 +899,13 @@ public void testRMRestartGetApplicationList() throws Exception { |
896 | 899 | memStore.init(conf); |
897 | 900 |
|
898 | 901 | // start RM |
899 | | - MockRM rm1 = createMockRM(conf, memStore); |
| 902 | + MockRM rm1 = new MockRM(conf, memStore) { |
| 903 | + @Override |
| 904 | + protected SystemMetricsPublisher createSystemMetricsPublisher() { |
| 905 | + return spy(super.createSystemMetricsPublisher()); |
| 906 | + } |
| 907 | + }; |
| 908 | + rms.add(rm1); |
900 | 909 | rm1.start(); |
901 | 910 | MockNM nm1 = |
902 | 911 | new MockNM("127.0.0.1:1234", 15120, rm1.getResourceTrackerService()); |
@@ -925,17 +934,27 @@ public void testRMRestartGetApplicationList() throws Exception { |
925 | 934 | rm1.waitForState(app2.getApplicationId(), RMAppState.KILLED); |
926 | 935 | rm1.waitForState(am2.getApplicationAttemptId(), RMAppAttemptState.KILLED); |
927 | 936 |
|
| 937 | + verify(rm1.getRMContext().getSystemMetricsPublisher(),Mockito.times(3)) |
| 938 | + .appCreated(any(RMApp.class), anyLong()); |
928 | 939 | // restart rm |
929 | 940 |
|
930 | 941 | MockRM rm2 = new MockRM(conf, memStore) { |
931 | 942 | @Override |
932 | 943 | protected RMAppManager createRMAppManager() { |
933 | 944 | return spy(super.createRMAppManager()); |
934 | 945 | } |
| 946 | + |
| 947 | + @Override |
| 948 | + protected SystemMetricsPublisher createSystemMetricsPublisher() { |
| 949 | + return spy(super.createSystemMetricsPublisher()); |
| 950 | + } |
935 | 951 | }; |
936 | 952 | rms.add(rm2); |
937 | 953 | rm2.start(); |
938 | 954 |
|
| 955 | + verify(rm2.getRMContext().getSystemMetricsPublisher(),Mockito.times(3)) |
| 956 | + .appCreated(any(RMApp.class), anyLong()); |
| 957 | + |
939 | 958 | GetApplicationsRequest request1 = |
940 | 959 | GetApplicationsRequest.newInstance(EnumSet.of( |
941 | 960 | YarnApplicationState.FINISHED, YarnApplicationState.KILLED, |
|
0 commit comments