Search in sources :

Example 61 with YarnException

use of org.apache.hadoop.yarn.exceptions.YarnException in project hadoop by apache.

the class ContainerManagerImpl method rollbackLastReInitialization.

/**
   * Rollback the last reInitialization, if possible.
   * @param containerId Container ID.
   * @return Rollback Response.
   * @throws YarnException Yarn Exception.
   */
@Override
public RollbackResponse rollbackLastReInitialization(ContainerId containerId) throws YarnException {
    Container container = preReInitializeOrLocalizeCheck(containerId, ReInitOp.ROLLBACK);
    if (container.canRollback()) {
        dispatcher.getEventHandler().handle(new ContainerEvent(containerId, ContainerEventType.ROLLBACK_REINIT));
        container.setIsReInitializing(true);
    } else {
        throw new YarnException("Nothing to rollback to !!");
    }
    return RollbackResponse.newInstance();
}
Also used : ContainerEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEvent) Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container) YarnException(org.apache.hadoop.yarn.exceptions.YarnException)

Example 62 with YarnException

use of org.apache.hadoop.yarn.exceptions.YarnException in project hadoop by apache.

the class ContainerManagerImpl method handle.

@SuppressWarnings("unchecked")
@Override
public void handle(ContainerManagerEvent event) {
    switch(event.getType()) {
        case FINISH_APPS:
            CMgrCompletedAppsEvent appsFinishedEvent = (CMgrCompletedAppsEvent) event;
            for (ApplicationId appID : appsFinishedEvent.getAppsToCleanup()) {
                Application app = this.context.getApplications().get(appID);
                if (app == null) {
                    LOG.warn("couldn't find application " + appID + " while processing" + " FINISH_APPS event");
                    continue;
                }
                boolean shouldDropEvent = false;
                for (Container container : app.getContainers().values()) {
                    if (container.isRecovering()) {
                        LOG.info("drop FINISH_APPS event to " + appID + " because " + "container " + container.getContainerId() + " is recovering");
                        shouldDropEvent = true;
                        break;
                    }
                }
                if (shouldDropEvent) {
                    continue;
                }
                String diagnostic = "";
                if (appsFinishedEvent.getReason() == CMgrCompletedAppsEvent.Reason.ON_SHUTDOWN) {
                    diagnostic = "Application killed on shutdown";
                } else if (appsFinishedEvent.getReason() == CMgrCompletedAppsEvent.Reason.BY_RESOURCEMANAGER) {
                    diagnostic = "Application killed by ResourceManager";
                }
                this.dispatcher.getEventHandler().handle(new ApplicationFinishEvent(appID, diagnostic));
            }
            break;
        case FINISH_CONTAINERS:
            CMgrCompletedContainersEvent containersFinishedEvent = (CMgrCompletedContainersEvent) event;
            for (ContainerId containerId : containersFinishedEvent.getContainersToCleanup()) {
                ApplicationId appId = containerId.getApplicationAttemptId().getApplicationId();
                Application app = this.context.getApplications().get(appId);
                if (app == null) {
                    LOG.warn("couldn't find app " + appId + " while processing" + " FINISH_CONTAINERS event");
                    continue;
                }
                Container container = app.getContainers().get(containerId);
                if (container == null) {
                    LOG.warn("couldn't find container " + containerId + " while processing FINISH_CONTAINERS event");
                    continue;
                }
                if (container.isRecovering()) {
                    LOG.info("drop FINISH_CONTAINERS event to " + containerId + " because container is recovering");
                    continue;
                }
                this.dispatcher.getEventHandler().handle(new ContainerKillEvent(containerId, ContainerExitStatus.KILLED_BY_RESOURCEMANAGER, "Container Killed by ResourceManager"));
            }
            break;
        case DECREASE_CONTAINERS_RESOURCE:
            CMgrDecreaseContainersResourceEvent containersDecreasedEvent = (CMgrDecreaseContainersResourceEvent) event;
            for (org.apache.hadoop.yarn.api.records.Container container : containersDecreasedEvent.getContainersToDecrease()) {
                try {
                    changeContainerResourceInternal(container.getId(), container.getVersion(), container.getResource(), false);
                } catch (YarnException e) {
                    LOG.error("Unable to decrease container resource", e);
                } catch (IOException e) {
                    LOG.error("Unable to update container resource in store", e);
                }
            }
            break;
        case SIGNAL_CONTAINERS:
            CMgrSignalContainersEvent containersSignalEvent = (CMgrSignalContainersEvent) event;
            for (SignalContainerRequest request : containersSignalEvent.getContainersToSignal()) {
                internalSignalToContainer(request, "ResourceManager");
            }
            break;
        default:
            throw new YarnRuntimeException("Got an unknown ContainerManagerEvent type: " + event.getType());
    }
}
Also used : ApplicationFinishEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationFinishEvent) CMgrDecreaseContainersResourceEvent(org.apache.hadoop.yarn.server.nodemanager.CMgrDecreaseContainersResourceEvent) CMgrSignalContainersEvent(org.apache.hadoop.yarn.server.nodemanager.CMgrSignalContainersEvent) CMgrCompletedContainersEvent(org.apache.hadoop.yarn.server.nodemanager.CMgrCompletedContainersEvent) SignalContainerRequest(org.apache.hadoop.yarn.api.protocolrecords.SignalContainerRequest) CMgrCompletedAppsEvent(org.apache.hadoop.yarn.server.nodemanager.CMgrCompletedAppsEvent) ContainerKillEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerKillEvent) ByteString(com.google.protobuf.ByteString) IOException(java.io.IOException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Application(org.apache.hadoop.yarn.server.nodemanager.containermanager.application.Application)

Example 63 with YarnException

use of org.apache.hadoop.yarn.exceptions.YarnException in project hadoop by apache.

the class ContainerManagerImpl method localize.

@Override
@SuppressWarnings("unchecked")
public ResourceLocalizationResponse localize(ResourceLocalizationRequest request) throws YarnException, IOException {
    ContainerId containerId = request.getContainerId();
    Container container = preReInitializeOrLocalizeCheck(containerId, ReInitOp.LOCALIZE);
    try {
        Map<LocalResourceVisibility, Collection<LocalResourceRequest>> req = container.getResourceSet().addResources(request.getLocalResources());
        if (req != null && !req.isEmpty()) {
            dispatcher.getEventHandler().handle(new ContainerLocalizationRequestEvent(container, req));
        }
    } catch (URISyntaxException e) {
        LOG.info("Error when parsing local resource URI for " + containerId, e);
        throw new YarnException(e);
    }
    return ResourceLocalizationResponse.newInstance();
}
Also used : Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container) ContainerLocalizationRequestEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ContainerLocalizationRequestEvent) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) Collection(java.util.Collection) URISyntaxException(java.net.URISyntaxException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) LocalResourceVisibility(org.apache.hadoop.yarn.api.records.LocalResourceVisibility)

