Java Code Examples for org.apache.hadoop.yarn.api.records.FinalApplicationStatus#FAILED

The following examples show how to use org.apache.hadoop.yarn.api.records.FinalApplicationStatus#FAILED . 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: YarnResourceManager.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Converts a Flink application status enum to a YARN application status enum.
 * @param status The Flink application status.
 * @return The corresponding YARN application status.
 */
private FinalApplicationStatus getYarnStatus(ApplicationStatus status) {
	if (status == null) {
		return FinalApplicationStatus.UNDEFINED;
	}
	else {
		switch (status) {
			case SUCCEEDED:
				return FinalApplicationStatus.SUCCEEDED;
			case FAILED:
				return FinalApplicationStatus.FAILED;
			case CANCELED:
				return FinalApplicationStatus.KILLED;
			default:
				return FinalApplicationStatus.UNDEFINED;
		}
	}
}
 
Example 2
Source File: YarnResourceManager.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Converts a Flink application status enum to a YARN application status enum.
 * @param status The Flink application status.
 * @return The corresponding YARN application status.
 */
private FinalApplicationStatus getYarnStatus(ApplicationStatus status) {
	if (status == null) {
		return FinalApplicationStatus.UNDEFINED;
	}
	else {
		switch (status) {
			case SUCCEEDED:
				return FinalApplicationStatus.SUCCEEDED;
			case FAILED:
				return FinalApplicationStatus.FAILED;
			case CANCELED:
				return FinalApplicationStatus.KILLED;
			default:
				return FinalApplicationStatus.UNDEFINED;
		}
	}
}
 
Example 3
Source File: RMAppImpl.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private FinalApplicationStatus createFinalApplicationStatus(RMAppState state) {
  switch(state) {
  case NEW:
  case NEW_SAVING:
  case SUBMITTED:
  case ACCEPTED:
  case RUNNING:
  case FINAL_SAVING:
  case KILLING:
    return FinalApplicationStatus.UNDEFINED;    
  // finished without a proper final state is the same as failed  
  case FINISHING:
  case FINISHED:
  case FAILED:
    return FinalApplicationStatus.FAILED;
  case KILLED:
    return FinalApplicationStatus.KILLED;
  }
  throw new YarnRuntimeException("Unknown state passed!");
}
 
Example 4
Source File: TestRMAppAttemptTransitions.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testFinishingKill() {
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false);
  FinalApplicationStatus finalStatus = FinalApplicationStatus.FAILED;
  String trackingUrl = "newtrackingurl";
  String diagnostics = "Job failed";
  unregisterApplicationAttempt(amContainer, finalStatus, trackingUrl,
      diagnostics);
  applicationAttempt.handle(
      new RMAppAttemptEvent(
          applicationAttempt.getAppAttemptId(), 
          RMAppAttemptEventType.KILL));
  testAppAttemptFinishingState(amContainer, finalStatus, trackingUrl,
      diagnostics);
}
 
Example 5
Source File: RMAppImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
private FinalApplicationStatus createFinalApplicationStatus(RMAppState state) {
  switch(state) {
  case NEW:
  case NEW_SAVING:
  case SUBMITTED:
  case ACCEPTED:
  case RUNNING:
  case FINAL_SAVING:
  case KILLING:
    return FinalApplicationStatus.UNDEFINED;    
  // finished without a proper final state is the same as failed  
  case FINISHING:
  case FINISHED:
  case FAILED:
    return FinalApplicationStatus.FAILED;
  case KILLED:
    return FinalApplicationStatus.KILLED;
  }
  throw new YarnRuntimeException("Unknown state passed!");
}
 
Example 6
Source File: TestRMAppAttemptTransitions.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testFinishingKill() {
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false);
  FinalApplicationStatus finalStatus = FinalApplicationStatus.FAILED;
  String trackingUrl = "newtrackingurl";
  String diagnostics = "Job failed";
  unregisterApplicationAttempt(amContainer, finalStatus, trackingUrl,
      diagnostics);
  applicationAttempt.handle(
      new RMAppAttemptEvent(
          applicationAttempt.getAppAttemptId(), 
          RMAppAttemptEventType.KILL));
  testAppAttemptFinishingState(amContainer, finalStatus, trackingUrl,
      diagnostics);
}
 
