Example usage for org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt RMAppAttempt getFinalApplicationStatus

List of usage examples for org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt RMAppAttempt getFinalApplicationStatus

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt RMAppAttempt getFinalApplicationStatus.

Prototype

FinalApplicationStatus getFinalApplicationStatus();

Source Link

Document

The final status set by the AM.

Usage

From source file:io.hops.ha.common.TransactionStateImpl.java

License:Apache License

private void persistAppAttempt() throws IOException {
    if (!appAttempts.isEmpty()) {
        ApplicationAttemptStateDataAccess DA = (ApplicationAttemptStateDataAccess) RMStorageFactory
                .getDataAccess(ApplicationAttemptStateDataAccess.class);
        List<ApplicationAttemptState> toAdd = new ArrayList<ApplicationAttemptState>();
        for (String appAttemptIdStr : appAttempts.keySet()) {
            RMAppAttempt appAttempt = appAttempts.get(appAttemptIdStr);
            String appIdStr = appAttempt.getAppAttemptId().getApplicationId().toString();

            Credentials credentials = appAttempt.getCredentials();
            ByteBuffer appAttemptTokens = null;

            if (credentials != null) {
                DataOutputBuffer dob = new DataOutputBuffer();
                credentials.writeTokenStorageToStream(dob);
                appAttemptTokens = ByteBuffer.wrap(dob.getData(), 0, dob.getLength());
            }//w ww  .  j  a v  a 2 s .  co m
            ApplicationAttemptStateDataPBImpl attemptStateData = (ApplicationAttemptStateDataPBImpl) ApplicationAttemptStateDataPBImpl
                    .newApplicationAttemptStateData(appAttempt.getAppAttemptId(),
                            appAttempt.getMasterContainer(), appAttemptTokens, appAttempt.getStartTime(),
                            appAttempt.getState(), appAttempt.getOriginalTrackingUrl(),
                            appAttempt.getDiagnostics(), appAttempt.getFinalApplicationStatus(),
                            appAttempt.getRanNodes(), appAttempt.getJustFinishedContainers(),
                            appAttempt.getProgress(), appAttempt.getHost(), appAttempt.getRpcPort());

            byte[] attemptIdByteArray = attemptStateData.getProto().toByteArray();
            LOG.debug("adding appAttempt : " + appAttempt.getAppAttemptId() + " with state "
                    + appAttempt.getState());
            toAdd.add(new ApplicationAttemptState(appIdStr, appAttemptIdStr, attemptIdByteArray,
                    appAttempt.getHost(), appAttempt.getRpcPort(), appAttemptTokens,
                    appAttempt.getTrackingUrl()));
        }
        DA.addAll(toAdd);
    }
}