/** * Helper method to determine if a cluster application is running -or * is earlier in the lifecycle * @param app application report * @return true if the application is considered live */ public boolean isApplicationLive(ApplicationReport app) { Preconditions.checkArgument(app != null, "Null app report"); return app.getYarnApplicationState().ordinal() <= YarnApplicationState.RUNNING.ordinal(); }
/** * Helper method to determine if a cluster application is running -or * is earlier in the lifecycle * @param app application report * @return true if the application is considered live */ public boolean isApplicationLive(ApplicationReport app) { Preconditions.checkArgument(app != null, "Null app report"); return app.getYarnApplicationState().ordinal() <= YarnApplicationState.RUNNING.ordinal(); }
/** * Built a (sorted) map of application reports, mapped to the instance name * The list is sorted, and the addition process does not add a report * if there is already one that exists. If the list handed in is sorted, * those that are listed first form the entries returned * @param instances list of intances * @param minState minimum YARN state to be included * @param maxState maximum YARN state to be included * @return all reports in the list whose state >= minimum and <= maximum */ public static Map<String, ApplicationReport> buildApplicationReportMap( List<ApplicationReport> instances, YarnApplicationState minState, YarnApplicationState maxState) { TreeMap<String, ApplicationReport> map = new TreeMap<>(); for (ApplicationReport report : instances) { YarnApplicationState state = report.getYarnApplicationState(); if (state.ordinal() >= minState.ordinal() && state.ordinal() <= maxState.ordinal() && map.get(report.getName()) == null) { map.put(report.getName(), report); } } return map; }
/** * Built a (sorted) map of application reports, mapped to the instance name * The list is sorted, and the addition process does not add a report * if there is already one that exists. If the list handed in is sorted, * those that are listed first form the entries returned * @param instances list of intances * @param minState minimum YARN state to be included * @param maxState maximum YARN state to be included * @return all reports in the list whose state >= minimum and <= maximum */ public static Map<String, ApplicationReport> buildApplicationReportMap( List<ApplicationReport> instances, YarnApplicationState minState, YarnApplicationState maxState) { TreeMap<String, ApplicationReport> map = new TreeMap<>(); for (ApplicationReport report : instances) { YarnApplicationState state = report.getYarnApplicationState(); if (state.ordinal() >= minState.ordinal() && state.ordinal() <= maxState.ordinal() && map.get(report.getName()) == null) { map.put(report.getName(), report); } } return map; }
private boolean isAppInRunningState(String clustername) throws YarnException, IOException { // is this actually a known cluster? sliderFileSystem.locateInstanceDefinition(clustername); ApplicationReport app = findInstance(clustername); if (app == null) { // exit early log.info("Cluster {} not running", clustername); return false; } log.debug("App to upgrade was found: {}:\n{}", clustername, new OnDemandReportStringifier(app)); if (app.getYarnApplicationState().ordinal() >= YarnApplicationState.FINISHED.ordinal()) { log.info("Cluster {} is in a terminated state {}. Use command '{}' instead.", clustername, app.getYarnApplicationState(), ACTION_UPDATE); return false; } // IPC request to upgrade containers is possible if the app is running. if (app.getYarnApplicationState().ordinal() < YarnApplicationState.RUNNING .ordinal()) { log.info("Cluster {} is in a pre-running state {}. To upgrade it needs " + "to be RUNNING.", clustername, app.getYarnApplicationState()); return false; } return true; }
private boolean isAppInRunningState(String clustername) throws YarnException, IOException { // is this actually a known cluster? sliderFileSystem.locateInstanceDefinition(clustername); ApplicationReport app = findInstance(clustername); if (app == null) { // exit early log.info("Cluster {} not running", clustername); return false; } log.debug("App to upgrade was found: {}:\n{}", clustername, new OnDemandReportStringifier(app)); if (app.getYarnApplicationState().ordinal() >= YarnApplicationState.FINISHED.ordinal()) { log.info("Cluster {} is in a terminated state {}. Use command '{}' instead.", clustername, app.getYarnApplicationState(), ACTION_UPDATE); return false; } // IPC request to upgrade containers is possible if the app is running. if (app.getYarnApplicationState().ordinal() < YarnApplicationState.RUNNING .ordinal()) { log.info("Cluster {} is in a pre-running state {}. To upgrade it needs " + "to be RUNNING.", clustername, app.getYarnApplicationState()); return false; } return true; }
if (app.getYarnApplicationState().ordinal() >= YarnApplicationState.FINISHED.ordinal()) { log.info("Cluster {} is in a terminated state {}", clustername, app.getYarnApplicationState()); && app.getYarnApplicationState().ordinal() < YarnApplicationState.RUNNING.ordinal()) { log.info("Cluster {} is in a pre-running state {}. Force killing it", clustername, app.getYarnApplicationState());
if (app.getYarnApplicationState().ordinal() >= YarnApplicationState.FINISHED.ordinal()) { log.info("Cluster {} is in a terminated state {}", clustername, app.getYarnApplicationState()); && app.getYarnApplicationState().ordinal() < YarnApplicationState.RUNNING.ordinal()) { log.info("Cluster {} is in a pre-running state {}. Force killing it", clustername, app.getYarnApplicationState());