Example 7
Source File: YarnResourceManager.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Converts a Flink application status enum to a YARN application status enum.
 * @param status The Flink application status.
 * @return The corresponding YARN application status.
 */
private FinalApplicationStatus getYarnStatus(ApplicationStatus status) {
	if (status == null) {
		return FinalApplicationStatus.UNDEFINED;
	}
	else {
		switch (status) {
			case SUCCEEDED:
				return FinalApplicationStatus.SUCCEEDED;
			case FAILED:
				return FinalApplicationStatus.FAILED;
			case CANCELED:
				return FinalApplicationStatus.KILLED;
			default:
				return FinalApplicationStatus.UNDEFINED;
		}
	}
}
 
Example 8
Source File: LocalClient.java    From tez with Apache License 2.0 6 votes vote down vote up
protected FinalApplicationStatus convertDAGAppMasterStateToFinalYARNState(
    DAGAppMasterState dagAppMasterState) {
  switch (dagAppMasterState) {
    case NEW:
    case INITED:
    case RECOVERING:
    case IDLE:
    case RUNNING:
      return FinalApplicationStatus.UNDEFINED;
    case SUCCEEDED:
      return FinalApplicationStatus.SUCCEEDED;
    case FAILED:
      return FinalApplicationStatus.FAILED;
    case KILLED:
      return FinalApplicationStatus.KILLED;
    case ERROR:
      return FinalApplicationStatus.FAILED;
    default:
      return FinalApplicationStatus.UNDEFINED;
  }
}
 
Example 9
Source File: ApplicationMaster.java    From TensorFlowOnYARN with Apache License 2.0 5 votes vote down vote up
private FinalApplicationStatus getFinalAppStatus() {
  if (completedContainerNum.get() - failedContainerNum.get() >= args.totalContainerNum) {
    return FinalApplicationStatus.SUCCEEDED;
  } else {
    return FinalApplicationStatus.FAILED;
  }
}
 
Example 10
Source File: YarnRMContainerAllocator.java    From incubator-tajo with Apache License 2.0 5 votes vote down vote up
public void stop() {
  if(stopped.get()) {
    return;
  }
  LOG.info("un-registering ApplicationMaster(QueryMaster):" + appAttemptId);
  stopped.set(true);

  try {
    FinalApplicationStatus status = FinalApplicationStatus.UNDEFINED;
    Query query = context.getQuery();
    if (query != null) {
      TajoProtos.QueryState state = query.getState();
      if (state == TajoProtos.QueryState.QUERY_SUCCEEDED) {
        status = FinalApplicationStatus.SUCCEEDED;
      } else if (state == TajoProtos.QueryState.QUERY_FAILED || state == TajoProtos.QueryState.QUERY_ERROR) {
        status = FinalApplicationStatus.FAILED;
      } else if (state == TajoProtos.QueryState.QUERY_ERROR) {
        status = FinalApplicationStatus.FAILED;
      }
    }
    unregisterApplicationMaster(status, "tajo query finished", null);
  } catch (Exception e) {
    LOG.error(e.getMessage(), e);
  }

  allocatorThread.interrupt();
  LOG.info("un-registered ApplicationMAster(QueryMaster) stopped:" + appAttemptId);

  super.stop();
}
 
Example 11
Source File: GobblinYarnAppLauncher.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
@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));
      }
    }
  }
}
 
