.append(appInfo.getAllocatedVCores() == -1 ? "N/A" : String .valueOf(appInfo.getAllocatedVCores())).append("\",\"") .append(appInfo.getAllocatedMB() == -1 ? "N/A" : String .valueOf(appInfo.getAllocatedMB())).append("\",\"") .append(appInfo.getReservedVCores() == -1 ? "N/A" : String .valueOf(appInfo.getReservedVCores())).append("\",\"")
private static void mergeAMWithUAM(AppInfo am, AppInfo uam) { am.setPreemptedResourceMB( am.getPreemptedResourceMB() + uam.getPreemptedResourceMB()); am.setPreemptedResourceVCores( am.getPreemptedResourceVCores() + uam.getPreemptedResourceVCores()); am.setNumNonAMContainerPreempted(am.getNumNonAMContainerPreempted() + uam.getNumNonAMContainerPreempted()); am.setNumAMContainerPreempted( am.getNumAMContainerPreempted() + uam.getNumAMContainerPreempted()); am.setPreemptedMemorySeconds( am.getPreemptedMemorySeconds() + uam.getPreemptedMemorySeconds()); am.setPreemptedVcoreSeconds( am.getPreemptedVcoreSeconds() + uam.getPreemptedVcoreSeconds()); if (am.getState() == YarnApplicationState.RUNNING && uam.getState() == am.getState()) { am.getResourceRequests().addAll(uam.getResourceRequests()); am.setAllocatedMB(am.getAllocatedMB() + uam.getAllocatedMB()); am.setAllocatedVCores(am.getAllocatedVCores() + uam.getAllocatedVCores()); am.setReservedMB(am.getReservedMB() + uam.getReservedMB()); am.setReservedVCores(am.getReservedVCores() + uam.getReservedMB()); am.setRunningContainers( am.getRunningContainers() + uam.getRunningContainers()); am.setMemorySeconds(am.getMemorySeconds() + uam.getMemorySeconds()); am.setVcoreSeconds(am.getVcoreSeconds() + uam.getVcoreSeconds()); } }
@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(); }