private int getMaintenanceOffSCHCountByState(State state) {
    int count = 0;
    for (ServiceComponentHost sch : hostComponents.values()) {
      try {
        MaintenanceState effectiveMaintenanceState = maintenanceStateHelper.getEffectiveState(sch, sch.getHost());
        if (sch.getState() == state && effectiveMaintenanceState == MaintenanceState.OFF) {
          count++;
        }
      } catch (AmbariException e) {
        e.printStackTrace();
      }
    }
    return count;
  }
Count the ServiceComponentHosts that have given state and are effectively not in maintenanceMode
@param state
@return
ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java