當前位置: 首頁>>代碼示例>>Java>>正文


Java FinalApplicationStatus.SUCCEEDED屬性代碼示例

本文整理匯總了Java中org.apache.hadoop.yarn.api.records.FinalApplicationStatus.SUCCEEDED屬性的典型用法代碼示例。如果您正苦於以下問題:Java FinalApplicationStatus.SUCCEEDED屬性的具體用法?Java FinalApplicationStatus.SUCCEEDED怎麽用?Java FinalApplicationStatus.SUCCEEDED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.hadoop.yarn.api.records.FinalApplicationStatus的用法示例。


在下文中一共展示了FinalApplicationStatus.SUCCEEDED屬性的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testFinishingExpire

@Test
public void testFinishingExpire() {
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false);
  FinalApplicationStatus finalStatus = FinalApplicationStatus.SUCCEEDED;
  String trackingUrl = "mytrackingurl";
  String diagnostics = "Successful";
  unregisterApplicationAttempt(amContainer, finalStatus, trackingUrl,
      diagnostics);
  applicationAttempt.handle(
      new RMAppAttemptEvent(
          applicationAttempt.getAppAttemptId(),
          RMAppAttemptEventType.EXPIRE));
  testAppAttemptFinishedState(amContainer, finalStatus, trackingUrl,
      diagnostics, 0, false);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:TestRMAppAttemptTransitions.java

示例2: testFinishingToFinishing

@Test
public void testFinishingToFinishing() {
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false);
  FinalApplicationStatus finalStatus = FinalApplicationStatus.SUCCEEDED;
  String trackingUrl = "mytrackingurl";
  String diagnostics = "Successful";
  unregisterApplicationAttempt(amContainer, finalStatus, trackingUrl,
      diagnostics);
  // container must be AM container to move from FINISHING to FINISHED
  NodeId anyNodeId = NodeId.newInstance("host", 1234);
  applicationAttempt.handle(
      new RMAppAttemptContainerFinishedEvent(
          applicationAttempt.getAppAttemptId(),
          BuilderUtils.newContainerStatus(
              BuilderUtils.newContainerId(
                  applicationAttempt.getAppAttemptId(), 42),
              ContainerState.COMPLETE, "", 0), anyNodeId));
  testAppAttemptFinishingState(amContainer, finalStatus, trackingUrl,
      diagnostics);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:22,代碼來源:TestRMAppAttemptTransitions.java

示例3: testSuccessfulFinishingToFinished

@Test
public void testSuccessfulFinishingToFinished() {
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false);
  FinalApplicationStatus finalStatus = FinalApplicationStatus.SUCCEEDED;
  String trackingUrl = "mytrackingurl";
  String diagnostics = "Successful";
  unregisterApplicationAttempt(amContainer, finalStatus, trackingUrl,
      diagnostics);
  NodeId anyNodeId = NodeId.newInstance("host", 1234);
  applicationAttempt.handle(
      new RMAppAttemptContainerFinishedEvent(
          applicationAttempt.getAppAttemptId(),
          BuilderUtils.newContainerStatus(amContainer.getId(),
              ContainerState.COMPLETE, "", 0), anyNodeId));
  testAppAttemptFinishedState(amContainer, finalStatus, trackingUrl,
      diagnostics, 0, false);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:19,代碼來源:TestRMAppAttemptTransitions.java

示例4: testFinalSavingToFinishedWithExpire

@Test
public void testFinalSavingToFinishedWithExpire() {
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false);
  FinalApplicationStatus finalStatus = FinalApplicationStatus.SUCCEEDED;
  String trackingUrl = "mytrackingurl";
  String diagnostics = "Successssseeeful";
  applicationAttempt.handle(new RMAppAttemptUnregistrationEvent(
    applicationAttempt.getAppAttemptId(), trackingUrl, finalStatus,
    diagnostics));
  assertEquals(RMAppAttemptState.FINAL_SAVING,
    applicationAttempt.getAppAttemptState());
  assertEquals(YarnApplicationAttemptState.RUNNING,
      applicationAttempt.createApplicationAttemptState());
  // Expire event comes before Attempt_saved event.
  applicationAttempt.handle(new RMAppAttemptEvent(applicationAttempt
    .getAppAttemptId(), RMAppAttemptEventType.EXPIRE));
  assertEquals(RMAppAttemptState.FINAL_SAVING,
    applicationAttempt.getAppAttemptState());
  // send attempt_saved
  sendAttemptUpdateSavedEvent(applicationAttempt);
  testAppAttemptFinishedState(amContainer, finalStatus, trackingUrl,
    diagnostics, 0, false);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:25,代碼來源:TestRMAppAttemptTransitions.java

