Example usage for org.apache.hadoop.yarn.api.records ContainerStatus setExitStatus

List of usage examples for org.apache.hadoop.yarn.api.records ContainerStatus setExitStatus

Introduction

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

Prototype

@Private
    @Unstable
    public abstract void setExitStatus(int exitStatus);

Source Link

Usage

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

License:Apache License

/**
 * /*from  w w  w .  j a v a  2 s . c o m*/
 */
@Override
void containerAllocated(final Container allocatedContainer) {
    final ApplicationContainer applicationContainer = applicationContainers.get(allocatedContainer);
    if (logger.isDebugEnabled()) {
        logger.debug("Container allocated");
    }
    final AtomicBoolean errorFlag = new AtomicBoolean();
    this.executor.execute(new Runnable() {
        @Override
        public void run() {
            ContainerStatus containerStatus = new ContainerStatusPBImpl();
            try {
                applicationContainer.launch();
                logger.info("Container finished");
                // TODO implement a better mock so it can show ContainerRequest values

                containerStatus.setExitStatus(0);
                //               rmCallbackHandler.onContainersCompleted(Collections.singletonList(containerStatus));
            } catch (Exception e) {
                logger.error("Application Container failed. ", e);
                //               rmCallbackHandler.onError(e);
                containerStatus.setExitStatus(0);
                errorFlag.set(true);
            } finally {
                rmCallbackHandler.onContainersCompleted(Collections.singletonList(containerStatus));
            }
        }
    });

    this.executor.execute(new Runnable() {
        @Override
        public void run() {
            try {
                //               Field clientField = ReflectionUtils.getFieldAndMakeAccessible(ApplicationContainer.class, "client");
                //               while (clientField.get(applicationContainer) == null && !errorFlag.get()){
                //                  LockSupport.parkNanos(1000000);
                //               }
                awaitApplicationContainerStart(applicationContainer, errorFlag);
                if (!errorFlag.get()) {
                    nmCallbackHandler.onContainerStarted(allocatedContainer.getId(), null);
                    if (logger.isDebugEnabled()) {
                        logger.debug("Container started");
                    }
                }
            } catch (Exception e) {
                logger.error("Should never heppen. Must be a bug. Please report", e);
                e.printStackTrace();
            }
        }
    });
}