Package org.apache.hadoop.yarn.api.records

Examples of org.apache.hadoop.yarn.api.records.YarnApplicationState


    // go through the apps in RM to count the numbers, ignoring the case of
    // the state/type name
    ConcurrentMap<ApplicationId, RMApp> apps = rm.getRMContext().getRMApps();
    for (RMApp rmapp : apps.values()) {
      YarnApplicationState state = rmapp.createApplicationState();
      String type = rmapp.getApplicationType().trim().toLowerCase();
      if (states.contains(state.toString().toLowerCase())) {
        if (types.contains(ANY)) {
          countApp(scoreboard, state, ANY);
        } else if (types.contains(type)) {
          countApp(scoreboard, state, type);
        }
View Full Code Here


          + ", yarnAppState=" + report.getYarnApplicationState().toString()
          + ", distributedFinalState=" + report.getFinalApplicationStatus().toString()
          + ", appTrackingUrl=" + report.getTrackingUrl()
          + ", appUser=" + report.getUser());

      YarnApplicationState state = report.getYarnApplicationState();
      FinalApplicationStatus dsStatus = report.getFinalApplicationStatus();
      if (YarnApplicationState.FINISHED == state) {
        if (FinalApplicationStatus.SUCCEEDED == dsStatus) {
          LOG.info("Application has completed successfully. Breaking monitoring loop");
          return true;       
        }
        else {
          LOG.info("Application did finished unsuccessfully."
              + " YarnState=" + state.toString() + ", DSFinalStatus=" + dsStatus.toString()
              + ". Breaking monitoring loop");
          return false;
        }       
      }
      else if (YarnApplicationState.KILLED == state 
          || YarnApplicationState.FAILED == state) {
        LOG.info("Application did not finish."
            + " YarnState=" + state.toString() + ", DSFinalStatus=" + dsStatus.toString()
            + ". Breaking monitoring loop");
        return false;
      }     

      if (System.currentTimeMillis() > (clientStartTime + clientTimeout)) {
View Full Code Here

        boolean repeat = false;
    long start = System.currentTimeMillis();
        do {
            try {
                ApplicationReport appReport = client.getApplicationReport(appId);
                YarnApplicationState appState = appReport.getYarnApplicationState();
                repeat = (appState != YarnApplicationState.FINISHED && appState != YarnApplicationState.KILLED && appState != YarnApplicationState.FAILED);
                if (repeat) {
                    Thread.sleep(500);
                }
            } catch (Exception ex) {
View Full Code Here

    // go through the apps in RM to count the numbers, ignoring the case of
    // the state/type name
    ConcurrentMap<ApplicationId, RMApp> apps = rm.getRMContext().getRMApps();
    for (RMApp rmapp : apps.values()) {
      YarnApplicationState state = rmapp.createApplicationState();
      String type = rmapp.getApplicationType().trim().toLowerCase();
      if (states.contains(state.toString().toLowerCase())) {
        if (types.contains(ANY)) {
          countApp(scoreboard, state, ANY);
        } else if (types.contains(type)) {
          countApp(scoreboard, state, type);
        }
View Full Code Here

    int pollCount = 0;
    long startTime = System.currentTimeMillis();

    while (true) {
      try {
        YarnApplicationState state =
            getApplicationReport(applicationId).getYarnApplicationState();
        if (!state.equals(YarnApplicationState.NEW) &&
            !state.equals(YarnApplicationState.NEW_SAVING)) {
          LOG.info("Submitted application " + applicationId);
          break;
        }

        long elapsedMillis = System.currentTimeMillis() - startTime;
View Full Code Here

  private void verifySubmitApp(MockRM rm, RMApp app,
      ApplicationId expectedAppId) throws Exception {
    int maxWaittingTimes = 20;
    int count = 0;
    while (true) {
      YarnApplicationState state =
          rm.getApplicationReport(app.getApplicationId())
              .getYarnApplicationState();
      if (!state.equals(YarnApplicationState.NEW) &&
          !state.equals(YarnApplicationState.NEW_SAVING)) {
        break;
      }
      if (count > maxWaittingTimes) {
        break;
      }
      Thread.sleep(200);
      count++;
    }
    // Verify submittion is successful
    YarnApplicationState state =
        rm.getApplicationReport(app.getApplicationId())
            .getYarnApplicationState();
    Assert.assertTrue(state == YarnApplicationState.ACCEPTED
        || state == YarnApplicationState.SUBMITTED);
    Assert.assertEquals(expectedAppId, app.getApplicationId());
View Full Code Here

   */
  protected ApplicationInfo submitApplicationAndWaitState(long timeout, TimeUnit unit, YarnApplicationState... applicationStates) throws Exception {
    Assert.notEmpty(applicationStates, "Need to have atleast one state");
    Assert.notNull(getYarnClient(), "Yarn client must be set");

    YarnApplicationState state = null;
    ApplicationReport report = null;

    ApplicationId applicationId = submitApplication();
    Assert.notNull(applicationId, "Failed to get application id from submit");

    long end = System.currentTimeMillis() + unit.toMillis(timeout);

    // break label for inner loop
    done:
    do {
      report = findApplicationReport(getYarnClient(), applicationId);
      if (report == null) {
        break;
      }
      state = report.getYarnApplicationState();
      for (YarnApplicationState stateCheck : applicationStates) {
        if (state.equals(stateCheck)) {
          break done;
        }
      }
      Thread.sleep(1000);
    } while (System.currentTimeMillis() < end);
View Full Code Here

   */
  protected YarnApplicationState waitState(ApplicationId applicationId, long timeout, TimeUnit unit, YarnApplicationState... applicationStates) throws Exception {
    Assert.notNull(getYarnClient(), "Yarn client must be set");
    Assert.notNull(applicationId, "ApplicationId must not be null");

    YarnApplicationState state = null;
    long end = System.currentTimeMillis() + unit.toMillis(timeout);

    // break label for inner loop
    done:
    do {
      state = findState(getYarnClient(), applicationId);
      if (state == null) {
        break;
      }
      for (YarnApplicationState stateCheck : applicationStates) {
        if (state.equals(stateCheck)) {
          break done;
        }
      }
      Thread.sleep(1000);
    } while (System.currentTimeMillis() < end);
View Full Code Here

   * @param client the Yarn client
   * @param applicationId Yarn app application id
   * @return Current application state or <code>NULL</code> if not found
   */
  private YarnApplicationState findState(YarnClient client, ApplicationId applicationId) {
    YarnApplicationState state = null;
    for (ApplicationReport report : client.listApplications()) {
      if (report.getApplicationId().equals(applicationId)) {
        state = report.getYarnApplicationState();
        break;
      }
View Full Code Here

          + ", yarnAppState=" + report.getYarnApplicationState().toString()
          + ", distributedFinalState=" + report.getFinalApplicationStatus().toString()
          + ", appTrackingUrl=" + report.getTrackingUrl()
          + ", appUser=" + report.getUser());

      YarnApplicationState state = report.getYarnApplicationState();
      FinalApplicationStatus dsStatus = report.getFinalApplicationStatus();
      if (YarnApplicationState.FINISHED == state) {
        if (FinalApplicationStatus.SUCCEEDED == dsStatus) {
          LOG.info("Application has completed successfully. Breaking monitoring loop");
          return true;       
        }
        else {
          LOG.info("Application did finished unsuccessfully."
              + " YarnState=" + state.toString() + ", DSFinalStatus=" + dsStatus.toString()
              + ". Breaking monitoring loop");
          return false;
        }       
      }
      else if (YarnApplicationState.KILLED == state 
          || YarnApplicationState.FAILED == state) {
        LOG.info("Application did not finish."
            + " YarnState=" + state.toString() + ", DSFinalStatus=" + dsStatus.toString()
            + ". Breaking monitoring loop");
        return false;
      }     

      if (System.currentTimeMillis() > (clientStartTime + clientTimeout)) {
View Full Code Here

TOP

Related Classes of org.apache.hadoop.yarn.api.records.YarnApplicationState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.