示例5: fromYarn

public static State fromYarn(YarnApplicationState yarnApplicationState,
    FinalApplicationStatus finalApplicationStatus) {
  switch (yarnApplicationState) {
  case NEW:
  case NEW_SAVING:
  case SUBMITTED:
  case ACCEPTED:
    return State.PREP;
  case RUNNING:
    return State.RUNNING;
  case FINISHED:
    if (finalApplicationStatus == FinalApplicationStatus.SUCCEEDED) {
      return State.SUCCEEDED;
    } else if (finalApplicationStatus == FinalApplicationStatus.KILLED) {
      return State.KILLED;
    }
  case FAILED:
    return State.FAILED;
  case KILLED:
    return State.KILLED;
  }
  throw new YarnRuntimeException("Unrecognized application state: " + yarnApplicationState);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:23,代碼來源:TypeConverter.java

示例6: getFinalAppStatus

private FinalApplicationStatus getFinalAppStatus() {
  if (completedContainerNum.get() - failedContainerNum.get() >= args.totalContainerNum) {
    return FinalApplicationStatus.SUCCEEDED;
  } else {
    return FinalApplicationStatus.FAILED;
  }
}
 
開發者ID:Intel-bigdata,項目名稱:TensorFlowOnYARN,代碼行數:7,代碼來源:ApplicationMaster.java

示例7: testUnmanagedAMSuccess

private void testUnmanagedAMSuccess(String url) {
  unmanagedAM = true;
  when(submissionContext.getUnmanagedAM()).thenReturn(true);
  // submit AM and check it goes to LAUNCHED state
  scheduleApplicationAttempt();
  testAppAttemptLaunchedState(null);
  verify(amLivelinessMonitor, times(1)).register(
      applicationAttempt.getAppAttemptId());

  // launch AM
  runApplicationAttempt(null, "host", 8042, url, true);

  // complete a container
  Container container = mock(Container.class);
  when(container.getNodeId()).thenReturn(NodeId.newInstance("host", 1234));
  application.handle(new RMAppRunningOnNodeEvent(application.getApplicationId(),
      container.getNodeId()));
  applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent(
      applicationAttempt.getAppAttemptId(), mock(ContainerStatus.class),
      container.getNodeId()));
  // complete AM
  String diagnostics = "Successful";
  FinalApplicationStatus finalStatus = FinalApplicationStatus.SUCCEEDED;
  applicationAttempt.handle(new RMAppAttemptUnregistrationEvent(
      applicationAttempt.getAppAttemptId(), url, finalStatus,
      diagnostics));
  testAppAttemptFinishedState(null, finalStatus, url, diagnostics, 1,
      true);
  assertFalse(transferStateFromPreviousAttempt);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:30,代碼來源:TestRMAppAttemptTransitions.java

示例8: testFinalSavingToFinishedWithContainerFinished

@Test
public void
    testFinalSavingToFinishedWithContainerFinished() {
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false);
  FinalApplicationStatus finalStatus = FinalApplicationStatus.SUCCEEDED;
  String trackingUrl = "mytrackingurl";
  String diagnostics = "Successful";
  applicationAttempt.handle(new RMAppAttemptUnregistrationEvent(
    applicationAttempt.getAppAttemptId(), trackingUrl, finalStatus,
    diagnostics));
  assertEquals(RMAppAttemptState.FINAL_SAVING,
    applicationAttempt.getAppAttemptState());
  assertEquals(YarnApplicationAttemptState.RUNNING,
      applicationAttempt.createApplicationAttemptState());
  // Container_finished event comes before Attempt_Saved event.
  NodeId anyNodeId = NodeId.newInstance("host", 1234);
  applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent(
    applicationAttempt.getAppAttemptId(), BuilderUtils.newContainerStatus(
      amContainer.getId(), ContainerState.COMPLETE, "", 0), anyNodeId));
  assertEquals(RMAppAttemptState.FINAL_SAVING,
    applicationAttempt.getAppAttemptState());
  // send attempt_saved
  sendAttemptUpdateSavedEvent(applicationAttempt);
  testAppAttemptFinishedState(amContainer, finalStatus, trackingUrl,
    diagnostics, 0, false);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:28,代碼來源:TestRMAppAttemptTransitions.java

