Example usage for org.apache.hadoop.yarn.api.records FinalApplicationStatus FAILED

List of usage examples for org.apache.hadoop.yarn.api.records FinalApplicationStatus FAILED

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.api.records FinalApplicationStatus FAILED.

Prototype

FinalApplicationStatus FAILED

To view the source code for org.apache.hadoop.yarn.api.records FinalApplicationStatus FAILED.

Click Source Link

Document

Application which failed.

Usage

From source file:org.springframework.yarn.batch.am.BatchAppmaster.java

License:Apache License

@Override
public void submitApplication() {
    log.info("submitApplication");
    registerAppmaster();/*from   w w  w  .  j ava2 s .  com*/
    start();
    if (getAllocator() instanceof AbstractAllocator) {
        log.info("about to set app attempt id");
        ((AbstractAllocator) getAllocator()).setApplicationAttemptId(getApplicationAttemptId());
    }

    for (PartitionHandler handler : partitionHandlers) {
        if (handler instanceof AbstractPartitionHandler) {
            ((AbstractPartitionHandler) handler).setBatchAppmaster(this);
        }
    }

    try {
        getYarnJobLauncher().run(getParameters());
    } catch (JobExecutionException e) {
        log.error("Error in jobLauncherHelper", e);
        setFinalApplicationStatus(FinalApplicationStatus.FAILED);
    }
    for (JobExecution jobExecution : jobExecutions) {
        if (jobExecution.getStatus().equals(BatchStatus.FAILED)) {
            setFinalApplicationStatus(FinalApplicationStatus.FAILED);
            break;
        }
    }
    notifyCompleted();
}

From source file:org.springframework.yarn.examples.AbstractManagedContainerGroupsAppmaster.java

License:Apache License

@Override
protected void onContainerCompleted(ContainerStatus status) {
    log.info("XXX onContainerCompleted: " + status);
    super.onContainerCompleted(status);

    getMonitor().monitorContainer(status);

    int exitStatus = status.getExitStatus();
    ContainerId containerId = status.getContainerId();

    boolean handled = false;
    if (exitStatus > 0) {
        handled = onContainerFailed(containerId);
        if (!handled) {
            setFinalApplicationStatus(FinalApplicationStatus.FAILED);
            notifyCompleted();/*  w  ww  .j  a va2 s . c o  m*/
        }
    } else {
        if (isComplete()) {
            notifyCompleted();
        }
    }
}

From source file:org.starschema.hadoop.yarn.applications.distributedshell.ApplicationMaster.java

License:Apache License

@VisibleForTesting
protected boolean finish() {
    // wait for completion.
    while (!done && (numCompletedContainers.get() < numTotalContainers)) {
        try {//from w  ww.j  a  va  2 s .  c  om
            Thread.sleep(200);
        } catch (InterruptedException ex) {
        }
    }

    if (timelineClient != null) {
        publishApplicationAttemptEvent(timelineClient, appAttemptID.toString(), DSEvent.DS_APP_ATTEMPT_END,
                domainId, appSubmitterUgi);
    }

    // Join all launched threads
    // needed for when we time out
    // and we need to release containers
    for (Thread launchThread : launchThreads) {
        try {
            launchThread.join(10000);
        } catch (InterruptedException e) {
            LOG.info("Exception thrown in thread join: " + e.getMessage());
            e.printStackTrace();
        }
    }

    // When the application completes, it should stop all running containers
    LOG.info("Application completed. Stopping running containers");
    nmClientAsync.stop();

    // When the application completes, it should send a finish application
    // signal to the RM
    LOG.info("Application completed. Signalling finish to RM");

    FinalApplicationStatus appStatus;
    String appMessage = null;
    boolean success = true;
    if (numFailedContainers.get() == 0 && numCompletedContainers.get() >= numTotalContainers) {
        appStatus = FinalApplicationStatus.SUCCEEDED;
    } else {
        appStatus = FinalApplicationStatus.FAILED;
        appMessage = "Diagnostics." + ", total=" + numTotalContainers + ", completed="
                + numCompletedContainers.get() + ", allocated=" + numAllocatedContainers.get() + ", failed="
                + numFailedContainers.get();
        LOG.info(appMessage);
        success = false;
    }
    try {
        amRMClient.unregisterApplicationMaster(appStatus, appMessage, null);
    } catch (YarnException ex) {
        LOG.error("Failed to unregister application", ex);
    } catch (IOException e) {
        LOG.error("Failed to unregister application", e);
    }

    amRMClient.stop();

    // Stop Timeline Client
    if (timelineClient != null) {
        timelineClient.stop();
    }

    return success;
}

