Java 类org.apache.hadoop.yarn.api.records.FinalApplicationStatus 实例源码

项目:hadoop    文件:TestResourceMgrDelegate.java   
@Test
public void tesAllJobs() throws Exception {
  final ApplicationClientProtocol applicationsManager = Mockito.mock(ApplicationClientProtocol.class);
  GetApplicationsResponse allApplicationsResponse = Records
      .newRecord(GetApplicationsResponse.class);
  List<ApplicationReport> applications = new ArrayList<ApplicationReport>();
  applications.add(getApplicationReport(YarnApplicationState.FINISHED,
      FinalApplicationStatus.FAILED));
  applications.add(getApplicationReport(YarnApplicationState.FINISHED,
      FinalApplicationStatus.SUCCEEDED));
  applications.add(getApplicationReport(YarnApplicationState.FINISHED,
      FinalApplicationStatus.KILLED));
  applications.add(getApplicationReport(YarnApplicationState.FAILED,
      FinalApplicationStatus.FAILED));
  allApplicationsResponse.setApplicationList(applications);
  Mockito.when(
      applicationsManager.getApplications(Mockito
          .any(GetApplicationsRequest.class))).thenReturn(
      allApplicationsResponse);
  ResourceMgrDelegate resourceMgrDelegate = new ResourceMgrDelegate(
    new YarnConfiguration()) {
    @Override
    protected void serviceStart() throws Exception {
      Assert.assertTrue(this.client instanceof YarnClientImpl);
      ((YarnClientImpl) this.client).setRMClient(applicationsManager);
    }
  };
  JobStatus[] allJobs = resourceMgrDelegate.getAllJobs();

  Assert.assertEquals(State.FAILED, allJobs[0].getState());
  Assert.assertEquals(State.SUCCEEDED, allJobs[1].getState());
  Assert.assertEquals(State.KILLED, allJobs[2].getState());
  Assert.assertEquals(State.FAILED, allJobs[3].getState());
}
项目:hadoop    文件:ApplicationFinishedEvent.java   
public ApplicationFinishedEvent(
    ApplicationId appId,
    String diagnosticsInfo,
    FinalApplicationStatus appStatus,
    YarnApplicationState state,
    ApplicationAttemptId latestAppAttemptId,
    long finishedTime,
    RMAppMetrics appMetrics) {
  super(SystemMetricsEventType.APP_FINISHED, finishedTime);
  this.appId = appId;
  this.diagnosticsInfo = diagnosticsInfo;
  this.appStatus = appStatus;
  this.latestAppAttemptId = latestAppAttemptId;
  this.state = state;
  this.appMetrics=appMetrics;
}
项目:hadoop    文件:RMAppImpl.java   
@Override
public FinalApplicationStatus getFinalApplicationStatus() {
  this.readLock.lock();
  try {
    // finish state is obtained based on the state machine's current state 
    // as a fall-back in case the application has not been unregistered 
    // ( or if the app never unregistered itself )
    // when the report is requested
    if (currentAttempt != null 
        && currentAttempt.getFinalApplicationStatus() != null) {
      return currentAttempt.getFinalApplicationStatus();   
    }
    return 
        createFinalApplicationStatus(this.stateMachine.getCurrentState());
  } finally {
    this.readLock.unlock();
  }
}
项目:hadoop    文件:RMAppImpl.java   
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!");
}
项目:hadoop    文件:ApplicationAttemptStateData.java   
public static ApplicationAttemptStateData newInstance(
    ApplicationAttemptId attemptId, Container container,
    Credentials attemptTokens, long startTime, RMAppAttemptState finalState,
    String finalTrackingUrl, String diagnostics,
    FinalApplicationStatus amUnregisteredFinalStatus, int exitStatus,
    long finishTime, long memorySeconds, long vcoreSeconds, long gcoreSeconds) {
  ApplicationAttemptStateData attemptStateData =
      Records.newRecord(ApplicationAttemptStateData.class);
  attemptStateData.setAttemptId(attemptId);
  attemptStateData.setMasterContainer(container);
  attemptStateData.setAppAttemptTokens(attemptTokens);
  attemptStateData.setState(finalState);
  attemptStateData.setFinalTrackingUrl(finalTrackingUrl);
  attemptStateData.setDiagnostics(diagnostics == null ? "" : diagnostics);
  attemptStateData.setStartTime(startTime);
  attemptStateData.setFinalApplicationStatus(amUnregisteredFinalStatus);
  attemptStateData.setAMContainerExitStatus(exitStatus);
  attemptStateData.setFinishTime(finishTime);
  attemptStateData.setMemorySeconds(memorySeconds);
  attemptStateData.setVcoreSeconds(vcoreSeconds);
  attemptStateData.setGcoreSeconds(gcoreSeconds);
  return attemptStateData;
}
项目:hadoop    文件:ApplicationAttemptStateDataPBImpl.java   
@Override
public FinalApplicationStatus getFinalApplicationStatus() {
  ApplicationAttemptStateDataProtoOrBuilder p = viaProto ? proto : builder;
  if (!p.hasFinalApplicationStatus()) {
    return null;
  }
  return convertFromProtoFormat(p.getFinalApplicationStatus());
}
项目:hadoop    文件:TestRMWebServicesApps.java   
@Test
public void testAppsQueryFinalStatus() throws JSONException, Exception {
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  RMApp app1 = rm.submitApp(CONTAINER_MB);
  amNodeManager.nodeHeartbeat(true);
  WebResource r = resource();

  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("apps").queryParam("finalStatus", FinalApplicationStatus.UNDEFINED.toString())
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  System.out.println(json.toString());
  JSONObject apps = json.getJSONObject("apps");
  assertEquals("incorrect number of elements", 1, apps.length());
  JSONArray array = apps.getJSONArray("app");
  assertEquals("incorrect number of elements", 1, array.length());
  verifyAppInfo(array.getJSONObject(0), app1);
  rm.stop();
}
项目:hadoop    文件:TestRMWebServicesApps.java   
@Test
public void testAppsQueryFinalStatusNone() throws JSONException, Exception {
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  rm.submitApp(CONTAINER_MB);
  amNodeManager.nodeHeartbeat(true);
  WebResource r = resource();

  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("apps").queryParam("finalStatus", FinalApplicationStatus.KILLED.toString())
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  assertEquals("apps is not null", JSONObject.NULL, json.get("apps"));
  rm.stop();
}
项目:hadoop    文件:TestSystemMetricsPublisher.java   
private static RMApp createRMApp(ApplicationId appId) {
  RMApp app = mock(RMApp.class);
  when(app.getApplicationId()).thenReturn(appId);
  when(app.getName()).thenReturn("test app");
  when(app.getApplicationType()).thenReturn("test app type");
  when(app.getUser()).thenReturn("test user");
  when(app.getQueue()).thenReturn("test queue");
  when(app.getSubmitTime()).thenReturn(Integer.MAX_VALUE + 1L);
  when(app.getStartTime()).thenReturn(Integer.MAX_VALUE + 2L);
  when(app.getFinishTime()).thenReturn(Integer.MAX_VALUE + 3L);
  when(app.getDiagnostics()).thenReturn(
      new StringBuilder("test diagnostics info"));
  RMAppAttempt appAttempt = mock(RMAppAttempt.class);
  when(appAttempt.getAppAttemptId()).thenReturn(
      ApplicationAttemptId.newInstance(appId, 1));
  when(app.getCurrentAppAttempt()).thenReturn(appAttempt);
  when(app.getFinalApplicationStatus()).thenReturn(
      FinalApplicationStatus.UNDEFINED);
  when(app.getRMAppMetrics()).thenReturn(
      new RMAppMetrics(null, 0, 0, Integer.MAX_VALUE, Long.MAX_VALUE, Long.MAX_VALUE));
  return app;
}
项目:scheduling-connector-for-hadoop    文件:SlurmApplicationClient.java   
@Override
public ApplicationReport getApplicationReport(ApplicationId applicationId)
    throws IOException {
  List<ApplicationReport> reports = null;
  try {
    reports = getApplications(applicationId.getId());
  } catch (Throwable e) {
    LOG.info("Couldn't get application report for " + applicationId
        + ", might be completed already.");
  }
  if (reports == null || reports.isEmpty()) {
    return ApplicationReport.newInstance(applicationId, null, "", "default",
        "", "", 0, null, YarnApplicationState.FINISHED, "", "", 0, 0,
        FinalApplicationStatus.SUCCEEDED, null, "", 100, null, null);
  }
  return reports.get(0);
}
项目:hadoop    文件:TestRMApplicationHistoryWriter.java   
private static RMApp createRMApp(ApplicationId appId) {
  RMApp app = mock(RMApp.class);
  when(app.getApplicationId()).thenReturn(appId);
  when(app.getName()).thenReturn("test app");
  when(app.getApplicationType()).thenReturn("test app type");
  when(app.getUser()).thenReturn("test user");
  when(app.getQueue()).thenReturn("test queue");
  when(app.getSubmitTime()).thenReturn(0L);
  when(app.getStartTime()).thenReturn(1L);
  when(app.getFinishTime()).thenReturn(2L);
  when(app.getDiagnostics()).thenReturn(
    new StringBuilder("test diagnostics info"));
  when(app.getFinalApplicationStatus()).thenReturn(
    FinalApplicationStatus.UNDEFINED);
  return app;
}
项目:hadoop    文件:TestTypeConverter.java   
@Test
public void testEnums() throws Exception {
  for (YarnApplicationState applicationState : YarnApplicationState.values()) {
    TypeConverter.fromYarn(applicationState, FinalApplicationStatus.FAILED);
  }
  // ad hoc test of NEW_SAVING, which is newly added
  Assert.assertEquals(State.PREP, TypeConverter.fromYarn(
      YarnApplicationState.NEW_SAVING, FinalApplicationStatus.FAILED));

  for (TaskType taskType : TaskType.values()) {
    TypeConverter.fromYarn(taskType);
  }

  for (JobState jobState : JobState.values()) {
    TypeConverter.fromYarn(jobState);
  }

  for (QueueState queueState : QueueState.values()) {
    TypeConverter.fromYarn(queueState);
  }

  for (TaskState taskState : TaskState.values()) {
    TypeConverter.fromYarn(taskState);
  }
}
项目:hadoop    文件:TestRMAppTransitions.java   
protected RMApp testCreateAppFinished(
    ApplicationSubmissionContext submissionContext,
    String diagnostics) throws IOException {
  // unmanaged AMs don't use the FINISHING state
  RMApp application = null;
  if (submissionContext != null && submissionContext.getUnmanagedAM()) {
    application = testCreateAppRunning(submissionContext);
  } else {
    application = testCreateAppFinishing(submissionContext);
  }
  // RUNNING/FINISHING => FINISHED event RMAppEventType.ATTEMPT_FINISHED
  RMAppEvent finishedEvent = new RMAppFinishedAttemptEvent(
      application.getApplicationId(), diagnostics);
  application.handle(finishedEvent);
  assertAppState(RMAppState.FINISHED, application);
  assertTimesAtFinish(application);
  // finished without a proper unregister implies failed
  assertFinalAppStatus(FinalApplicationStatus.FAILED, application);
  Assert.assertTrue("Finished app missing diagnostics",
      application.getDiagnostics().indexOf(diagnostics) != -1);
  return application;
}
项目:hadoop    文件:TestRMAppTransitions.java   
@Test
public void testAppFinalSavingToFinished() throws IOException {
  LOG.info("--- START: testAppFinalSavingToFinished ---");

  RMApp application = testCreateAppFinalSaving(null);
  final String diagMsg = "some diagnostics";
  // attempt_finished event comes before attempt_saved event
  RMAppEvent event =
      new RMAppFinishedAttemptEvent(application.getApplicationId(), diagMsg);
  application.handle(event);
  assertAppState(RMAppState.FINAL_SAVING, application);
  RMAppEvent appUpdated =
      new RMAppEvent(application.getApplicationId(), RMAppEventType.APP_UPDATE_SAVED);
  application.handle(appUpdated);
  assertAppState(RMAppState.FINISHED, application);

  assertTimesAtFinish(application);
  // finished without a proper unregister implies failed
  assertFinalAppStatus(FinalApplicationStatus.FAILED, application);
  Assert.assertTrue("Finished app missing diagnostics", application
    .getDiagnostics().indexOf(diagMsg) != -1);
}
项目:hadoop    文件:TestResourceMgrDelegate.java   
private ApplicationReport getApplicationReport(
    YarnApplicationState yarnApplicationState,
    FinalApplicationStatus finalApplicationStatus) {
  ApplicationReport appReport = Mockito.mock(ApplicationReport.class);
  ApplicationResourceUsageReport appResources = Mockito
      .mock(ApplicationResourceUsageReport.class);
  Mockito.when(appReport.getApplicationId()).thenReturn(
      ApplicationId.newInstance(0, 0));
  Mockito.when(appResources.getNeededResources()).thenReturn(
      Records.newRecord(Resource.class));
  Mockito.when(appResources.getReservedResources()).thenReturn(
      Records.newRecord(Resource.class));
  Mockito.when(appResources.getUsedResources()).thenReturn(
      Records.newRecord(Resource.class));
  Mockito.when(appReport.getApplicationResourceUsageReport()).thenReturn(
      appResources);
  Mockito.when(appReport.getYarnApplicationState()).thenReturn(
      yarnApplicationState);
  Mockito.when(appReport.getFinalApplicationStatus()).thenReturn(
      finalApplicationStatus);

  return appReport;
}
项目:hadoop    文件:TestRMAppAttemptTransitions.java   
/**
 * {@link RMAppAttemptState#FINISHING}
 */