示例9: monitorApplication

/**
 * Monitor the submitted application for completion. 
 * Kill application if time expires. 
 * @param appId Application Id of application to be monitored
 * @return true if application completed successfully
 * @throws YarnException
 * @throws IOException
 */
private boolean monitorApplication(ApplicationId appId)
    throws YarnException, IOException {

  while (true) {

    // Check app status every 1 second.
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      LOG.debug("Thread sleep in monitoring loop interrupted");
    }

    // 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()
        + ", clientToAMToken=" + 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();
    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)) {
      LOG.info("Reached client specified timeout for application. Killing application");
      forceKillApplication(appId);
      return false;				
    }
  }			

}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:66,代碼來源:Client.java

示例10: run

public boolean run() throws IOException, YarnException {
  LOG.info("Starting Client");
  
  // Connect to ResourceManager
  rmClient.start();
  try {  
    // Create launch context for app master
    LOG.info("Setting up application submission context for ASM");
    ApplicationSubmissionContext appContext = rmClient.createApplication()
        .getApplicationSubmissionContext();
    ApplicationId appId = appContext.getApplicationId();

    // set the application name
    appContext.setApplicationName(appName);

    // Set the priority for the application master
    Priority pri = Records.newRecord(Priority.class);
    pri.setPriority(amPriority);
    appContext.setPriority(pri);

    // Set the queue to which this application is to be submitted in the RM
    appContext.setQueue(amQueue);

    // Set up the container launch context for the application master
    ContainerLaunchContext amContainer = Records
        .newRecord(ContainerLaunchContext.class);
    appContext.setAMContainerSpec(amContainer);

    // unmanaged AM
    appContext.setUnmanagedAM(true);
    LOG.info("Setting unmanaged AM");

    // Submit the application to the applications manager
    LOG.info("Submitting application to ASM");
    rmClient.submitApplication(appContext);

    ApplicationReport appReport =
        monitorApplication(appId, EnumSet.of(YarnApplicationState.ACCEPTED,
          YarnApplicationState.KILLED, YarnApplicationState.FAILED,
          YarnApplicationState.FINISHED));

    if (appReport.getYarnApplicationState() == YarnApplicationState.ACCEPTED) {
      // Monitor the application attempt to wait for launch state
      ApplicationAttemptReport attemptReport =
          monitorCurrentAppAttempt(appId,
            YarnApplicationAttemptState.LAUNCHED);
      ApplicationAttemptId attemptId =
          attemptReport.getApplicationAttemptId();
      LOG.info("Launching AM with application attempt id " + attemptId);
      // launch AM
      launchAM(attemptId);
      // Monitor the application for end state
      appReport =
          monitorApplication(appId, EnumSet.of(YarnApplicationState.KILLED,
            YarnApplicationState.FAILED, YarnApplicationState.FINISHED));
    }

    YarnApplicationState appState = appReport.getYarnApplicationState();
    FinalApplicationStatus appStatus = appReport.getFinalApplicationStatus();

    LOG.info("App ended with state: " + appReport.getYarnApplicationState()
        + " and status: " + appStatus);
    
    boolean success;
    if (YarnApplicationState.FINISHED == appState
        && FinalApplicationStatus.SUCCEEDED == appStatus) {
      LOG.info("Application has completed successfully.");
      success = true;
    } else {
      LOG.info("Application did finished unsuccessfully." + " YarnState="
          + appState.toString() + ", FinalStatus=" + appStatus.toString());
      success = false;
    }
    
    return success;
  } finally {
    rmClient.stop();
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:79,代碼來源:UnmanagedAMLauncher.java

示例11: doUnregistration

@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();
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:50,代碼來源:RMCommunicator.java


注:本文中的org.apache.hadoop.yarn.api.records.FinalApplicationStatus.SUCCEEDED屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。