com.amazonaws.services.elasticmapreduce.model.StepStatus Java Examples
The following examples show how to use
com.amazonaws.services.elasticmapreduce.model.StepStatus.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmrClusterJob.java From datacollector with Apache License 2.0 | 4 votes |
@Override public Properties getJobStatus(Properties jobProps) throws IOException { EMRJobConfig emrJobConfig = new EMRJobConfig(jobProps); Utils.checkNotNull(emrJobConfig.getClusterId(), "EMR Cluster Id"); String state; String message = null; DescribeStepResult res = getEmrClient(emrClusterConfig).describeStep(new DescribeStepRequest().withClusterId( emrJobConfig.getClusterId()).withStepId(emrJobConfig.getStepId())); StepStatus status = res.getStep().getStatus(); ApplicationId appId = null; LOG.debug(Utils.format("Status of step: {} is {}", emrJobConfig.getStepId(), status.getState())); if ("PENDING".equals(status.getState())) { state = status.getState(); if (status.getStateChangeReason() != null) { message = status.getStateChangeReason().getMessage(); } } else if (!"COMPLETED".equals(status.getState()) && !"RUNNING".equals(status.getState())) { state = status.getState(); if (status.getFailureDetails() != null) { message = status.getFailureDetails().getReason(); } } else { YarnClient yarnClient = getYarnClient(emrJobConfig.getClusterId(), emrClusterConfig); ApplicationReport report = null; try { for (ApplicationReport applicationReport : yarnClient.getApplications()) { if (applicationReport.getName().contains(emrJobConfig.getUniquePrefix())) { appId = applicationReport.getApplicationId(); break; } } if (appId != null) { report = yarnClient.getApplicationReport(appId); } } catch (YarnException ex) { throw new IOException("Failed to fetch yarn app report " + ex); } if (report != null) { YarnApplicationState yarnState = report.getYarnApplicationState(); FinalApplicationStatus finalApplicationStatus = report.getFinalApplicationStatus(); LOG.info(Utils.format("Application state for app id: {} is {} ", appId, yarnState)); state = yarnState.name(); if (YarnApplicationState.FINISHED == yarnState) { // override with final application state if yarnState is FINISHED state = finalApplicationStatus.name(); } message = report.getDiagnostics(); } else { state = "STARTING"; // a situation where step was in RUNNING but yarn application not yet created. message = "Yarn application not yet created"; } } EmrState emrJobState = new EmrState(); emrJobState.setState(state); emrJobState.setMessage(message); emrJobState.setAppId(appId != null ? appId.toString() : null); return emrJobState.toProperties(); }