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

The following examples show how to use org.apache.hadoop.yarn.api.records.FinalApplicationStatus. These examples are extracted from open source projects. 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 Project: hadoop   Source File: TestRMAppAttemptTransitions.java    License: 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 2
Source Project: big-c   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * {@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();
}
 
Example 3
Source Project: hadoop   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 4
Source Project: big-c   Source File: ApplicationFinishedEvent.java    License: Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 5
Source Project: hadoop   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * {@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();
}
 
Example 6
Source Project: attic-apex-core   Source File: StreamingAppMasterService.java    License: Apache License 2.0 6 votes vote down vote up
private void finishApplication(FinalApplicationStatus finalStatus) throws YarnException, IOException
{
  LOG.info("Application completed. Signalling finish to RM");
  FinishApplicationMasterRequest finishReq = Records.newRecord(FinishApplicationMasterRequest.class);
  finishReq.setFinalApplicationStatus(finalStatus);

  if (finalStatus != FinalApplicationStatus.SUCCEEDED) {
    String diagnostics = "Diagnostics." + " completed=" + numCompletedContainers.get() + ", allocated=" + allocatedContainers.size() + ", failed=" + numFailedContainers.get();
    if (!StringUtils.isEmpty(dnmgr.shutdownDiagnosticsMessage)) {
      diagnostics += "\n";
      diagnostics += dnmgr.shutdownDiagnosticsMessage;
    }
    // YARN-208 - as of 2.0.1-alpha dropped by the RM
    finishReq.setDiagnostics(diagnostics);
    // expected termination of the master process
    // application status and diagnostics message are set above
  }
  LOG.info("diagnostics: " + finishReq.getDiagnostics());
  amRmClient.unregisterApplicationMaster(finishReq.getFinalApplicationStatus(), finishReq.getDiagnostics(), null);
}
 
Example 7
Source Project: big-c   Source File: TestRMApplicationHistoryWriter.java    License: Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 8
Source Project: hadoop   Source File: AppAttemptFinishedEvent.java    License: Apache License 2.0 6 votes vote down vote up
public AppAttemptFinishedEvent(
    ApplicationAttemptId appAttemptId,
    String trackingUrl,
    String originalTrackingUrl,
    String diagnosticsInfo,
    FinalApplicationStatus appStatus,
    YarnApplicationAttemptState state,
    long finishedTime) {
  super(SystemMetricsEventType.APP_ATTEMPT_FINISHED, finishedTime);
  this.appAttemptId = appAttemptId;
  // This is the tracking URL after the application attempt is finished
  this.trackingUrl = trackingUrl;
  this.originalTrackingUrl = originalTrackingUrl;
  this.diagnosticsInfo = diagnosticsInfo;
  this.appStatus = appStatus;
  this.state = state;
}
 
Example 9
private ApplicationReport mockRunningApplicationReport(String appId, String appName)
{
  ApplicationReport app = mock(ApplicationReport.class);
  ApplicationId applicationId = mock(ApplicationId.class);

  when(applicationId.toString()).thenReturn(appId);
  when(app.getApplicationId()).thenReturn(applicationId);

  when(app.getName()).thenReturn(appName);

  when(app.getYarnApplicationState()).thenReturn(YarnApplicationState.RUNNING);
  when(app.getFinalApplicationStatus()).thenReturn(FinalApplicationStatus.UNDEFINED);

  when(app.getTrackingUrl()).thenReturn("http://example.com");

  return app;
}
 
Example 10
Source Project: big-c   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 11
Source Project: big-c   Source File: AppAttemptFinishedEvent.java    License: Apache License 2.0 6 votes vote down vote up
public AppAttemptFinishedEvent(
    ApplicationAttemptId appAttemptId,
    String trackingUrl,
    String originalTrackingUrl,
    String diagnosticsInfo,
    FinalApplicationStatus appStatus,
    YarnApplicationAttemptState state,
    long finishedTime) {
  super(SystemMetricsEventType.APP_ATTEMPT_FINISHED, finishedTime);
  this.appAttemptId = appAttemptId;
  // This is the tracking URL after the application attempt is finished
  this.trackingUrl = trackingUrl;
  this.originalTrackingUrl = originalTrackingUrl;
  this.diagnosticsInfo = diagnosticsInfo;
  this.appStatus = appStatus;
  this.state = state;
}
 
Example 12
Source Project: incubator-tez   Source File: NotRunningJob.java    License: Apache License 2.0 5 votes vote down vote up
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, "TEZ_MRR", null);
}
 