From source file:oz.hadoop.yarn.api.core.ApplicationContainerLauncherImpl.java

License:Apache License

/**
 * /* w  ww . j a va 2 s  .c  o m*/
 */
@Override
void doShutDown() throws Exception {
    String suffix = this.applicationSpecification.getString(YayaConstants.APPLICATION_NAME) + "_master/"
            + this.applicationSpecification.getInt(YayaConstants.APP_ID) + "/";
    FileSystem fs = FileSystem.get(this.yarnConfig);
    Path dst = new Path(fs.getHomeDirectory(), suffix);
    fs.delete(dst, true);
    if (logger.isInfoEnabled()) {
        logger.info("Deleted application jars: " + dst.toString());
    }

    FinalApplicationStatus status = (this.error != null) ? FinalApplicationStatus.FAILED
            : FinalApplicationStatus.SUCCEEDED;
    //this.resourceManagerClient.getClusterNodeCount()
    //this.resourceManagerClient.getFailureCause()
    logger.info("Unregistering the Application Master");
    this.resourceManagerClient.unregisterApplicationMaster(status, this.generateExitMessage(status), null);

    logger.info("Shutting down Node Manager Client");
    this.nodeManagerClient.stop();
    logger.info("Shutting down Resource Manager Client");
    this.resourceManagerClient.stop();
}

From source file:oz.hadoop.yarn.api.core.ApplicationContainerLauncherImpl.java

License:Apache License

/**
 *
 * @param status/*from w ww. j  a  v  a  2s . c o m*/
 * @return
 */
private String generateExitMessage(FinalApplicationStatus status) {
    StringBuffer exitMessage = new StringBuffer();
    exitMessage.append("Application '");
    exitMessage.append(this.applicationSpecification.getString(YayaConstants.APPLICATION_NAME));
    exitMessage.append("' launched by ");
    exitMessage.append(this.getClass().getName());
    exitMessage.append(" has finished");
    if (status == FinalApplicationStatus.FAILED) {
        exitMessage.append(" with failure. Diagnostic information: " + this.error.getMessage());
    } else {
        exitMessage.append(" successfully.");
    }
    return exitMessage.toString();
}

From source file:x10.x10rt.yarn.ApplicationMaster.java

License:Open Source License

protected boolean shutdown() {

    // close selector, and any remaining links to places
    try {/*  ww  w  .jav  a 2s.  c om*/
        selector.close();
    } catch (IOException e1) {
        // shutting down... ignore
    }
    links.clear();
    places.clear();

    // When the application completes, it should stop all running containers
    LOG.info("X10 program " + appName + " completed. Stopping running containers");
    nodeManager.stop();
    // When the application completes, it should send a finish application
    // signal to the RM
    LOG.info("Signalling finish to RM");
    FinalApplicationStatus appStatus;
    String appMessage = null;
    boolean success = true;
    if (numFailedContainers.get() == 0) {
        appStatus = FinalApplicationStatus.SUCCEEDED;
    } else {
        appStatus = FinalApplicationStatus.FAILED;
        appMessage = "Diagnostics." + ", total=" + numRequestedContainers.get() + ", completed="
                + numCompletedContainers.get() + ", allocated=" + numAllocatedContainers.get() + ", failed="
                + numFailedContainers.get() + ", extra=" + numExtraContainers.get();
        success = false;
    }
    try {
        resourceManager.unregisterApplicationMaster(appStatus, appMessage, null);
    } catch (YarnException ex) {
        LOG.error("Failed to unregister application", ex);
    } catch (IOException e) {
        LOG.error("Failed to unregister application", e);
    }
    resourceManager.stop();
    return success;
}

From source file:yarnkit.appmaster.ApplicationMasterService.java

License:Apache License

@Override
protected void shutDown() throws Exception {
    LOG.info("Stopping Containers");

    // stop containers
    tracker.kill();/*from www . j  a  v a 2 s  .c  o m*/
    this.hasRunningContainers = false;

    // unregister application master
    final FinalApplicationStatus status;
    String message = null;
    if (state() == State.FAILED || totalFailures.get() > parameters.getAllowedFailures()) {
        status = FinalApplicationStatus.FAILED;
        if (throwable != null) {
            message = throwable.getLocalizedMessage();
        }
    } else {
        status = FinalApplicationStatus.SUCCEEDED;
    }
    LOG.info("Sending a finish request to Resource Manager: " + status);
    try {
        resourceManager.unregisterApplicationMaster(status, message, null);
    } catch (Exception e) {
        LOG.error("Error finishing Application Master", e);
    }
}