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; }
for (AppInfo a : appsInfo) { if (a.getAMHostHttpAddress() != null) { 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); if (returnPartialResult || (a.getName() != null && !(a.getName().startsWith(UnmanagedApplicationManager.APP_NAME) || a.getName().startsWith(PARTIAL_REPORT)))) { federationAM.put(a.getAppId(), a);
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()); } }
continue; AppInfo appInfo = new AppInfo(rm, app, true, WebAppUtils.getHttpSchemePrefix(conf)); String percent = String.format("%.1f", appInfo.getProgress()); ApplicationAttemptId attemptId = app.getCurrentAppAttempt().getAppAttemptId(); int fairShare = fsinfo.getAppFairShare(attemptId); .append(url("app", appInfo.getAppId())).append("'>") .append(appInfo.getAppId()).append("</a>\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( appInfo.getUser()))).append("\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( appInfo.getName()))).append("\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( appInfo.getApplicationType()))).append("\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( appInfo.getQueue()))).append("\",\"") .append(fairShare).append("\",\"") .append(appInfo.getStartTime()).append("\",\"") .append(appInfo.getFinishTime()).append("\",\"") .append(appInfo.getState()).append("\",\"") .append(appInfo.getFinalStatus()).append("\",\"") !appInfo.isTrackingUrlReady()? "#" : appInfo.getTrackingUrlPretty(); .append(appInfo.getTrackingUI()).append("</a>\"],\n");
AppInfo appInfo = new AppInfo(rm, app, true, WebAppUtils.getHttpSchemePrefix(conf)); String percent = StringUtils.format("%.1f", appInfo.getProgress()); ApplicationAttemptId attemptId = app.getCurrentAppAttempt().getAppAttemptId(); long fairShare = fsinfo.getAppFairShare(attemptId); .append(url("app", appInfo.getAppId())).append("'>") .append(appInfo.getAppId()).append("</a>\",\"") .append(StringEscapeUtils.escapeEcmaScript(StringEscapeUtils.escapeHtml4( appInfo.getUser()))).append("\",\"") .append(StringEscapeUtils.escapeEcmaScript(StringEscapeUtils.escapeHtml4( appInfo.getName()))).append("\",\"") .append(StringEscapeUtils.escapeEcmaScript(StringEscapeUtils.escapeHtml4( appInfo.getApplicationType()))).append("\",\"") .append(StringEscapeUtils.escapeEcmaScript(StringEscapeUtils.escapeHtml4( appInfo.getQueue()))).append("\",\"") .append(fairShare).append("\",\"") .append(appInfo.getStartTime()).append("\",\"") .append(appInfo.getLaunchTime()).append("\",\"") .append(appInfo.getFinishTime()).append("\",\"") .append(appInfo.getState()).append("\",\"") .append(appInfo.getFinalStatus()).append("\",\"") .append(appInfo.getRunningContainers() == -1 ? "N/A" : String .valueOf(appInfo.getRunningContainers())).append("\",\"") .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("\",\"")
try { String percent = String.format("%.1f", app.getProgress() * 100.0F); String trackingURL = app.getTrackingUrl() == null ? "#" : app.getTrackingUrl(); .append(app.getAppId()).append("</a>\",\"") .append(escape(app.getUser())).append("\",\"") .append(escape(app.getName())).append("\",\"") .append(escape(app.getApplicationType())).append("\",\"") .append(escape(app.getQueue())).append("\",\"") .append(String.valueOf(app.getPriority())).append("\",\"") .append(app.getStartTime()).append("\",\"") .append(app.getFinishTime()).append("\",\"") .append(app.getState()).append("\",\"") .append(app.getFinalStatus()).append("\",\"") "Cannot add application {}: {}", app.getAppId(), e.getMessage());
@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(); }
private void createResourceRequestsTable(Block html) { AppInfo app = new AppInfo(rm, rm.getRMContext().getRMApps() .get(this.appAttemptId.getApplicationId()), true, WebAppUtils.getHttpSchemePrefix(conf)); List<ResourceRequestInfo> resourceRequests = app.getResourceRequests(); if (resourceRequests == null || resourceRequests.isEmpty()) { return;
@GET @Path(RMWSConsts.APPS_APPID) @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) @Override public AppInfo getApp(@Context HttpServletRequest hsr, @PathParam(RMWSConsts.APPID) String appId, @QueryParam(RMWSConsts.DESELECTS) Set<String> unselectedFields) { initForReadableEndpoints(); ApplicationId id = WebAppUtils.parseApplicationId(recordFactory, appId); RMApp app = rm.getRMContext().getRMApps().get(id); if (app == null) { throw new NotFoundException("app with id: " + appId + " not found"); } DeSelectFields deSelectFields = new DeSelectFields(); deSelectFields.initFields(unselectedFields); return new AppInfo(rm, app, hasAccess(app, hsr), hsr.getScheme() + "://", deSelectFields); }
continue; AppInfo appInfo = new AppInfo(rm, app, true, WebAppUtils.getHttpSchemePrefix(conf)); String percent = String.format("%.1f", appInfo.getProgress()); ApplicationAttemptId attemptId = app.getCurrentAppAttempt().getAppAttemptId(); int fairShare = fsinfo.getAppFairShare(attemptId); .append(url("app", appInfo.getAppId())).append("'>") .append(appInfo.getAppId()).append("</a>\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( appInfo.getUser()))).append("\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( appInfo.getName()))).append("\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( appInfo.getApplicationType()))).append("\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( appInfo.getQueue()))).append("\",\"") .append(fairShare).append("\",\"") .append(appInfo.getStartTime()).append("\",\"") .append(appInfo.getFinishTime()).append("\",\"") .append(appInfo.getState()).append("\",\"") .append(appInfo.getFinalStatus()).append("\",\"") !appInfo.isTrackingUrlReady()? "#" : appInfo.getTrackingUrlPretty(); .append(appInfo.getTrackingUI()).append("</a>\"],\n");
private void createResourceRequestsTable(Block html) { AppInfo app = new AppInfo(rm, rm.getRMContext().getRMApps() .get(this.appAttemptId.getApplicationId()), true, WebAppUtils.getHttpSchemePrefix(conf)); List<ResourceRequest> resourceRequests = app.getResourceRequests(); if (resourceRequests == null || resourceRequests.isEmpty()) { return;
@GET @Path("/apps/{appid}") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public AppInfo getApp(@Context HttpServletRequest hsr, @PathParam("appid") String appId) { init(); if (appId == null || appId.isEmpty()) { throw new NotFoundException("appId, " + appId + ", is empty or null"); } ApplicationId id; id = ConverterUtils.toApplicationId(recordFactory, appId); if (id == null) { throw new NotFoundException("appId is null"); } RMApp app = rm.getRMContext().getRMApps().get(id); if (app == null) { throw new NotFoundException("app with id: " + appId + " not found"); } return new AppInfo(rm, app, hasAccess(app, hsr), hsr.getScheme() + "://"); }
private void createResourceRequestsTable(Block html) { AppInfo app = new AppInfo(rm, rm.getRMContext().getRMApps() .get(this.appAttemptId.getApplicationId()), true, WebAppUtils.getHttpSchemePrefix(conf)); List<ResourceRequest> resourceRequests = app.getResourceRequests(); if (resourceRequests == null || resourceRequests.isEmpty()) { return;
@GET @Path("/apps/{appid}") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public AppInfo getApp(@Context HttpServletRequest hsr, @PathParam("appid") String appId) { init(); if (appId == null || appId.isEmpty()) { throw new NotFoundException("appId, " + appId + ", is empty or null"); } ApplicationId id; id = ConverterUtils.toApplicationId(recordFactory, appId); if (id == null) { throw new NotFoundException("appId is null"); } RMApp app = rm.getRMContext().getRMApps().get(id); if (app == null) { throw new NotFoundException("app with id: " + appId + " not found"); } return new AppInfo(rm, app, hasAccess(app, hsr), hsr.getScheme() + "://"); }
AppInfo app = new AppInfo(rm, rmapp, hasAccess(rmapp, hsr), WebAppUtils.getHttpSchemePrefix(conf)); allApps.add(app);
AppInfo app = new AppInfo(rm, rmapp, hasAccess(rmapp, hsr), WebAppUtils.getHttpSchemePrefix(conf)); allApps.add(app);
AppInfo app = new AppInfo(rm, rmapp, allowAccess, WebAppUtils.getHttpSchemePrefix(conf), deSelectFields); allApps.add(app);