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

The following examples show how to use org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState. 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: big-c   Source File: ApplicationAttemptHistoryData.java    License: Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 2
@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;
}
 
Example 3
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 4
Source Project: hadoop   Source File: RMAppAttemptImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public ApplicationAttemptReport createApplicationAttemptReport() {
  this.readLock.lock();
  ApplicationAttemptReport attemptReport = null;
  try {
    // AM container maybe not yet allocated. and also unmangedAM doesn't have
    // am container.
    ContainerId amId =
        masterContainer == null ? null : masterContainer.getId();
    attemptReport = ApplicationAttemptReport.newInstance(this
        .getAppAttemptId(), this.getHost(), this.getRpcPort(), this
        .getTrackingUrl(), this.getOriginalTrackingUrl(), this.getDiagnostics(),
        YarnApplicationAttemptState .valueOf(this.getState().toString()), amId);
  } finally {
    this.readLock.unlock();
  }
  return attemptReport;
}
 
Example 5
Source Project: big-c   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 6 votes vote down vote up
@Test(timeout=10000)
public void testLaunchedExpire() {
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  applicationAttempt.handle(new RMAppAttemptEvent(
      applicationAttempt.getAppAttemptId(), RMAppAttemptEventType.EXPIRE));
  assertEquals(YarnApplicationAttemptState.LAUNCHED,
      applicationAttempt.createApplicationAttemptState());
  sendAttemptUpdateSavedEvent(applicationAttempt);
  assertEquals(RMAppAttemptState.FAILED,
      applicationAttempt.getAppAttemptState());
  assertTrue("expire diagnostics missing",
      applicationAttempt.getDiagnostics().contains("timed out"));
  String rmAppPageUrl = pjoin(RM_WEBAPP_ADDR, "cluster", "app",
      applicationAttempt.getAppAttemptId().getApplicationId());
  assertEquals(rmAppPageUrl, applicationAttempt.getOriginalTrackingUrl());
  assertEquals(rmAppPageUrl, applicationAttempt.getTrackingUrl());
  verifyTokenCount(applicationAttempt.getAppAttemptId(), 1);
  verifyApplicationAttemptFinished(RMAppAttemptState.FAILED);
}
 
Example 6
Source Project: hadoop   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testUnmanagedAMContainersCleanup() {
  unmanagedAM = true;
  when(submissionContext.getUnmanagedAM()).thenReturn(true);
  when(submissionContext.getKeepContainersAcrossApplicationAttempts())
    .thenReturn(true);
  // submit AM and check it goes to SUBMITTED state
  submitApplicationAttempt();
  // launch AM and verify attempt failed
  applicationAttempt.handle(new RMAppAttemptRegistrationEvent(
    applicationAttempt.getAppAttemptId(), "host", 8042, "oldtrackingurl"));
  assertEquals(YarnApplicationAttemptState.SUBMITTED,
      applicationAttempt.createApplicationAttemptState());
  sendAttemptUpdateSavedEvent(applicationAttempt);
  assertFalse(transferStateFromPreviousAttempt);
}
 
Example 7
Source Project: hadoop   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testAMCrashAtScheduled() {
  // This is to test sending CONTAINER_FINISHED event at SCHEDULED state.
  // Verify the state transition is correct.
  scheduleApplicationAttempt();
  ContainerStatus cs =
      SchedulerUtils.createAbnormalContainerStatus(
          BuilderUtils.newContainerId(
              applicationAttempt.getAppAttemptId(), 1),
          SchedulerUtils.LOST_CONTAINER);
  // send CONTAINER_FINISHED event at SCHEDULED state,
  // The state should be FINAL_SAVING with previous state SCHEDULED
  NodeId anyNodeId = NodeId.newInstance("host", 1234);
  applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent(
      applicationAttempt.getAppAttemptId(), cs, anyNodeId));
  // createApplicationAttemptState will return previous state (SCHEDULED),
  // if the current state is FINAL_SAVING.
  assertEquals(YarnApplicationAttemptState.SCHEDULED,
      applicationAttempt.createApplicationAttemptState());
  // send ATTEMPT_UPDATE_SAVED event,
  // verify the state is changed to state FAILED.
  sendAttemptUpdateSavedEvent(applicationAttempt);
  assertEquals(RMAppAttemptState.FAILED,
      applicationAttempt.getAppAttemptState());
  verifyApplicationAttemptFinished(RMAppAttemptState.FAILED);
}
 
