List of usage examples for org.apache.hadoop.yarn.api.records ApplicationReport getProgress
@Public @Stable public abstract float getProgress();
From source file:husky.client.HuskyYarnClient.java
License:Apache License
private boolean monitorApp() throws YarnException, IOException { while (true) { try {/*from ww w. j a v a 2 s. c om*/ Thread.sleep(1000); } catch (InterruptedException ignore) { } ApplicationReport report = mYarnClient.getApplicationReport(mAppId); YarnApplicationState yarnState = report.getYarnApplicationState(); FinalApplicationStatus appState = report.getFinalApplicationStatus(); LOG.info("YarnState = " + yarnState + ", AppState = " + appState + ", Progress = " + report.getProgress()); if (yarnState == FINISHED) { if (appState == SUCCEEDED) { LOG.info("Application completed successfully."); return true; } else { LOG.info("Application completed unsuccessfully. YarnState: " + yarnState.toString() + ", ApplicationState: " + appState.toString()); return false; } } else if (yarnState == KILLED || yarnState == FAILED) { LOG.info("Application did not complete. YarnState: " + yarnState.toString() + ", ApplicationState: " + appState.toString()); return false; } } }
From source file:ml.shifu.guagua.yarn.GuaguaYarnClient.java
License:Apache License
/** * Assess whether job is already finished/failed and 'done' flag needs to be * set, prints progress display for client if all is going well. * //from ww w . ja v a 2 s .c om * @param report * the application report to assess. * @return true if job report indicates the job run is over. */ private boolean checkProgress(final ApplicationReport report) { YarnApplicationState jobState = report.getYarnApplicationState(); LOG.info( "Got applicaton report for appId={}, state={}, progress={}%, amDiag={}, masterHost={}, masterRpcPort={}, queue={}, startTime={}, clientToken={}, finalState={}, trackingUrl={}, user={}", this.appId.getId(), report.getYarnApplicationState().toString(), DF.format(report.getProgress() * 100), report.getDiagnostics(), report.getHost(), report.getRpcPort(), report.getQueue(), report.getStartTime(), report.getClientToAMToken(), report.getFinalApplicationStatus().toString(), report.getTrackingUrl(), report.getUser()); switch (jobState) { case FINISHED: LOG.info("Application finished in {} ms", (System.currentTimeMillis() - getStartTime())); return true; case KILLED: LOG.error("{} reports KILLED state, diagnostics show: {}", getAppName(), report.getDiagnostics()); return true; case FAILED: LOG.error("{} reports FAILED state, diagnostics show: {}", getAppName(), report.getDiagnostics()); return true; default: if (this.reportCounter++ % 5 == 0) { displayJobReport(report); } return false; } }
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:yrun.commands.Yps.java
License:Apache License
public static void main(String[] args) throws YarnException, IOException { YarnClient yarnClient = YarnClient.createYarnClient(); YarnConfiguration yarnConfiguration = new YarnConfiguration(); yarnClient.init(yarnConfiguration);// w w w . java2 s.co m yarnClient.start(); try { List<ApplicationReport> applications = yarnClient.getApplications(); for (ApplicationReport applicationReport : applications) { ApplicationId applicationId = applicationReport.getApplicationId(); String user = applicationReport.getUser(); String queue = applicationReport.getQueue(); String name = applicationReport.getName(); YarnApplicationState yarnApplicationState = applicationReport.getYarnApplicationState(); float progress = applicationReport.getProgress(); System.out.printf("%s\t%s\t%s\t%s\t%s\t%f%n", toString(applicationId), user, queue, name, yarnApplicationState.name(), progress); } } finally { yarnClient.stop(); yarnClient.close(); } }