Example 12
Source File: TaskSchedulerEventHandler.java    From incubator-tez with Apache License 2.0 5 votes vote down vote up
@Override
public AppFinalStatus getFinalAppStatus() {
  FinalApplicationStatus finishState = FinalApplicationStatus.UNDEFINED;
  StringBuffer sb = new StringBuffer();
  if (dagAppMaster == null) {
    finishState = FinalApplicationStatus.UNDEFINED;
    sb.append("App not yet initialized");
  } else {
    DAGAppMasterState appMasterState = dagAppMaster.getState();
    if (appMasterState == DAGAppMasterState.SUCCEEDED) {
      finishState = FinalApplicationStatus.SUCCEEDED;
    } else if (appMasterState == DAGAppMasterState.KILLED
        || (appMasterState == DAGAppMasterState.RUNNING && isSignalled)) {
      finishState = FinalApplicationStatus.KILLED;
    } else if (appMasterState == DAGAppMasterState.FAILED
        || appMasterState == DAGAppMasterState.ERROR) {
      finishState = FinalApplicationStatus.FAILED;
    } else {
      finishState = FinalApplicationStatus.UNDEFINED;
    }
    List<String> diagnostics = dagAppMaster.getDiagnostics();
    if(diagnostics != null) {
      for (String s : diagnostics) {
        sb.append(s).append("\n");
      }
    }
  }
  if(LOG.isDebugEnabled()) {
    LOG.debug("Setting job diagnostics to " + sb.toString());
  }

  String historyUrl = "";
  /*String historyUrl = JobHistoryUtils.getHistoryUrl(getConfig(),
      appContext.getApplicationID());
  LOG.info("History url is " + historyUrl);*/

  return new AppFinalStatus(finishState, sb.toString(), historyUrl);
}
 
Example 13
Source File: HadoopShim28.java    From tez with Apache License 2.0 5 votes vote down vote up
@Override
public FinalApplicationStatus applyFinalApplicationStatusCorrection(FinalApplicationStatus orig,
    boolean isSessionMode, boolean isError) {
  switch (orig) {
    case FAILED:
      // App is failed if dag failed in non-session mode or there was an error.
      return (!isSessionMode || isError) ?
          FinalApplicationStatus.FAILED : FinalApplicationStatus.ENDED;
    case SUCCEEDED:
      return isSessionMode ? FinalApplicationStatus.ENDED : FinalApplicationStatus.SUCCEEDED;
    default:
      return orig;
  }
}
 
Example 14
Source File: TaskSchedulerManager.java    From tez with Apache License 2.0 5 votes vote down vote up
public AppFinalStatus getFinalAppStatus() {
  FinalApplicationStatus finishState = FinalApplicationStatus.UNDEFINED;
  StringBuffer sb = new StringBuffer();
  if (dagAppMaster == null) {
    finishState = FinalApplicationStatus.UNDEFINED;
    sb.append("App not yet initialized");
  } else {
    DAGAppMasterState appMasterState = dagAppMaster.getState();
    if (appMasterState == DAGAppMasterState.SUCCEEDED) {
      finishState = FinalApplicationStatus.SUCCEEDED;
    } else if (appMasterState == DAGAppMasterState.KILLED
        || (appMasterState == DAGAppMasterState.RUNNING && isSignalled)) {
      finishState = FinalApplicationStatus.KILLED;
    } else if (appMasterState == DAGAppMasterState.FAILED
        || appMasterState == DAGAppMasterState.ERROR) {
      finishState = FinalApplicationStatus.FAILED;
    } else {
      finishState = FinalApplicationStatus.UNDEFINED;
    }
    finishState = hadoopShim.applyFinalApplicationStatusCorrection(finishState,
        dagAppMaster.isSession(), appMasterState == DAGAppMasterState.ERROR);
    List<String> diagnostics = dagAppMaster.getDiagnostics();
    if(diagnostics != null) {
      for (String s : diagnostics) {
        sb.append(s).append("\n");
      }
    }
  }
  if(LOG.isDebugEnabled()) {
    LOG.debug("Setting job diagnostics to " + sb.toString());
  }

  // if history url is set use the same, if historyUrl is set to "" then rm ui disables the
  // history url
  return new AppFinalStatus(finishState, sb.toString(), historyUrl);
}
 