Example 8
Source Project: hadoop   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testAMCrashAtAllocated() {
  Container amContainer = allocateApplicationAttempt();
  String containerDiagMsg = "some error";
  int exitCode = 123;
  ContainerStatus cs =
      BuilderUtils.newContainerStatus(amContainer.getId(),
        ContainerState.COMPLETE, containerDiagMsg, exitCode);
  NodeId anyNodeId = NodeId.newInstance("host", 1234);
  applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent(
    applicationAttempt.getAppAttemptId(), cs, anyNodeId));
  assertEquals(YarnApplicationAttemptState.ALLOCATED,
      applicationAttempt.createApplicationAttemptState());
  sendAttemptUpdateSavedEvent(applicationAttempt);
  assertEquals(RMAppAttemptState.FAILED,
    applicationAttempt.getAppAttemptState());
  verifyTokenCount(applicationAttempt.getAppAttemptId(), 1);
  verifyApplicationAttemptFinished(RMAppAttemptState.FAILED);
  boolean shouldCheckURL = (applicationAttempt.getTrackingUrl() != null);
  verifyAMCrashAtAllocatedDiagnosticInfo(applicationAttempt.getDiagnostics(),
    exitCode, shouldCheckURL);
}
 
Example 9
Source Project: hadoop   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 6 votes vote down vote up
@Test(timeout=10000)
public void testLaunchedExpire() {
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  applicationAttempt.handle(new RMAppAttemptEvent(
      applicationAttempt.getAppAttemptId(), RMAppAttemptEventType.EXPIRE));
  assertEquals(YarnApplicationAttemptState.LAUNCHED,
      applicationAttempt.createApplicationAttemptState());
  sendAttemptUpdateSavedEvent(applicationAttempt);
  assertEquals(RMAppAttemptState.FAILED,
      applicationAttempt.getAppAttemptState());
  assertTrue("expire diagnostics missing",
      applicationAttempt.getDiagnostics().contains("timed out"));
  String rmAppPageUrl = pjoin(RM_WEBAPP_ADDR, "cluster", "app",
      applicationAttempt.getAppAttemptId().getApplicationId());
  assertEquals(rmAppPageUrl, applicationAttempt.getOriginalTrackingUrl());
  assertEquals(rmAppPageUrl, applicationAttempt.getTrackingUrl());
  verifyTokenCount(applicationAttempt.getAppAttemptId(), 1);
  verifyApplicationAttemptFinished(RMAppAttemptState.FAILED);
}
 
Example 10
Source Project: hadoop   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 6 votes vote down vote up
@Test(timeout=20000)
public void testRunningExpire() {
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false);
  applicationAttempt.handle(new RMAppAttemptEvent(
      applicationAttempt.getAppAttemptId(), RMAppAttemptEventType.EXPIRE));
  assertEquals(YarnApplicationAttemptState.RUNNING,
      applicationAttempt.createApplicationAttemptState());
  sendAttemptUpdateSavedEvent(applicationAttempt);
  assertEquals(RMAppAttemptState.FAILED,
      applicationAttempt.getAppAttemptState());
  assertTrue("expire diagnostics missing",
      applicationAttempt.getDiagnostics().contains("timed out"));
  String rmAppPageUrl = pjoin(RM_WEBAPP_ADDR, "cluster", "app",
      applicationAttempt.getAppAttemptId().getApplicationId());
  assertEquals(rmAppPageUrl, applicationAttempt.getOriginalTrackingUrl());
  assertEquals(rmAppPageUrl, applicationAttempt.getTrackingUrl());
  verifyTokenCount(applicationAttempt.getAppAttemptId(), 1);
  verifyAMHostAndPortInvalidated();
  verifyApplicationAttemptFinished(RMAppAttemptState.FAILED);
}
 
Example 11
Source Project: hadoop   Source File: ApplicationAttemptHistoryData.java    License: Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 12
Source Project: big-c   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testUnmanagedAMContainersCleanup() {
  unmanagedAM = true;
  when(submissionContext.getUnmanagedAM()).thenReturn(true);
  when(submissionContext.getKeepContainersAcrossApplicationAttempts())
    .thenReturn(true);
  // submit AM and check it goes to SUBMITTED state
  submitApplicationAttempt();
  // launch AM and verify attempt failed
  applicationAttempt.handle(new RMAppAttemptRegistrationEvent(
    applicationAttempt.getAppAttemptId(), "host", 8042, "oldtrackingurl"));
  assertEquals(YarnApplicationAttemptState.SUBMITTED,
      applicationAttempt.createApplicationAttemptState());
  sendAttemptUpdateSavedEvent(applicationAttempt);
  assertFalse(transferStateFromPreviousAttempt);
}
 