Example 13
Source Project: big-c   Source File: ProtocolHATestBase.java    License: Apache License 2.0 5 votes vote down vote up
public ApplicationReport createFakeAppReport() {
  ApplicationId appId = ApplicationId.newInstance(1000l, 1);
  ApplicationAttemptId attemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  // create a fake application report
  ApplicationReport report =
      ApplicationReport.newInstance(appId, attemptId, "fakeUser",
          "fakeQueue", "fakeApplicationName", "localhost", 0, null,
          YarnApplicationState.FINISHED, "fake an application report", "",
          1000l, 1200l, FinalApplicationStatus.FAILED, null, "", 50f,
          "fakeApplicationType", null);
  return report;
}
 
Example 14
Source Project: tez   Source File: TestTaskScheduler.java    License: Apache License 2.0 5 votes vote down vote up
@Test (timeout=3000)
public void testTaskSchedulerHeldContainersReleaseAfterExpired() throws Exception {
  final TezAMRMClientAsync<CookieContainerRequest> mockRMClient = spy(
    new AMRMClientAsyncForTest(new AMRMClientForTest(), 100));
  final TaskSchedulerContext mockApp = setupMockTaskSchedulerContext(DEFAULT_APP_HOST, DEFAULT_APP_PORT,
    DEFAULT_APP_URL, true, new Configuration());
  final TaskSchedulerContextDrainable drainableAppCallback = createDrainableContext(mockApp);
  final TaskSchedulerWithDrainableContext scheduler =
    new TaskSchedulerWithDrainableContext(drainableAppCallback, mockRMClient);

  scheduler.initialize();
  scheduler.start();

  Resource mockCapability = Resource.newInstance(1024, 1);
  NodeId emptyHost = NodeId.newInstance("", 1);
  ApplicationAttemptId appId = ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 0), 0);
  ContainerId containerId = ContainerId.newInstance(appId, 0);
  Container c1 = Container.newInstance(containerId, emptyHost, null, mockCapability, null, null);

  HeldContainer hc1 = new HeldContainer(c1, -1, -1, null, containerSignatureMatcher);

  // containerExpiryTime = 0
  scheduler.heldContainers.put(containerId, hc1);

  long currTime = System.currentTimeMillis();
  scheduler.delayedContainerManager.addDelayedContainer(hc1.getContainer(), currTime);
  // sleep and wait for mainLoop() check-in to release this expired held container.
  Thread.sleep(1000);

  verify(mockRMClient, times(1)).releaseAssignedContainer((ContainerId)any());
  Assert.assertEquals(0, scheduler.heldContainers.size());

  AppFinalStatus finalStatus =
    new AppFinalStatus(FinalApplicationStatus.SUCCEEDED, SUCCEED_APP_MESSAGE, DEFAULT_APP_URL);
  when(mockApp.getFinalAppStatus()).thenReturn(finalStatus);
  scheduler.shutdown();
}
 
Example 15
Source Project: Scribengin   Source File: Client.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
private boolean monitorApplication(ApplicationId appId) throws YarnException, IOException {
  boolean r = false;
  while (true) {
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      r = false;
      break;
    }

    ApplicationReport report = yarnClient.getApplicationReport(appId);
    YarnApplicationState state = report.getYarnApplicationState();
    FinalApplicationStatus status = report.getFinalApplicationStatus();

    if (state == YarnApplicationState.FINISHED) {
      if (status == FinalApplicationStatus.SUCCEEDED) {
        LOG.info("Completed sucessfully.");
        r = true;
        break;
      } else {
        LOG.info("Application errored out. YarnState=" + state.toString() + ", finalStatue="
            + status.toString());
        r = false;
        break;
      }
    } else if (state == YarnApplicationState.KILLED || state == YarnApplicationState.FAILED) {
      LOG.info("Application errored out. YarnState=" + state.toString() + ", finalStatue="
          + status.toString());
      r = false;
      break;
    }
  }// while
  return r;
}
 
Example 16
Source Project: Flink-CEPplus   Source File: AbstractYarnClusterTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Tests that the cluster retrieval of a finished YARN application fails.
 */
@Test(expected = ClusterRetrieveException.class)
public void testClusterClientRetrievalOfFinishedYarnApplication() throws Exception {
	final ApplicationId applicationId = ApplicationId.newInstance(System.currentTimeMillis(), 42);
	final ApplicationReport applicationReport = createApplicationReport(
		applicationId,
		YarnApplicationState.FINISHED,
		FinalApplicationStatus.SUCCEEDED);

	final YarnClient yarnClient = new TestingYarnClient(Collections.singletonMap(applicationId, applicationReport));
	final YarnConfiguration yarnConfiguration = new YarnConfiguration();
	yarnClient.init(yarnConfiguration);
	yarnClient.start();

	final TestingAbstractYarnClusterDescriptor clusterDescriptor = new TestingAbstractYarnClusterDescriptor(
		new Configuration(),
		yarnConfiguration,
		temporaryFolder.newFolder().getAbsolutePath(),
		yarnClient,
		false);

	try {
		clusterDescriptor.retrieve(applicationId);
	} finally {
		clusterDescriptor.close();
	}
}
 
