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

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

Introduction

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

Prototype

float getProgress();

Source Link

Document

Progress for the application attempt.

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());
            }/*from w w  w . j  a v  a2  s.  c o 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);
    }
}