Example 13
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 14
Source Project: big-c   Source File: RMAppAttemptBlock.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void createAttemptHeadRoomTable(Block html) {
  RMAppAttempt attempt = getRMAppAttempt();
  if (attempt != null) {
    if (!isApplicationInFinalState(YarnApplicationAttemptState
        .valueOf(attempt.getAppAttemptState().toString()))) {
      RMAppAttemptMetrics metrics = attempt.getRMAppAttemptMetrics();
      DIV<Hamlet> pdiv = html._(InfoBlock.class).div(_INFO_WRAP);
      info("Application Attempt Overview").clear();
      info("Application Attempt Metrics")._(
        "Application Attempt Headroom : ", metrics == null ? "N/A" :
          metrics.getApplicationAttemptHeadroom());
      pdiv._();
    }
  }
}
 
Example 15
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 16
Source Project: big-c   Source File: RMAppAttemptImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public ApplicationAttemptReport createApplicationAttemptReport() {
  this.readLock.lock();
  ApplicationAttemptReport attemptReport = null;
  try {
    // AM container maybe not yet allocated. and also unmangedAM doesn't have
    // am container.
    ContainerId amId =
        masterContainer == null ? null : masterContainer.getId();
    attemptReport = ApplicationAttemptReport.newInstance(this
        .getAppAttemptId(), this.getHost(), this.getRpcPort(), this
        .getTrackingUrl(), this.getOriginalTrackingUrl(), this.getDiagnostics(),
        YarnApplicationAttemptState .valueOf(this.getState().toString()), amId);
  } finally {
    this.readLock.unlock();
  }
  return attemptReport;
}
 
Example 17
@Override
public void setYarnApplicationAttemptState(YarnApplicationAttemptState state) {
  maybeInitBuilder();
  if (state == null) {
    builder.clearYarnApplicationAttemptState();
    return;
  }
  builder.setYarnApplicationAttemptState(convertToProtoFormat(state));
}
 
Example 18
Source Project: big-c   Source File: ApplicationAttemptFinishData.java    License: Apache License 2.0 5 votes vote down vote up
@Public
@Unstable
public static ApplicationAttemptFinishData newInstance(
    ApplicationAttemptId appAttemptId, String diagnosticsInfo,
    String trackingURL, FinalApplicationStatus finalApplicationStatus,
    YarnApplicationAttemptState yarnApplicationAttemptState) {
  ApplicationAttemptFinishData appAttemptFD =
      Records.newRecord(ApplicationAttemptFinishData.class);
  appAttemptFD.setApplicationAttemptId(appAttemptId);
  appAttemptFD.setDiagnosticsInfo(diagnosticsInfo);
  appAttemptFD.setTrackingURL(trackingURL);
  appAttemptFD.setFinalApplicationStatus(finalApplicationStatus);
  appAttemptFD.setYarnApplicationAttemptState(yarnApplicationAttemptState);
  return appAttemptFD;
}
 
Example 19
Source Project: big-c   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Test
public void testContainersCleanupForLastAttempt() {
  // create a failed attempt.
  applicationAttempt =
      new RMAppAttemptImpl(applicationAttempt.getAppAttemptId(), spyRMContext,
        scheduler, masterService, submissionContext, new Configuration(),
        true, BuilderUtils.newResourceRequest(
            RMAppAttemptImpl.AM_CONTAINER_PRIORITY, ResourceRequest.ANY,
            submissionContext.getResource(), 1));
  when(submissionContext.getKeepContainersAcrossApplicationAttempts())
    .thenReturn(true);
  when(submissionContext.getMaxAppAttempts()).thenReturn(1);
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false);
  ContainerStatus cs1 =
      ContainerStatus.newInstance(amContainer.getId(),
        ContainerState.COMPLETE, "some error", 123);
  ApplicationAttemptId appAttemptId = applicationAttempt.getAppAttemptId();
  NodeId anyNodeId = NodeId.newInstance("host", 1234);
  applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent(
    appAttemptId, cs1, anyNodeId));
  assertEquals(YarnApplicationAttemptState.RUNNING,
      applicationAttempt.createApplicationAttemptState());
  sendAttemptUpdateSavedEvent(applicationAttempt);
  assertEquals(RMAppAttemptState.FAILED,
    applicationAttempt.getAppAttemptState());
  assertFalse(transferStateFromPreviousAttempt);
  verifyApplicationAttemptFinished(RMAppAttemptState.FAILED);
}
 