Example 17
Source Project: big-c   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testUnregisterToSuccessfulFinishing() {
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false);
  unregisterApplicationAttempt(amContainer,
      FinalApplicationStatus.SUCCEEDED, "mytrackingurl", "Successful");
}
 
Example 18
Source Project: hadoop   Source File: ApplicationFinishDataPBImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setFinalApplicationStatus(
    FinalApplicationStatus finalApplicationStatus) {
  maybeInitBuilder();
  if (finalApplicationStatus == null) {
    builder.clearFinalApplicationStatus();
    return;
  }
  builder
    .setFinalApplicationStatus(convertToProtoFormat(finalApplicationStatus));
}
 
Example 19
Source Project: hadoop   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testUnregisterToSuccessfulFinishing() {
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false);
  unregisterApplicationAttempt(amContainer,
      FinalApplicationStatus.SUCCEEDED, "mytrackingurl", "Successful");
}
 
Example 20
@Override
public void setFinalApplicationStatus(
    FinalApplicationStatus finalApplicationStatus) {
  maybeInitBuilder();
  if (finalApplicationStatus == null) {
    builder.clearFinalApplicationStatus();
    return;
  }
  builder
    .setFinalApplicationStatus(convertToProtoFormat(finalApplicationStatus));
}
 
Example 21
Source Project: big-c   Source File: MockRM.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 22
Source Project: hadoop   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 5 votes vote down vote up
private void testTrackingUrlManagedAM(String url) {
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  runApplicationAttempt(amContainer, "host", 8042, url, false);
  unregisterApplicationAttempt(amContainer,
      FinalApplicationStatus.SUCCEEDED, url, "Successful");
}
 
Example 23
Source Project: hadoop   Source File: ApplicationAttemptFinishDataPBImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setFinalApplicationStatus(
    FinalApplicationStatus finalApplicationStatus) {
  maybeInitBuilder();
  if (finalApplicationStatus == null) {
    builder.clearFinalApplicationStatus();
    return;
  }
  builder
    .setFinalApplicationStatus(convertToProtoFormat(finalApplicationStatus));
}
 
Example 24
public Map<String, Long> getJobsDuration(RMCommunicator rmCommunicator) throws YarnException, IOException {

		long appDuration, endMillis = 0;
		Map<String, Long> jobsDuration = new HashMap<String, Long>();
		for (ApplicationReport report : rmCommunicator.getApplications()) {
			if (report.getFinalApplicationStatus().equals(FinalApplicationStatus.SUCCEEDED)) {
				endMillis = report.getFinishTime();
				appDuration = (endMillis - report.getStartTime());
				jobsDuration.put(report.getApplicationId().toString().replace(APPLICATION, JOB), appDuration);
			}
		}	
		return jobsDuration;
	}
 
Example 25
Source Project: tez   Source File: TestHadoopShim28.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testApplyFinalApplicationStatusCorrection() {
  HadoopShim shim = new HadoopShim28();
  // Session mode success/failure, change to ended
  Assert.assertEquals(FinalApplicationStatus.ENDED,
      shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.SUCCEEDED, true, false));
  Assert.assertEquals(FinalApplicationStatus.ENDED,
      shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.FAILED, true, false));

  // Non-session mode success/failure, retain success/failure
  Assert.assertEquals(FinalApplicationStatus.SUCCEEDED,
      shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.SUCCEEDED, false, false));
  Assert.assertEquals(FinalApplicationStatus.FAILED,
      shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.FAILED, false, false));

  // Session and non-session mode error, retain failed.
  Assert.assertEquals(FinalApplicationStatus.FAILED,
      shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.FAILED, true, true));
  Assert.assertEquals(FinalApplicationStatus.FAILED,
      shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.FAILED, false, true));

  // Session and non-session mode killed is killed.
  Assert.assertEquals(FinalApplicationStatus.KILLED,
      shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.KILLED, true, false));
  Assert.assertEquals(FinalApplicationStatus.KILLED,
      shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.KILLED, false, false));

  // Session and non-session mode undefined is undefined.
  Assert.assertEquals(FinalApplicationStatus.UNDEFINED,
      shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.UNDEFINED, true, false));
  Assert.assertEquals(FinalApplicationStatus.UNDEFINED,
      shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.UNDEFINED, false, false));
}
 