Example 15
Source File: RMCommunicator.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
protected void doUnregistration()
    throws YarnException, IOException, InterruptedException {
  FinalApplicationStatus finishState = FinalApplicationStatus.UNDEFINED;
  JobImpl jobImpl = (JobImpl)job;
  if (jobImpl.getInternalState() == JobStateInternal.SUCCEEDED) {
    finishState = FinalApplicationStatus.SUCCEEDED;
  } else if (jobImpl.getInternalState() == JobStateInternal.KILLED
      || (jobImpl.getInternalState() == JobStateInternal.RUNNING && isSignalled)) {
    finishState = FinalApplicationStatus.KILLED;
  } else if (jobImpl.getInternalState() == JobStateInternal.FAILED
      || jobImpl.getInternalState() == JobStateInternal.ERROR) {
    finishState = FinalApplicationStatus.FAILED;
  }
  StringBuffer sb = new StringBuffer();
  for (String s : job.getDiagnostics()) {
    sb.append(s).append("\n");
  }
  LOG.info("Setting job diagnostics to " + sb.toString());

  String historyUrl =
      MRWebAppUtil.getApplicationWebURLOnJHSWithScheme(getConfig(),
          context.getApplicationID());
  LOG.info("History url is " + historyUrl);
  FinishApplicationMasterRequest request =
      FinishApplicationMasterRequest.newInstance(finishState,
        sb.toString(), historyUrl);
  try {
    while (true) {
      FinishApplicationMasterResponse response =
          scheduler.finishApplicationMaster(request);
      if (response.getIsUnregistered()) {
        // When excepting ClientService, other services are already stopped,
        // it is safe to let clients know the final states. ClientService
        // should wait for some time so clients have enough time to know the
        // final states.
        RunningAppContext raContext = (RunningAppContext) context;
        raContext.markSuccessfulUnregistration();
        break;
      }
      LOG.info("Waiting for application to be successfully unregistered.");
      Thread.sleep(rmPollInterval);
    }
  } catch (ApplicationMasterNotRegisteredException e) {
    // RM might have restarted or failed over and so lost the fact that AM had
    // registered before.
    register();
    doUnregistration();
  }
}
 
Example 16
Source File: RMCommunicator.java    From big-c with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
protected void doUnregistration()
    throws YarnException, IOException, InterruptedException {
  FinalApplicationStatus finishState = FinalApplicationStatus.UNDEFINED;
  JobImpl jobImpl = (JobImpl)job;
  if (jobImpl.getInternalState() == JobStateInternal.SUCCEEDED) {
    finishState = FinalApplicationStatus.SUCCEEDED;
  } else if (jobImpl.getInternalState() == JobStateInternal.KILLED
      || (jobImpl.getInternalState() == JobStateInternal.RUNNING && isSignalled)) {
    finishState = FinalApplicationStatus.KILLED;
  } else if (jobImpl.getInternalState() == JobStateInternal.FAILED
      || jobImpl.getInternalState() == JobStateInternal.ERROR) {
    finishState = FinalApplicationStatus.FAILED;
  }
  StringBuffer sb = new StringBuffer();
  for (String s : job.getDiagnostics()) {
    sb.append(s).append("\n");
  }
  LOG.info("Setting job diagnostics to " + sb.toString());

  String historyUrl =
      MRWebAppUtil.getApplicationWebURLOnJHSWithScheme(getConfig(),
          context.getApplicationID());
  LOG.info("History url is " + historyUrl);
  FinishApplicationMasterRequest request =
      FinishApplicationMasterRequest.newInstance(finishState,
        sb.toString(), historyUrl);
  try {
    while (true) {
      FinishApplicationMasterResponse response =
          scheduler.finishApplicationMaster(request);
      if (response.getIsUnregistered()) {
        // When excepting ClientService, other services are already stopped,
        // it is safe to let clients know the final states. ClientService
        // should wait for some time so clients have enough time to know the
        // final states.
        RunningAppContext raContext = (RunningAppContext) context;
        raContext.markSuccessfulUnregistration();
        break;
      }
      LOG.info("Waiting for application to be successfully unregistered.");
      Thread.sleep(rmPollInterval);
    }
  } catch (ApplicationMasterNotRegisteredException e) {
    // RM might have restarted or failed over and so lost the fact that AM had
    // registered before.
    register();
    doUnregistration();
  }
}