Example 20
Source Project: big-c   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testNewToKilled() {
  applicationAttempt.handle(
      new RMAppAttemptEvent(
          applicationAttempt.getAppAttemptId(), 
          RMAppAttemptEventType.KILL));
  assertEquals(YarnApplicationAttemptState.NEW,
      applicationAttempt.createApplicationAttemptState());
  testAppAttemptKilledState(null, EMPTY_DIAGNOSTICS);
  verifyTokenCount(applicationAttempt.getAppAttemptId(), 1);
}
 
Example 21
Source Project: hadoop   Source File: RMServerUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static YarnApplicationAttemptState createApplicationAttemptState(
    RMAppAttemptState rmAppAttemptState) {
  switch (rmAppAttemptState) {
    case NEW:
      return YarnApplicationAttemptState.NEW;
    case SUBMITTED:
      return YarnApplicationAttemptState.SUBMITTED;
    case SCHEDULED:
      return YarnApplicationAttemptState.SCHEDULED;
    case ALLOCATED:
      return YarnApplicationAttemptState.ALLOCATED;
    case LAUNCHED:
      return YarnApplicationAttemptState.LAUNCHED;
    case ALLOCATED_SAVING:
    case LAUNCHED_UNMANAGED_SAVING:
      return YarnApplicationAttemptState.ALLOCATED_SAVING;
    case RUNNING:
      return YarnApplicationAttemptState.RUNNING;
    case FINISHING:
      return YarnApplicationAttemptState.FINISHING;
    case FINISHED:
      return YarnApplicationAttemptState.FINISHED;
    case KILLED:
      return YarnApplicationAttemptState.KILLED;
    case FAILED:
      return YarnApplicationAttemptState.FAILED;
    default:
      throw new YarnRuntimeException("Unknown state passed!");
  }
}
 
Example 22
Source Project: big-c   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSubmittedToKilled() {
  submitApplicationAttempt();
  applicationAttempt.handle(
      new RMAppAttemptEvent(
          applicationAttempt.getAppAttemptId(), 
          RMAppAttemptEventType.KILL));
  assertEquals(YarnApplicationAttemptState.SUBMITTED,
      applicationAttempt.createApplicationAttemptState());
  testAppAttemptKilledState(null, EMPTY_DIAGNOSTICS);
}
 
Example 23
Source Project: hadoop   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSubmittedToKilled() {
  submitApplicationAttempt();
  applicationAttempt.handle(
      new RMAppAttemptEvent(
          applicationAttempt.getAppAttemptId(), 
          RMAppAttemptEventType.KILL));
  assertEquals(YarnApplicationAttemptState.SUBMITTED,
      applicationAttempt.createApplicationAttemptState());
  testAppAttemptKilledState(null, EMPTY_DIAGNOSTICS);
}
 
Example 24
Source Project: samza   Source File: YarnJobValidationTool.java    License: Apache License 2.0 5 votes vote down vote up
public ApplicationAttemptId validateRunningAttemptId(ApplicationId appId) throws Exception {
  ApplicationAttemptId attemptId = this.client.getApplicationReport(appId).getCurrentApplicationAttemptId();
  ApplicationAttemptReport attemptReport = this.client.getApplicationAttemptReport(attemptId);
  if (attemptReport.getYarnApplicationAttemptState() == YarnApplicationAttemptState.RUNNING) {
    log.info("Job is running. AttempId " + attemptId.toString());
    return attemptId;
  } else {
    throw new SamzaException("Job not running " + this.jobName);
  }
}
 
Example 25
Source Project: big-c   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAllocatedToKilled() {
  Container amContainer = allocateApplicationAttempt();
  applicationAttempt.handle(
      new RMAppAttemptEvent(
          applicationAttempt.getAppAttemptId(), 
          RMAppAttemptEventType.KILL));
  assertEquals(YarnApplicationAttemptState.ALLOCATED,
      applicationAttempt.createApplicationAttemptState());
  testAppAttemptKilledState(amContainer, EMPTY_DIAGNOSTICS);
}
 
Example 26
Source Project: hadoop   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAllocatedToFailed() {
  Container amContainer = allocateApplicationAttempt();
  String diagnostics = "Launch Failed";
  applicationAttempt.handle(
      new RMAppAttemptLaunchFailedEvent(
          applicationAttempt.getAppAttemptId(), 
          diagnostics));
  assertEquals(YarnApplicationAttemptState.ALLOCATED,
      applicationAttempt.createApplicationAttemptState());
  testAppAttemptFailedState(amContainer, diagnostics);
}
 
