private void updateState(YarnApplicationState newState) { state = newState; if (verbose) { System.out.print("Application State: "); System.out.println(state.toString()); System.out.print("Starting..."); } } }
private void updateState(YarnApplicationState newState) { YarnApplicationState oldState = state; state = newState; if (oldState == null) { return; } System.out.println(); System.out.print("Application State: "); System.out.println(state.toString()); System.out.print("Stopping..."); } }
@Subscribe public void handleApplicationReportArrivalEvent(ApplicationReportArrivalEvent applicationReportArrivalEvent) { ApplicationReport applicationReport = applicationReportArrivalEvent.getApplicationReport(); YarnApplicationState appState = applicationReport.getYarnApplicationState(); LOGGER.info("Gobblin Yarn application state: " + appState.toString()); // Reset the count on failures to get the ApplicationReport when there's one success this.getApplicationReportFailureCount.set(0); if (appState == YarnApplicationState.FINISHED || appState == YarnApplicationState.FAILED || appState == YarnApplicationState.KILLED) { applicationCompleted = true; LOGGER.info("Gobblin Yarn application finished with final status: " + applicationReport.getFinalApplicationStatus().toString()); if (applicationReport.getFinalApplicationStatus() == FinalApplicationStatus.FAILED) { LOGGER.error("Gobblin Yarn application failed for the following reason: " + applicationReport.getDiagnostics()); } try { GobblinYarnAppLauncher.this.stop(); } catch (IOException ioe) { LOGGER.error("Failed to close the " + GobblinYarnAppLauncher.class.getSimpleName(), ioe); } catch (TimeoutException te) { LOGGER.error("Timeout in stopping the service manager", te); } finally { if (this.emailNotificationOnShutdown) { sendEmailOnShutdown(Optional.of(applicationReport)); } } } }
public void display(boolean verbose, boolean isNew) { YarnApplicationState state = report.getYarnApplicationState(); if (verbose || !isNew) { System.out.println("Application State: " + state.toString()); System.out.println("Host: " + report.getHost()); } if (verbose || !isNew) { System.out.println("Queue: " + report.getQueue()); System.out.println("User: " + report.getUser()); long startTime = report.getStartTime(); System.out.println("Start Time: " + DoYUtil.toIsoTime(startTime)); System.out.println("Application Name: " + report.getName()); } System.out.println("Tracking URL: " + report.getTrackingUrl()); if (isNew) { System.out.println("Application Master URL: " + getAmUrl()); } showFinalStatus(); }
+ ", appMasterRpcPort=" + report.getRpcPort() + ", appStartTime=" + report.getStartTime() + ", yarnAppState=" + report.getYarnApplicationState().toString() + ", distributedFinalState=" + report.getFinalApplicationStatus().toString() + ", appTrackingUrl=" + report.getTrackingUrl() } else { LOG.info("Application did finished unsuccessfully." + " YarnState=" + state.toString() + ", DSFinalStatus=" + dsStatus.toString() + ". Breaking monitoring loop"); return false; || YarnApplicationState.FAILED == state) { LOG.info("Application did not finish." + " YarnState=" + state.toString() + ", DSFinalStatus=" + dsStatus.toString() + ". Breaking monitoring loop"); return false;
if (xlearningClient == null && isRunning.get()) { LOG.info("Application report for " + applicationId + " (state: " + applicationReport.getYarnApplicationState().toString() + ")"); xlearningClient = getAppMessageHandler(conf, applicationReport.getHost(), applicationReport.getRpcPort()); return true; } else { LOG.info("Application has completed failed with YarnApplicationState=" + yarnApplicationState.toString() + " and FinalApplicationStatus=" + finalApplicationStatus.toString()); return false; xlearningClient = null; isRunning.set(false); LOG.info("Application has completed with YarnApplicationState=" + yarnApplicationState.toString() + " and FinalApplicationStatus=" + finalApplicationStatus.toString()); return false;
+ ", appMasterRpcPort=" + report.getRpcPort() + ", appStartTime=" + report.getStartTime() + ", yarnAppState=" + report.getYarnApplicationState().toString() + ", distributedFinalState=" + report.getFinalApplicationStatus().toString() + ", appTrackingUrl=" + report.getTrackingUrl() + " YarnState=" + state.toString() + ", DSFinalStatus=" + dsStatus.toString() + ". Breaking monitoring loop"); return false; || YarnApplicationState.FAILED == state) { LOG.info("Application did not finish." + " YarnState=" + state.toString() + ", DSFinalStatus=" + dsStatus.toString() + ". Breaking monitoring loop"); return false;
private String clarifyAppState(YarnApplicationState state) { String ret = state.toString(); switch (state) { case NEW: return ret + ": waiting for application to be initialized"; case NEW_SAVING: return ret + ": waiting for application to be persisted in state-store."; case SUBMITTED: return ret + ": waiting for application to be accepted by scheduler."; case ACCEPTED: return ret + ": waiting for AM container to be allocated, launched and" + " register with RM."; case RUNNING: return ret + ": AM has registered with RM and started running."; default: return ret; } }
private String clarifyAppState(YarnApplicationState state) { String ret = state.toString(); switch (state) { case NEW: return ret + ": waiting for application to be initialized"; case NEW_SAVING: return ret + ": waiting for application to be persisted in state-store."; case SUBMITTED: return ret + ": waiting for application to be accepted by scheduler."; case ACCEPTED: return ret + ": waiting for AM container to be allocated, launched and" + " register with RM."; case RUNNING: return ret + ": AM has registered with RM and started running."; default: return ret; } }
static InstanceInfo extractInstanceInfo(String clusterName, ApplicationReport report) { InstanceMetadata md = getMetadata(report.getApplicationTags()); if (md == null) { return null; } ApplicationResourceUsageReport usage = report.getApplicationResourceUsageReport(); InstanceStatus stat = new InstanceStatus() .allocatedVCores((long) usage.getUsedResources().getVirtualCores()) .allocatedMB((long) usage.getUsedResources().getMemory()) .clusterId(clusterName) .applicationId(report.getApplicationId().toString()) .startedTime(report.getStartTime()) .runningContainers((long) usage.getNumUsedContainers()) .trackingUrl(report.getTrackingUrl()) .state(InstanceStatus.StateEnum.fromValue(report.getYarnApplicationState().toString())); return new InstanceInfo(clusterName, report.getApplicationId(), md, stat); } }
/** * This function returns the state of a given application. This state can be on of the * {"NEW", "NEW_SAVING", "SUBMITTED", "ACCEPTED", "RUNNING", "FINISHED", "FAILED", "KILLED"} * * @param applicationId the application id of the application the state is being queried * @return the state of the application which is one of the following values: {"NEW", "NEW_SAVING", "SUBMITTED", "ACCEPTED", "RUNNING", "FINISHED", "FAILED", "KILLED"} * @throws IOException Throws IO exception * @throws YarnException in case of errors or if YARN rejects the request due to * access-control restrictions. */ public String getApplicationState(String applicationId) throws IOException, YarnException { return yarnClient.getApplicationReport(getApplicationIDFromString(applicationId)).getYarnApplicationState().toString(); }
public Collection<CloudAppInstanceInfo> getSubmittedApplications() { List<CloudAppInstanceInfo> appIds = new ArrayList<CloudAppInstanceInfo>(); for (ApplicationReport report : yarnClient.listApplications("DATAFLOW")) { appIds.add(new CloudAppInstanceInfo(report.getApplicationId().toString(), report.getName(), report.getYarnApplicationState().toString(), report.getOriginalTrackingUrl())); } return appIds; }
public Collection<CloudAppInstanceInfo> getSubmittedApplications(String yarnApplicationId) { List<CloudAppInstanceInfo> appIds = new ArrayList<CloudAppInstanceInfo>(); for (ApplicationReport report : yarnClient.listApplications("DATAFLOW")) { if (report.getApplicationId().toString().equals(yarnApplicationId)) { appIds.add(new CloudAppInstanceInfo(report.getApplicationId().toString(), report.getName(), report.getYarnApplicationState().toString(), report.getOriginalTrackingUrl())); } } return appIds; }
@Test public void testRequestWithValidStateQueries() { GetApplicationsRequest request = ApplicationsRequestBuilder.create() .withStatesQuery( Sets.newHashSet(YarnApplicationState.NEW_SAVING.toString(), YarnApplicationState.NEW.toString())) .build(); GetApplicationsRequest expectedRequest = getDefaultRequest(); Set<String> appStates = Sets.newHashSet(YarnApplicationState.NEW_SAVING.toString(), YarnApplicationState.NEW.toString()); Set<String> appStatesLowerCase = parseQueries(appStates, true); expectedRequest.setApplicationStates(appStatesLowerCase); assertEquals(expectedRequest, request); }
@Test public void testRequestWithValidStateQuery() { GetApplicationsRequest request = ApplicationsRequestBuilder.create() .withStateQuery(YarnApplicationState.NEW_SAVING.toString()).build(); GetApplicationsRequest expectedRequest = getDefaultRequest(); Set<String> appStates = Sets.newHashSet(YarnApplicationState.NEW_SAVING.toString()); Set<String> appStatesLowerCase = parseQueries(appStates, true); expectedRequest.setApplicationStates(appStatesLowerCase); assertEquals(expectedRequest, request); }
@Test public void testView() throws Exception { Injector injector = WebAppTests.createMockInjector(ApplicationBaseProtocol.class, mockApplicationHistoryClientService(5, 1, 1)); AHSView ahsViewInstance = injector.getInstance(AHSView.class); ahsViewInstance.render(); WebAppTests.flushOutput(injector); ahsViewInstance.set(YarnWebParams.APP_STATE, YarnApplicationState.FAILED.toString()); ahsViewInstance.render(); WebAppTests.flushOutput(injector); ahsViewInstance.set(YarnWebParams.APP_STATE, StringHelper.cjoin( YarnApplicationState.FAILED.toString(), YarnApplicationState.KILLED)); ahsViewInstance.render(); WebAppTests.flushOutput(injector); }
@Test public void testGetApp() { LogWebService.AppInfo app = logWebService.getApp(request, appId.toString(), null); Assert.assertEquals("RUNNING", app.getAppState().toString()); Assert.assertEquals(user, app.getUser()); }
@Test public void testAppsQuery() throws Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("applicationhistory").path("apps") .queryParam("state", YarnApplicationState.FINISHED.toString()) .queryParam("user.name", USERS[round]) .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("incorrect number of elements", 1, json.length()); JSONObject apps = json.getJSONObject("apps"); assertEquals("incorrect number of elements", 1, apps.length()); JSONArray array = apps.getJSONArray("app"); assertEquals("incorrect number of elements", MAX_APPS, array.length()); }
@Test public void testAppsQueryStatesNone() throws JSONException, Exception { rm.start(); MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048); rm.submitApp(CONTAINER_MB); amNodeManager.nodeHeartbeat(true); WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("apps") .queryParam("states", YarnApplicationState.RUNNING.toString()) .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("incorrect number of elements", 1, json.length()); assertEquals("apps is not null", JSONObject.NULL, json.get("apps")); rm.stop(); }
@Test public void testAppsQueryStateNone() throws JSONException, Exception { rm.start(); MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048); rm.submitApp(CONTAINER_MB); amNodeManager.nodeHeartbeat(true); WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("apps") .queryParam("state", YarnApplicationState.RUNNING.toString()) .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("incorrect number of elements", 1, json.length()); assertEquals("apps is not null", JSONObject.NULL, json.get("apps")); rm.stop(); }