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();
}
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());
}
}
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();
}
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;
}
}
}
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());
}
}
Aggregations