Example 27
Source Project: hadoop   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testRunningToFailed() {
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false);
  String containerDiagMsg = "some error";
  int exitCode = 123;
  ContainerStatus cs = BuilderUtils.newContainerStatus(amContainer.getId(),
      ContainerState.COMPLETE, containerDiagMsg, exitCode);
  ApplicationAttemptId appAttemptId = applicationAttempt.getAppAttemptId();
  NodeId anyNodeId = NodeId.newInstance("host", 1234);
  applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent(
      appAttemptId, cs, anyNodeId));

  // ignored ContainerFinished and Expire at FinalSaving if we were supposed
  // to Failed state.
  assertEquals(RMAppAttemptState.FINAL_SAVING,
    applicationAttempt.getAppAttemptState());
  applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent(
    applicationAttempt.getAppAttemptId(), BuilderUtils.newContainerStatus(
      amContainer.getId(), ContainerState.COMPLETE, "", 0), anyNodeId));
  applicationAttempt.handle(new RMAppAttemptEvent(
    applicationAttempt.getAppAttemptId(), RMAppAttemptEventType.EXPIRE));
  assertEquals(RMAppAttemptState.FINAL_SAVING,
    applicationAttempt.getAppAttemptState()); 
  assertEquals(YarnApplicationAttemptState.RUNNING,
      applicationAttempt.createApplicationAttemptState());
  sendAttemptUpdateSavedEvent(applicationAttempt);
  assertEquals(RMAppAttemptState.FAILED,
      applicationAttempt.getAppAttemptState());
  assertEquals(0, applicationAttempt.getJustFinishedContainers().size());
  assertEquals(amContainer, applicationAttempt.getMasterContainer());
  assertEquals(0, application.getRanNodes().size());
  String rmAppPageUrl = pjoin(RM_WEBAPP_ADDR, "cluster", "app",
      applicationAttempt.getAppAttemptId().getApplicationId());
  assertEquals(rmAppPageUrl, applicationAttempt.getOriginalTrackingUrl());
  assertEquals(rmAppPageUrl, applicationAttempt.getTrackingUrl());
  verifyAMHostAndPortInvalidated();
  verifyApplicationAttemptFinished(RMAppAttemptState.FAILED);
}
 
Example 28
Source Project: hadoop   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testRunningToKilled() {
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false);
  applicationAttempt.handle(
      new RMAppAttemptEvent(
          applicationAttempt.getAppAttemptId(),
          RMAppAttemptEventType.KILL));

  // ignored ContainerFinished and Expire at FinalSaving if we were supposed
  // to Killed state.
  assertEquals(RMAppAttemptState.FINAL_SAVING,
    applicationAttempt.getAppAttemptState());
  NodeId anyNodeId = NodeId.newInstance("host", 1234);
  applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent(
    applicationAttempt.getAppAttemptId(), BuilderUtils.newContainerStatus(
      amContainer.getId(), ContainerState.COMPLETE, "", 0), anyNodeId));
  applicationAttempt.handle(new RMAppAttemptEvent(
    applicationAttempt.getAppAttemptId(), RMAppAttemptEventType.EXPIRE));
  assertEquals(RMAppAttemptState.FINAL_SAVING,
    applicationAttempt.getAppAttemptState()); 
  assertEquals(YarnApplicationAttemptState.RUNNING,
      applicationAttempt.createApplicationAttemptState());
  sendAttemptUpdateSavedEvent(applicationAttempt);
  assertEquals(RMAppAttemptState.KILLED,
      applicationAttempt.getAppAttemptState());
  assertEquals(0, applicationAttempt.getJustFinishedContainers().size());
  assertEquals(amContainer, applicationAttempt.getMasterContainer());
  assertEquals(0, application.getRanNodes().size());
  String rmAppPageUrl = pjoin(RM_WEBAPP_ADDR, "cluster", "app",
      applicationAttempt.getAppAttemptId().getApplicationId());
  assertEquals(rmAppPageUrl, applicationAttempt.getOriginalTrackingUrl());
  assertEquals(rmAppPageUrl, applicationAttempt.getTrackingUrl());
  verifyTokenCount(applicationAttempt.getAppAttemptId(), 1);
  verifyAMHostAndPortInvalidated();
  verifyApplicationAttemptFinished(RMAppAttemptState.KILLED);
}
 
Example 29
Source Project: hadoop   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 30
Source Project: big-c   Source File: TestRMAppAttemptTransitions.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAllocatedToFailed() {
  Container amContainer = allocateApplicationAttempt();
  String diagnostics = "Launch Failed";
  applicationAttempt.handle(
      new RMAppAttemptLaunchFailedEvent(
          applicationAttempt.getAppAttemptId(), 
          diagnostics));
  assertEquals(YarnApplicationAttemptState.ALLOCATED,
      applicationAttempt.createApplicationAttemptState());
  testAppAttemptFailedState(amContainer, diagnostics);
}