Search in sources :

Example 16 with RMAppAttemptContainerFinishedEvent

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptContainerFinishedEvent in project hadoop by apache.

the class TestRMAppAttemptTransitions method 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));
    sendAttemptUpdateSavedEvent(applicationAttempt);
    testAppAttemptFinishedState(null, finalStatus, url, diagnostics, 1, true);
    assertFalse(transferStateFromPreviousAttempt);
}
Also used : RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer) Container(org.apache.hadoop.yarn.api.records.Container) FinalApplicationStatus(org.apache.hadoop.yarn.api.records.FinalApplicationStatus) RMAppRunningOnNodeEvent(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppRunningOnNodeEvent) RMAppAttemptContainerFinishedEvent(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptContainerFinishedEvent) RMAppAttemptUnregistrationEvent(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptUnregistrationEvent)

Example 17 with RMAppAttemptContainerFinishedEvent

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptContainerFinishedEvent in project hadoop by apache.

the class TestRMAppAttemptTransitions method 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, amContainer.getResource()), anyNodeId));
    testAppAttemptFinishedState(amContainer, finalStatus, trackingUrl, diagnostics, 0, false);
}
Also used : RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer) Container(org.apache.hadoop.yarn.api.records.Container) FinalApplicationStatus(org.apache.hadoop.yarn.api.records.FinalApplicationStatus) NodeId(org.apache.hadoop.yarn.api.records.NodeId) RMAppAttemptContainerFinishedEvent(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptContainerFinishedEvent) Test(org.junit.Test)

Example 18 with RMAppAttemptContainerFinishedEvent

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptContainerFinishedEvent in project hadoop by apache.

the class ResourceTrackerService method handleNMContainerStatus.

/**
   * Helper method to handle received ContainerStatus. If this corresponds to
   * the completion of a master-container of a managed AM,
   * we call the handler for RMAppAttemptContainerFinishedEvent.
   */
@SuppressWarnings("unchecked")
@VisibleForTesting
void handleNMContainerStatus(NMContainerStatus containerStatus, NodeId nodeId) {
    ApplicationAttemptId appAttemptId = containerStatus.getContainerId().getApplicationAttemptId();
    RMApp rmApp = rmContext.getRMApps().get(appAttemptId.getApplicationId());
    if (rmApp == null) {
        LOG.error("Received finished container : " + containerStatus.getContainerId() + " for unknown application " + appAttemptId.getApplicationId() + " Skipping.");
        return;
    }
    if (rmApp.getApplicationSubmissionContext().getUnmanagedAM()) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Ignoring container completion status for unmanaged AM " + rmApp.getApplicationId());
        }
        return;
    }
    RMAppAttempt rmAppAttempt = rmApp.getRMAppAttempt(appAttemptId);
    if (rmAppAttempt == null) {
        LOG.info("Ignoring not found attempt " + appAttemptId);
        return;
    }
    Container masterContainer = rmAppAttempt.getMasterContainer();
    if (masterContainer.getId().equals(containerStatus.getContainerId()) && containerStatus.getContainerState() == ContainerState.COMPLETE) {
        ContainerStatus status = ContainerStatus.newInstance(containerStatus.getContainerId(), containerStatus.getContainerState(), containerStatus.getDiagnostics(), containerStatus.getContainerExitStatus());
        // sending master container finished event.
        RMAppAttemptContainerFinishedEvent evt = new RMAppAttemptContainerFinishedEvent(appAttemptId, status, nodeId);
        rmContext.getDispatcher().getEventHandler().handle(evt);
    }
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) Container(org.apache.hadoop.yarn.api.records.Container) NMContainerStatus(org.apache.hadoop.yarn.server.api.protocolrecords.NMContainerStatus) ContainerStatus(org.apache.hadoop.yarn.api.records.ContainerStatus) RMAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) RMAppAttemptContainerFinishedEvent(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptContainerFinishedEvent) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

RMAppAttemptContainerFinishedEvent (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptContainerFinishedEvent)18 Container (org.apache.hadoop.yarn.api.records.Container)15 Test (org.junit.Test)15 NodeId (org.apache.hadoop.yarn.api.records.NodeId)13 RMContainer (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)13 ContainerStatus (org.apache.hadoop.yarn.api.records.ContainerStatus)9 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)8 FinalApplicationStatus (org.apache.hadoop.yarn.api.records.FinalApplicationStatus)5 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)4 RMAppAttemptUnregistrationEvent (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptUnregistrationEvent)4 Configuration (org.apache.hadoop.conf.Configuration)3 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)3 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)2 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)2 Resource (org.apache.hadoop.yarn.api.records.Resource)2 RMAppRunningOnNodeEvent (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppRunningOnNodeEvent)2 RMAppAttempt (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 InetSocketAddress (java.net.InetSocketAddress)1 ArrayList (java.util.ArrayList)1