federationAM.put(a.getAppId(), a); if (federationUAMSum.containsKey(a.getAppId())) { mergeAMWithUAM(a, federationUAMSum.get(a.getAppId())); federationUAMSum.remove(a.getAppId()); if (federationAM.containsKey(a.getAppId())) { mergeAMWithUAM(federationAM.get(a.getAppId()), a); } else if (federationUAMSum.containsKey(a.getAppId())) { federationUAMSum.put(a.getAppId(), mergeUAMWithUAM(federationUAMSum.get(a.getAppId()), a)); } else { federationUAMSum.put(a.getAppId(), a); && !(a.getName().startsWith(UnmanagedApplicationManager.APP_NAME) || a.getName().startsWith(PARTIAL_REPORT)))) { federationAM.put(a.getAppId(), a);
private static AppInfo mergeUAMWithUAM(AppInfo uam1, AppInfo uam2) { AppInfo partialReport = new AppInfo(); partialReport.setAppId(uam1.getAppId()); partialReport.setName(PARTIAL_REPORT + uam1.getAppId()); // We pick the status of the first uam partialReport.setState(uam1.getState()); // Merge the newly partial AM with UAM1 and then with UAM2 mergeAMWithUAM(partialReport, uam1); mergeAMWithUAM(partialReport, uam2); return partialReport; }
@Test public void testUnmarshalAppInfo() throws JSONException, Exception { rm.start(); MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048); RMApp app1 = rm.submitApp(CONTAINER_MB, "testwordcount", "user1"); amNodeManager.nodeHeartbeat(true); WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("apps").path(app1.getApplicationId().toString()) .accept(MediaType.APPLICATION_XML).get(ClientResponse.class); AppInfo appInfo = response.getEntity(AppInfo.class); // Check only a few values; all are validated in testSingleApp. assertEquals(app1.getApplicationId().toString(), appInfo.getAppId()); assertEquals(app1.getName(), appInfo.getName()); assertEquals(app1.createApplicationState(), appInfo.getState()); assertEquals(app1.getAMResourceRequests().get(0).getCapability() .getMemorySize(), appInfo.getAllocatedMB()); rm.stop(); }