List of usage examples for org.apache.hadoop.yarn.api.records ApplicationReport getYarnApplicationState
@Public @Stable public abstract YarnApplicationState getYarnApplicationState();
YarnApplicationState
of the application. From source file:org.apache.slider.common.tools.SliderUtils.java
License:Apache License
/** * convert an AM report to a string for diagnostics * @param report the report/* w w w . j a v a2 s . c o m*/ * @return the string value */ public static String reportToString(ApplicationReport report) { if (report == null) { return "Null application report"; } return "App " + report.getName() + "/" + report.getApplicationType() + "# " + report.getApplicationId() + " user " + report.getUser() + " is in state " + report.getYarnApplicationState() + " RPC: " + report.getHost() + ":" + report.getRpcPort() + " URL" + report.getOriginalTrackingUrl(); }
From source file:org.apache.slider.core.launch.SerializedApplicationReport.java
License:Apache License
public SerializedApplicationReport(ApplicationReport report) { this.applicationId = report.getApplicationId().toString(); this.applicationAttemptId = report.getCurrentApplicationAttemptId().toString(); this.name = report.getName(); this.applicationType = report.getApplicationType(); this.user = report.getUser(); this.queue = report.getQueue(); this.host = report.getHost(); this.rpcPort = report.getRpcPort(); this.state = report.getYarnApplicationState().toString(); this.diagnostics = report.getDiagnostics(); this.startTime = report.getStartTime(); this.finishTime = report.getFinishTime(); this.finalStatus = report.getFinalApplicationStatus().toString(); this.progress = report.getProgress(); }
From source file:org.apache.slider.server.appmaster.rpc.RpcBinder.java
License:Apache License
/** * This loops for a limited period trying to get the Proxy - * by doing so it handles AM failover//from ww w . ja v a2 s .com * @param conf configuration to patch and use * @param rmClient client of the resource manager * @param application application to work with * @param connectTimeout timeout for the whole proxy operation to timeout * (milliseconds). Use 0 to indicate "do not attempt to wait" -fail fast. * @param rpcTimeout timeout for RPCs to block during communications * @return the proxy * @throws IOException IO problems * @throws YarnException Slider-generated exceptions related to the binding * failing. This can include the application finishing or timeouts * @throws InterruptedException if a sleep operation waiting for * the cluster to respond is interrupted. */ @SuppressWarnings("NestedAssignment") public static SliderClusterProtocol getProxy(final Configuration conf, final ApplicationClientProtocol rmClient, ApplicationReport application, final int connectTimeout, final int rpcTimeout) throws IOException, YarnException, InterruptedException { ApplicationId appId; appId = application.getApplicationId(); Duration timeout = new Duration(connectTimeout); timeout.start(); Exception exception = null; YarnApplicationState state = null; while (application != null && (state = application.getYarnApplicationState()).equals(YarnApplicationState.RUNNING)) { try { return getProxy(conf, application, rpcTimeout); } catch (IOException e) { if (connectTimeout <= 0 || timeout.getLimitExceeded()) { throw e; } exception = e; } catch (YarnException e) { if (connectTimeout <= 0 || timeout.getLimitExceeded()) { throw e; } exception = e; } //at this point: app failed to work log.debug("Could not connect to {}. Waiting for getting the latest AM address...", appId); Thread.sleep(1000); //or get the app report application = rmClient.getApplicationReport(GetApplicationReportRequest.newInstance(appId)) .getApplicationReport(); } //get here if the app is no longer running. Raise a specific //exception but init it with the previous failure throw new BadClusterStateException(exception, ErrorStrings.E_FINISHED_APPLICATION, appId, state); }
From source file:org.apache.tajo.master.rm.YarnTajoResourceManager.java
License:Apache License
private ApplicationReport monitorApplication(ApplicationId appId, Set<YarnApplicationState> finalState) throws IOException, YarnException { long sleepTime = 100; int count = 1; while (true) { // Get application report for the appId we are interested in ApplicationReport report = yarnClient.getApplicationReport(appId); LOG.info("Got application report from ASM for" + ", appId=" + appId.getId() + ", appAttemptId=" + report.getCurrentApplicationAttemptId() + ", clientToken=" + report.getClientToAMToken() + ", appDiagnostics=" + report.getDiagnostics() + ", appMasterHost=" + report.getHost() + ", appQueue=" + report.getQueue() + ", appMasterRpcPort=" + report.getRpcPort() + ", appStartTime=" + report.getStartTime() + ", yarnAppState=" + report.getYarnApplicationState().toString() + ", distributedFinalState=" + report.getFinalApplicationStatus().toString() + ", appTrackingUrl=" + report.getTrackingUrl() + ", appUser=" + report.getUser()); YarnApplicationState state = report.getYarnApplicationState(); if (finalState.contains(state)) { return report; }// w w w . j a va 2 s. co m try { Thread.sleep(sleepTime); sleepTime = count * 100; if (count < 10) { count++; } } catch (InterruptedException e) { //LOG.debug("Thread sleep in monitoring loop interrupted"); } } }
From source file:org.apache.tajo.master.rm.YarnTajoResourceManager.java
License:Apache License
public boolean isQueryMasterStopped(QueryId queryId) { ApplicationId appId = ApplicationIdUtils.queryIdToAppId(queryId); try {// w w w. j a v a 2 s . c om ApplicationReport report = yarnClient.getApplicationReport(appId); YarnApplicationState state = report.getYarnApplicationState(); return EnumSet .of(YarnApplicationState.FINISHED, YarnApplicationState.KILLED, YarnApplicationState.FAILED) .contains(state); } catch (YarnException e) { LOG.error(e.getMessage(), e); return false; } catch (IOException e) { LOG.error(e.getMessage(), e); return false; } }
From source file:org.apache.tez.client.TezClient.java
License:Apache License
/** * Get the status of the App Master executing the DAG * In non-session mode it returns the status of the last submitted DAG App Master * In session mode, it returns the status of the App Master hosting the session * // w ww. j a va 2s. c om * @return State of the session * @throws TezException * @throws IOException */ public synchronized TezAppMasterStatus getAppMasterStatus() throws TezException, IOException { // Supporting per-DAG app master case since user may choose to run the same // code in that mode and the code should continue to work. Its easy to provide // the correct view for per-DAG app master too. ApplicationId appId = null; if (isSession) { appId = sessionAppId; } else { appId = lastSubmittedAppId; } Preconditions.checkState(appId != null, "Cannot get status without starting an application"); try { ApplicationReport appReport = frameworkClient.getApplicationReport(appId); switch (appReport.getYarnApplicationState()) { case NEW: case NEW_SAVING: case ACCEPTED: case SUBMITTED: return TezAppMasterStatus.INITIALIZING; case FAILED: case KILLED: diagnostics = appReport.getDiagnostics(); LOG.info("App did not succeed. Diagnostics: " + (appReport.getDiagnostics() != null ? appReport.getDiagnostics() : NO_CLUSTER_DIAGNOSTICS_MSG)); return TezAppMasterStatus.SHUTDOWN; case FINISHED: return TezAppMasterStatus.SHUTDOWN; case RUNNING: if (!isSession) { return TezAppMasterStatus.RUNNING; } try { DAGClientAMProtocolBlockingPB proxy = getSessionAMProxy(appId); if (proxy == null) { return TezAppMasterStatus.INITIALIZING; } GetAMStatusResponseProto response = proxy.getAMStatus(null, GetAMStatusRequestProto.newBuilder().build()); return DagTypeConverters.convertTezSessionStatusFromProto(response.getStatus()); } catch (TezException e) { LOG.info("Failed to retrieve AM Status via proxy", e); } catch (ServiceException e) { LOG.info("Failed to retrieve AM Status via proxy", e); } } } catch (YarnException e) { throw new TezException(e); } return TezAppMasterStatus.INITIALIZING; }
From source file:org.apache.tez.client.TezClientUtils.java
License:Apache License
static DAGClientAMProtocolBlockingPB getSessionAMProxy(FrameworkClient yarnClient, Configuration conf, ApplicationId applicationId) throws TezException, IOException { ApplicationReport appReport; try {/*from www.j av a 2 s . co m*/ appReport = yarnClient.getApplicationReport(applicationId); if (appReport == null) { throw new TezUncheckedException( "Could not retrieve application report" + " from YARN, applicationId=" + applicationId); } YarnApplicationState appState = appReport.getYarnApplicationState(); if (appState != YarnApplicationState.RUNNING) { if (appState == YarnApplicationState.FINISHED || appState == YarnApplicationState.KILLED || appState == YarnApplicationState.FAILED) { String msg = "Application not running" + ", applicationId=" + applicationId + ", yarnApplicationState=" + appReport.getYarnApplicationState() + ", finalApplicationStatus=" + appReport.getFinalApplicationStatus() + ", trackingUrl=" + appReport.getTrackingUrl() + ", diagnostics=" + (appReport.getDiagnostics() != null ? appReport.getDiagnostics() : TezClient.NO_CLUSTER_DIAGNOSTICS_MSG); LOG.info(msg); throw new SessionNotRunning(msg); } return null; } } catch (YarnException e) { throw new TezException(e); } return getAMProxy(conf, appReport.getHost(), appReport.getRpcPort(), appReport.getClientToAMToken()); }
From source file:org.apache.tez.client.TezSession.java
License:Apache License
public TezSessionStatus getSessionStatus() throws TezException, IOException { try {/*from ww w . j a va 2 s .co m*/ ApplicationReport appReport = yarnClient.getApplicationReport(applicationId); switch (appReport.getYarnApplicationState()) { case NEW: case NEW_SAVING: case ACCEPTED: case SUBMITTED: return TezSessionStatus.INITIALIZING; case FINISHED: case FAILED: case KILLED: return TezSessionStatus.SHUTDOWN; case RUNNING: try { DAGClientAMProtocolBlockingPB proxy = TezClientUtils.getSessionAMProxy(yarnClient, sessionConfig.getYarnConfiguration(), applicationId); if (proxy == null) { return TezSessionStatus.INITIALIZING; } GetAMStatusResponseProto response = proxy.getAMStatus(null, GetAMStatusRequestProto.newBuilder().build()); return DagTypeConverters.convertTezSessionStatusFromProto(response.getStatus()); } catch (TezException e) { LOG.info("Failed to retrieve AM Status via proxy", e); } catch (ServiceException e) { LOG.info("Failed to retrieve AM Status via proxy", e); } } } catch (YarnException e) { throw new TezException(e); } return TezSessionStatus.INITIALIZING; }
From source file:org.apache.tez.client.TezYarnClient.java
License:Apache License
@Override public ApplicationId submitApplication(ApplicationSubmissionContext appSubmissionContext) throws YarnException, IOException { ApplicationId appId = yarnClient.submitApplication(appSubmissionContext); ApplicationReport appReport = getApplicationReport(appId); if (appReport.getYarnApplicationState() == YarnApplicationState.FAILED) { throw new IOException("Failed to submit application to YARN: " + appReport.getDiagnostics()); }/*from w w w .ja v a2 s . c o m*/ return appId; }
From source file:org.apache.tez.dag.api.client.DAGClientImpl.java
License:Apache License
DAGStatus getDAGStatusViaRM() throws TezException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("GetDAGStatus via AM for app: " + appId + " dag:" + dagId); }//w w w .j a v a2 s. c o m ApplicationReport appReport; try { appReport = frameworkClient.getApplicationReport(appId); } catch (YarnException e) { throw new TezException(e); } if (appReport == null) { throw new TezException("Unknown/Invalid appId: " + appId); } DAGProtos.DAGStatusProto.Builder builder = DAGProtos.DAGStatusProto.newBuilder(); DAGStatus dagStatus = new DAGStatus(builder); DAGProtos.DAGStatusStateProto dagState; switch (appReport.getYarnApplicationState()) { case NEW: case NEW_SAVING: case SUBMITTED: case ACCEPTED: dagState = DAGProtos.DAGStatusStateProto.DAG_SUBMITTED; break; case RUNNING: dagState = DAGProtos.DAGStatusStateProto.DAG_RUNNING; break; case FAILED: dagState = DAGProtos.DAGStatusStateProto.DAG_FAILED; break; case KILLED: dagState = DAGProtos.DAGStatusStateProto.DAG_KILLED; break; case FINISHED: switch (appReport.getFinalApplicationStatus()) { case UNDEFINED: case FAILED: dagState = DAGProtos.DAGStatusStateProto.DAG_FAILED; break; case KILLED: dagState = DAGProtos.DAGStatusStateProto.DAG_KILLED; break; case SUCCEEDED: dagState = DAGProtos.DAGStatusStateProto.DAG_SUCCEEDED; break; default: throw new TezUncheckedException("Encountered unknown final application" + " status from YARN" + ", appState=" + appReport.getYarnApplicationState() + ", finalStatus=" + appReport.getFinalApplicationStatus()); } break; default: throw new TezUncheckedException("Encountered unknown application state" + " from YARN, appState=" + appReport.getYarnApplicationState()); } builder.setState(dagState); if (appReport.getDiagnostics() != null) { builder.addAllDiagnostics(Collections.singleton(appReport.getDiagnostics())); } return dagStatus; }