Example 26
Source Project: big-c   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testUsageReport() {
  // scheduler has info on running apps
  ApplicationAttemptId attemptId = applicationAttempt.getAppAttemptId();
  ApplicationResourceUsageReport appResUsgRpt =
          mock(ApplicationResourceUsageReport.class);
  when(appResUsgRpt.getMemorySeconds()).thenReturn(123456L);
  when(appResUsgRpt.getVcoreSeconds()).thenReturn(55544L);
  when(scheduler.getAppResourceUsageReport(any(ApplicationAttemptId.class)))
  .thenReturn(appResUsgRpt);

  // start and finish the attempt
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false);
  applicationAttempt.handle(new RMAppAttemptUnregistrationEvent(attemptId,
      "", FinalApplicationStatus.SUCCEEDED, ""));

  // expect usage stats to come from the scheduler report
  ApplicationResourceUsageReport report = 
      applicationAttempt.getApplicationResourceUsageReport();
  Assert.assertEquals(123456L, report.getMemorySeconds());
  Assert.assertEquals(55544L, report.getVcoreSeconds());

  // finish app attempt and remove it from scheduler 
  when(appResUsgRpt.getMemorySeconds()).thenReturn(223456L);
  when(appResUsgRpt.getVcoreSeconds()).thenReturn(75544L);
  sendAttemptUpdateSavedEvent(applicationAttempt);
  NodeId anyNodeId = NodeId.newInstance("host", 1234);
  applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent(
      attemptId, 
      ContainerStatus.newInstance(
          amContainer.getId(), ContainerState.COMPLETE, "", 0), anyNodeId));

  when(scheduler.getSchedulerAppInfo(eq(attemptId))).thenReturn(null);

  report = applicationAttempt.getApplicationResourceUsageReport();
  Assert.assertEquals(223456, report.getMemorySeconds());
  Assert.assertEquals(75544, report.getVcoreSeconds());
}
 
Example 27
Source Project: big-c   Source File: AMSimulator.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void lastStep() throws Exception {
  LOG.info(MessageFormat.format("Application {0} is shutting down.", appId));
  // unregister tracking
  if (isTracked) {
    untrackApp();
  }
  // unregister application master
  final FinishApplicationMasterRequest finishAMRequest = recordFactory
                .newRecordInstance(FinishApplicationMasterRequest.class);
  finishAMRequest.setFinalApplicationStatus(FinalApplicationStatus.SUCCEEDED);

  UserGroupInformation ugi =
      UserGroupInformation.createRemoteUser(appAttemptId.toString());
  Token<AMRMTokenIdentifier> token = rm.getRMContext().getRMApps().get(appId)
      .getRMAppAttempt(appAttemptId).getAMRMToken();
  ugi.addTokenIdentifier(token.decodeIdentifier());
  ugi.doAs(new PrivilegedExceptionAction<Object>() {
    @Override
    public Object run() throws Exception {
      rm.getApplicationMasterService()
          .finishApplicationMaster(finishAMRequest);
      return null;
    }
  });

  simulateFinishTimeMS = System.currentTimeMillis() -
      SLSRunner.getRunner().getStartTimeMS();
  // record job running information
  ((ResourceSchedulerWrapper)rm.getResourceScheduler())
       .addAMRuntime(appId, 
                    traceStartTimeMS, traceFinishTimeMS, 
                    simulateStartTimeMS, simulateFinishTimeMS);
}
 
Example 28
Source Project: hadoop   Source File: ProtocolHATestBase.java    License: Apache License 2.0 5 votes vote down vote up
public ApplicationReport createFakeAppReport() {
  ApplicationId appId = ApplicationId.newInstance(1000l, 1);
  ApplicationAttemptId attemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  // create a fake application report
  ApplicationReport report =
      ApplicationReport.newInstance(appId, attemptId, "fakeUser",
          "fakeQueue", "fakeApplicationName", "localhost", 0, null,
          YarnApplicationState.FINISHED, "fake an application report", "",
          1000l, 1200l, FinalApplicationStatus.FAILED, null, "", 50f,
          "fakeApplicationType", null);
  return report;
}
 
Example 29
@Test(timeout = 15000)
public void testFinishApplicationMasterOnHA() throws YarnException,
    IOException {
  FinishApplicationMasterRequest request =
      FinishApplicationMasterRequest.newInstance(
          FinalApplicationStatus.SUCCEEDED, "", "");
  FinishApplicationMasterResponse response =
      amClient.finishApplicationMaster(request);
  Assert.assertEquals(response,
      this.cluster.createFakeFinishApplicationMasterResponse());
}
 
Example 30
Source Project: hadoop   Source File: ApplicationReportPBImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public FinalApplicationStatus getFinalApplicationStatus() {
  ApplicationReportProtoOrBuilder p = viaProto ? proto : builder;
  if (!p.hasFinalApplicationStatus()) {
    return null;
  }	
  return convertFromProtoFormat(p.getFinalApplicationStatus());
}