private void testAppAttemptFinishingState(Container container,
    FinalApplicationStatus finalStatus,
    String trackingUrl,
    String diagnostics) {
  assertEquals(RMAppAttemptState.FINISHING,
      applicationAttempt.getAppAttemptState());
  assertEquals(diagnostics, applicationAttempt.getDiagnostics());
  verifyUrl(trackingUrl, applicationAttempt.getOriginalTrackingUrl());
  assertEquals(getProxyUrl(applicationAttempt),
      applicationAttempt.getTrackingUrl());
  assertEquals(container, applicationAttempt.getMasterContainer());
  assertEquals(finalStatus, applicationAttempt.getFinalApplicationStatus());
  verifyTokenCount(applicationAttempt.getAppAttemptId(), 0);
  verifyAttemptFinalStateSaved();
}
项目:hadoop    文件:TestRMAppAttemptTransitions.java   
@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);
}
项目:hadoop    文件:TestNMClient.java   
@Test (timeout = 180000)
public void testNMClientNoCleanupOnStop()
    throws YarnException, IOException {

  rmClient.registerApplicationMaster("Host", 10000, "");

  testContainerManagement(nmClient, allocateContainers(rmClient, 5));

  rmClient.unregisterApplicationMaster(FinalApplicationStatus.SUCCEEDED,
                                       null, null);
  // don't stop the running containers
  stopNmClient(false);
  assertFalse(nmClient.startedContainers. isEmpty());
  //now cleanup
  nmClient.cleanupRunningContainers();
  assertEquals(0, nmClient.startedContainers.size());
}
项目:hadoop    文件:TestRMAppAttemptTransitions.java   
@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);
}
项目:hadoop    文件:TestRMAppAttemptTransitions.java   
@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);
}
项目:hadoop    文件:TestRMAppAttemptTransitions.java   
@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);
}
项目:hadoop    文件:ApplicationAttemptHistoryData.java   
@Public
@Unstable
public static ApplicationAttemptHistoryData newInstance(
    ApplicationAttemptId appAttemptId, String host, int rpcPort,
    ContainerId masterContainerId, String diagnosticsInfo,
    String trackingURL, FinalApplicationStatus finalApplicationStatus,
    YarnApplicationAttemptState yarnApplicationAttemptState) {
  ApplicationAttemptHistoryData appAttemptHD =
      new ApplicationAttemptHistoryData();
  appAttemptHD.setApplicationAttemptId(appAttemptId);
  appAttemptHD.setHost(host);
  appAttemptHD.setRPCPort(rpcPort);
  appAttemptHD.setMasterContainerId(masterContainerId);
  appAttemptHD.setDiagnosticsInfo(diagnosticsInfo);
  appAttemptHD.setTrackingURL(trackingURL);
  appAttemptHD.setFinalApplicationStatus(finalApplicationStatus);
  appAttemptHD.setYarnApplicationAttemptState(yarnApplicationAttemptState);
  return appAttemptHD;
}
项目:hadoop    文件:TestAHSWebServices.java   
@Test
public void testSingleApp() throws Exception {
  ApplicationId appId = ApplicationId.newInstance(0, 1);
  WebResource r = resource();
  ClientResponse response =
      r.path("ws").path("v1").path("applicationhistory").path("apps")
        .path(appId.toString())
        .queryParam("user.name", USERS[round])
        .accept(MediaType.APPLICATION_JSON)
        .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject app = json.getJSONObject("app");
  assertEquals(appId.toString(), app.getString("appId"));
  assertEquals("test app", app.get("name"));
  assertEquals(round == 0 ? "test diagnostics info" : "",
      app.get("diagnosticsInfo"));
  assertEquals("test queue", app.get("queue"));
  assertEquals("user1", app.get("user"));
  assertEquals("test app type", app.get("type"));
  assertEquals(FinalApplicationStatus.UNDEFINED.toString(),
    app.get("finalAppStatus"));
  assertEquals(YarnApplicationState.FINISHED.toString(), app.get("appState"));
}
项目:TensorFlowOnYARN    文件:ApplicationMaster.java   
private FinalApplicationStatus getFinalAppStatus() {
  if (completedContainerNum.get() - failedContainerNum.get() >= args.totalContainerNum) {
    return FinalApplicationStatus.SUCCEEDED;
  } else {
    return FinalApplicationStatus.FAILED;
  }
}
项目:hadoop    文件:FinishApplicationMasterRequestPBImpl.java   
@Override
public FinalApplicationStatus getFinalApplicationStatus() {
  FinishApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder;
  if (!p.hasFinalApplicationStatus()) {
    return null;
  } 
  return convertFromProtoFormat(p.getFinalApplicationStatus());
}
项目:hadoop    文件:FinishApplicationMasterRequestPBImpl.java   
@Override
public void setFinalApplicationStatus(FinalApplicationStatus finalState) {
  maybeInitBuilder();
  if (finalState == null) {
    builder.clearFinalApplicationStatus();
    return;
  }
  builder.setFinalApplicationStatus(convertToProtoFormat(finalState));
}
项目:hadoop    文件:AMRMClientAsyncImpl.java   
/**
 * Unregister the application master. This must be called in the end.
 * @param appStatus Success/Failure status of the master
 * @param appMessage Diagnostics message on failure
 * @param appTrackingUrl New URL to get master info
 * @throws YarnException
 * @throws IOException
 */