Example 64 with YarnException

use of org.apache.hadoop.yarn.exceptions.YarnException in project hadoop by apache.

the class ContainerLocalizer method localizeFiles.

protected void localizeFiles(LocalizationProtocol nodemanager, CompletionService<Path> cs, UserGroupInformation ugi) throws IOException, YarnException {
    while (true) {
        try {
            LocalizerStatus status = createStatus();
            LocalizerHeartbeatResponse response = nodemanager.heartbeat(status);
            switch(response.getLocalizerAction()) {
                case LIVE:
                    List<ResourceLocalizationSpec> newRsrcs = response.getResourceSpecs();
                    for (ResourceLocalizationSpec newRsrc : newRsrcs) {
                        if (!pendingResources.containsKey(newRsrc.getResource())) {
                            pendingResources.put(newRsrc.getResource(), cs.submit(download(new Path(newRsrc.getDestinationDirectory().getFile()), newRsrc.getResource(), ugi)));
                        }
                    }
                    break;
                case DIE:
                    // killall running localizations
                    for (Future<Path> pending : pendingResources.values()) {
                        pending.cancel(true);
                    }
                    status = createStatus();
                    // ignore response while dying.
                    try {
                        nodemanager.heartbeat(status);
                    } catch (YarnException e) {
                        // Cannot do anything about this during death stage, let's just log
                        // it.
                        e.printStackTrace(System.out);
                        LOG.error("Heartbeat failed while dying: ", e);
                    }
                    return;
            }
            cs.poll(1000, TimeUnit.MILLISECONDS);
        } catch (InterruptedException e) {
            return;
        } catch (YarnException e) {
            // TODO cleanup
            throw e;
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) ResourceLocalizationSpec(org.apache.hadoop.yarn.server.nodemanager.api.ResourceLocalizationSpec) LocalizerHeartbeatResponse(org.apache.hadoop.yarn.server.nodemanager.api.protocolrecords.LocalizerHeartbeatResponse) LocalizerStatus(org.apache.hadoop.yarn.server.nodemanager.api.protocolrecords.LocalizerStatus) YarnException(org.apache.hadoop.yarn.exceptions.YarnException)

Example 65 with YarnException

use of org.apache.hadoop.yarn.exceptions.YarnException in project hadoop by apache.

the class SharedCacheUploader method notifySharedCacheManager.

@VisibleForTesting
boolean notifySharedCacheManager(String checksumVal, String fileName) throws IOException {
    try {
        SCMUploaderNotifyRequest request = recordFactory.newRecordInstance(SCMUploaderNotifyRequest.class);
        request.setResourceKey(checksumVal);
        request.setFilename(fileName);
        return scmClient.notify(request).getAccepted();
    } catch (YarnException e) {
        throw new IOException(e);
    } catch (UndeclaredThrowableException e) {
        // retrieve the cause of the exception and throw it as an IOException
        throw new IOException(e.getCause() == null ? e : e.getCause());
    }
}
Also used : SCMUploaderNotifyRequest(org.apache.hadoop.yarn.server.api.protocolrecords.SCMUploaderNotifyRequest) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) IOException(java.io.IOException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

YarnException (org.apache.hadoop.yarn.exceptions.YarnException)287 IOException (java.io.IOException)149 Test (org.junit.Test)107 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)61 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)44 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)31 Configuration (org.apache.hadoop.conf.Configuration)26 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)26 ArrayList (java.util.ArrayList)25 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)25 ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)25 AccessControlException (org.apache.hadoop.security.AccessControlException)22 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)21 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)17 Path (org.apache.hadoop.fs.Path)17 ReservationSubmissionRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)15 ContainerLaunchContext (org.apache.hadoop.yarn.api.records.ContainerLaunchContext)15 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)14 HashMap (java.util.HashMap)13 ApplicationSubmissionContext (org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext)13