|
30 | 30 |
|
31 | 31 | import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; |
32 | 32 | import org.apache.hadoop.yarn.api.records.ResourceRequest; |
| 33 | +import org.apache.hadoop.yarn.conf.YarnConfiguration; |
33 | 34 | import org.apache.hadoop.yarn.exceptions.YarnException; |
34 | 35 | import org.apache.hadoop.yarn.server.federation.policies.amrmproxy.FederationAMRMProxyPolicy; |
35 | 36 | import org.apache.hadoop.yarn.server.federation.policies.dao.WeightedPolicyInfo; |
36 | 37 | import org.apache.hadoop.yarn.server.federation.policies.exceptions.FederationPolicyException; |
37 | 38 | import org.apache.hadoop.yarn.server.federation.policies.exceptions.FederationPolicyInitializationException; |
38 | 39 | import org.apache.hadoop.yarn.server.federation.policies.router.FederationRouterPolicy; |
39 | | -import org.apache.hadoop.yarn.server.federation.store.records.SubClusterId; |
40 | | -import org.apache.hadoop.yarn.server.federation.store.records.SubClusterIdInfo; |
41 | | -import org.apache.hadoop.yarn.server.federation.store.records.SubClusterInfo; |
42 | | -import org.apache.hadoop.yarn.server.federation.store.records.SubClusterPolicyConfiguration; |
43 | | -import org.apache.hadoop.yarn.server.federation.store.records.SubClusterState; |
| 40 | +import org.apache.hadoop.yarn.server.federation.store.FederationStateStore; |
| 41 | +import org.apache.hadoop.yarn.server.federation.store.impl.MemoryFederationStateStore; |
| 42 | +import org.apache.hadoop.yarn.server.federation.store.records.*; |
44 | 43 | import org.apache.hadoop.yarn.server.federation.utils.FederationPoliciesTestUtil; |
| 44 | +import org.apache.hadoop.yarn.server.federation.utils.FederationStateStoreFacade; |
45 | 45 | import org.junit.Test; |
46 | 46 |
|
47 | 47 | /** |
@@ -184,4 +184,48 @@ public void setMockActiveSubclusters(int numSubclusters) { |
184 | 184 | } |
185 | 185 | } |
186 | 186 |
|
| 187 | + public String generateClusterMetricsInfo(int id) { |
| 188 | + |
| 189 | + long mem = 1024 * getRand().nextInt(277 * 100 - 1); |
| 190 | + // plant a best cluster |
| 191 | + if (id == 5) { |
| 192 | + mem = 1024 * 277 * 100; |
| 193 | + } |
| 194 | + String clusterMetrics = |
| 195 | + "{\"clusterMetrics\":{\"appsSubmitted\":65," + "\"appsCompleted\":64," |
| 196 | + + "\"appsPending\":0,\"appsRunning\":0,\"appsFailed\":0," |
| 197 | + + "\"appsKilled\":1,\"reservedMB\":0,\"availableMB\":" + mem + "," |
| 198 | + + "\"allocatedMB\":0,\"reservedVirtualCores\":0," |
| 199 | + + "\"availableVirtualCores\":2216,\"allocatedVirtualCores\":0," |
| 200 | + + "\"containersAllocated\":0,\"containersReserved\":0," |
| 201 | + + "\"containersPending\":0,\"totalMB\":28364800," |
| 202 | + + "\"totalVirtualCores\":2216,\"totalNodes\":278,\"lostNodes\":1," |
| 203 | + + "\"unhealthyNodes\":0,\"decommissionedNodes\":0," |
| 204 | + + "\"rebootedNodes\":0,\"activeNodes\":277}}\n"; |
| 205 | + |
| 206 | + return clusterMetrics; |
| 207 | + |
| 208 | + } |
| 209 | + |
| 210 | + public FederationStateStoreFacade getMemoryFacade() throws YarnException { |
| 211 | + |
| 212 | + // setting up a store and its facade (with caching off) |
| 213 | + FederationStateStoreFacade fedFacade = |
| 214 | + FederationStateStoreFacade.getInstance(); |
| 215 | + YarnConfiguration conf = new YarnConfiguration(); |
| 216 | + conf.set(YarnConfiguration.FEDERATION_CACHE_TIME_TO_LIVE_SECS, "0"); |
| 217 | + FederationStateStore store = new MemoryFederationStateStore(); |
| 218 | + store.init(conf); |
| 219 | + fedFacade.reinitialize(store, conf); |
| 220 | + |
| 221 | + for (SubClusterInfo sinfo : getActiveSubclusters().values()) { |
| 222 | + store.registerSubCluster(SubClusterRegisterRequest.newInstance(sinfo)); |
| 223 | + } |
| 224 | + |
| 225 | + return fedFacade; |
| 226 | + } |
| 227 | + |
| 228 | + public void setupContext() throws YarnException { |
| 229 | + |
| 230 | + } |
187 | 231 | } |
0 commit comments