public void unregisterApplicationMaster(FinalApplicationStatus appStatus,
    String appMessage, String appTrackingUrl) throws YarnException,
    IOException {
  synchronized (unregisterHeartbeatLock) {
    keepRunning = false;
    client.unregisterApplicationMaster(appStatus, appMessage, appTrackingUrl);
  }
}
项目:hadoop    文件:ApplicationReportPBImpl.java   
@Override
public FinalApplicationStatus getFinalApplicationStatus() {
  ApplicationReportProtoOrBuilder p = viaProto ? proto : builder;
  if (!p.hasFinalApplicationStatus()) {
    return null;
  } 
  return convertFromProtoFormat(p.getFinalApplicationStatus());
}
项目:hadoop    文件:ApplicationReportPBImpl.java   
@Override
public void setFinalApplicationStatus(FinalApplicationStatus finishState) {
  maybeInitBuilder();
  if (finishState == null) {
    builder.clearFinalApplicationStatus();
    return;
  }
  builder.setFinalApplicationStatus(convertToProtoFormat(finishState));
}
项目:hadoop    文件:TestApplicatonReport.java   
protected static ApplicationReport createApplicationReport(
    int appIdInt, int appAttemptIdInt, long timestamp) {
  ApplicationId appId = ApplicationId.newInstance(timestamp, appIdInt);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, appAttemptIdInt);
  ApplicationReport appReport =
      ApplicationReport.newInstance(appId, appAttemptId, "user", "queue",
        "appname", "host", 124, null, YarnApplicationState.FINISHED,
        "diagnostics", "url", 0, 0, FinalApplicationStatus.SUCCEEDED, null,
        "N/A", 0.53789f, YarnConfiguration.DEFAULT_APPLICATION_TYPE, null);
  return appReport;
}
项目:hadoop    文件:BuilderUtils.java   
public static ApplicationReport newApplicationReport(
    ApplicationId applicationId, ApplicationAttemptId applicationAttemptId,
    String user, String queue, String name, String host, int rpcPort,
    Token clientToAMToken, YarnApplicationState state, String diagnostics,
    String url, long startTime, long finishTime,
    FinalApplicationStatus finalStatus,
    ApplicationResourceUsageReport appResources, String origTrackingUrl,
    float progress, String appType, Token amRmToken, Set<String> tags) {
  ApplicationReport report = recordFactory
      .newRecordInstance(ApplicationReport.class);
  report.setApplicationId(applicationId);
  report.setCurrentApplicationAttemptId(applicationAttemptId);
  report.setUser(user);
  report.setQueue(queue);
  report.setName(name);
  report.setHost(host);
  report.setRpcPort(rpcPort);
  report.setClientToAMToken(clientToAMToken);
  report.setYarnApplicationState(state);
  report.setDiagnostics(diagnostics);
  report.setTrackingUrl(url);
  report.setStartTime(startTime);
  report.setFinishTime(finishTime);
  report.setFinalApplicationStatus(finalStatus);
  report.setApplicationResourceUsageReport(appResources);
  report.setOriginalTrackingUrl(origTrackingUrl);
  report.setProgress(progress);
  report.setApplicationType(appType);
  report.setAMRMToken(amRmToken);
  report.setApplicationTags(tags);
  return report;
}
项目:hadoop    文件:TestClientServiceDelegate.java   
private ApplicationReport getRunningApplicationReport(String host, int port) {
  ApplicationId appId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(
      appId, 0);
  return ApplicationReport.newInstance(appId, attemptId, "user", "queue",
    "appname", host, port, null, YarnApplicationState.RUNNING, "diagnostics",
    "url", 0, 0, FinalApplicationStatus.UNDEFINED, null, "N/A", 0.0f,
    YarnConfiguration.DEFAULT_APPLICATION_TYPE, null);
}
项目:hadoop    文件:NotRunningJob.java   
private ApplicationReport getUnknownApplicationReport() {
  ApplicationId unknownAppId = recordFactory
      .newRecordInstance(ApplicationId.class);
  ApplicationAttemptId unknownAttemptId = recordFactory
      .newRecordInstance(ApplicationAttemptId.class);

  // Setting AppState to NEW and finalStatus to UNDEFINED as they are never
  // used for a non running job
  return ApplicationReport.newInstance(unknownAppId, unknownAttemptId,
    "N/A", "N/A", "N/A", "N/A", 0, null, YarnApplicationState.NEW, "N/A",
    "N/A", 0, 0, FinalApplicationStatus.UNDEFINED, null, "N/A", 0.0f,
    YarnConfiguration.DEFAULT_APPLICATION_TYPE, null);
}
项目:hadoop    文件:TestClientRedirect.java   
@Override
public GetApplicationReportResponse getApplicationReport(
    GetApplicationReportRequest request) throws IOException {
  ApplicationId applicationId = request.getApplicationId();
  ApplicationReport application = recordFactory
      .newRecordInstance(ApplicationReport.class);
  application.setApplicationId(applicationId);
  application.setFinalApplicationStatus(FinalApplicationStatus.UNDEFINED);
  if (amRunning) {
    application.setYarnApplicationState(YarnApplicationState.RUNNING);
  } else if (amRestarting) {
    application.setYarnApplicationState(YarnApplicationState.SUBMITTED);
  } else {
    application.setYarnApplicationState(YarnApplicationState.FINISHED);
    application.setFinalApplicationStatus(FinalApplicationStatus.SUCCEEDED);
  }
  String[] split = AMHOSTADDRESS.split(":");
  application.setHost(split[0]);
  application.setRpcPort(Integer.parseInt(split[1]));
  application.setUser("TestClientRedirect-user");
  application.setName("N/A");
  application.setQueue("N/A");
  application.setStartTime(0);
  application.setFinishTime(0);
  application.setTrackingUrl("N/A");
  application.setDiagnostics("N/A");

  GetApplicationReportResponse response = recordFactory
      .newRecordInstance(GetApplicationReportResponse.class);
  response.setApplicationReport(application);
  return response;
}
项目:hadoop    文件:RMAppAttemptUnregistrationEvent.java   
public RMAppAttemptUnregistrationEvent(ApplicationAttemptId appAttemptId,
    String trackingUrl, FinalApplicationStatus finalStatus, String diagnostics) {
  super(appAttemptId, RMAppAttemptEventType.UNREGISTERED);
  this.finalTrackingUrl = trackingUrl;
  this.finalStatus = finalStatus;
  this.diagnostics = diagnostics;
}
项目:hadoop    文件:ApplicationAttemptStateDataPBImpl.java   
@Override
public void setFinalApplicationStatus(FinalApplicationStatus finishState) {
  maybeInitBuilder();
  if (finishState == null) {
    builder.clearFinalApplicationStatus();
    return;
  }
  builder.setFinalApplicationStatus(convertToProtoFormat(finishState));
}
项目:hadoop    文件:TestAMRMClient.java   
@Test (timeout=60000)
public void testAMRMClient() throws YarnException, IOException {
  AMRMClient<ContainerRequest> amClient = null;
  try {
    // start am rm client
    amClient = AMRMClient.<ContainerRequest>createAMRMClient();

    //setting an instance NMTokenCache
    amClient.setNMTokenCache(new NMTokenCache());
    //asserting we are not using the singleton instance cache
    Assert.assertNotSame(NMTokenCache.getSingleton(), 
        amClient.getNMTokenCache());

    amClient.init(conf);
    amClient.start();

    amClient.registerApplicationMaster("Host", 10000, "");

    testAllocation((AMRMClientImpl<ContainerRequest>)amClient);

    amClient.unregisterApplicationMaster(FinalApplicationStatus.SUCCEEDED,
        null, null);

  } finally {
    if (amClient != null && amClient.getServiceState() == STATE.STARTED) {
      amClient.stop();
    }
  }
}
项目:hadoop    文件:TestRMRestart.java   
private void finishApplicationMaster(RMApp rmApp, MockRM rm, MockNM nm,
    MockAM am) throws Exception {
  final FinishApplicationMasterRequest req =
      FinishApplicationMasterRequest.newInstance(
        FinalApplicationStatus.SUCCEEDED, "", "");
  finishApplicationMaster(rmApp, rm, nm, am, req);
}
项目:hadoop    文件:MockRM.java   
public static void finishAMAndVerifyAppState(RMApp rmApp, MockRM rm, MockNM nm,
    MockAM am) throws Exception {
  FinishApplicationMasterRequest req =
      FinishApplicationMasterRequest.newInstance(
        FinalApplicationStatus.SUCCEEDED, "", "");
  am.unregisterAppAttempt(req,true);
  am.waitForState(RMAppAttemptState.FINISHING);
  nm.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.COMPLETE);
  am.waitForState(RMAppAttemptState.FINISHED);
  rm.waitForState(rmApp.getApplicationId(), RMAppState.FINISHED);
}
项目:hadoop    文件:TestRMAppTransitions.java   
private void assertKilled(RMApp application) {
  assertTimesAtFinish(application);
  assertAppState(RMAppState.KILLED, application);
  assertFinalAppStatus(FinalApplicationStatus.KILLED, application);
  StringBuilder diag = application.getDiagnostics();
  Assert.assertEquals("application diagnostics is not correct",
      "Application killed by user.", diag.toString());
}