@Override
    public List<StageWrapper> build(UpgradeContext upgradeContext,
        List<StageWrapper> stageWrappers) {

      // insert all pre-processed stage wrappers first
      if (!stageWrappers.isEmpty()) {
        m_stages.addAll(0, stageWrappers);
      }

      List<TaskWrapper> tasks = new ArrayList<>();
      List<String> displays = new ArrayList<>();
      for (String service : m_servicesToCheck) {
        tasks.add(new TaskWrapper(
            service, "", Collections.emptySet(), new ServiceCheckTask()));

        displays.add(upgradeContext.getServiceDisplay(service));
      }

      if (upgradeContext.getDirection().isUpgrade() && m_serviceCheck
          && m_servicesToCheck.size() > 0) {

        StageWrapper wrapper = new StageWrapper(StageWrapper.Type.SERVICE_CHECK,
            "Service Check " + StringUtils.join(displays, ", "), tasks.toArray(new TaskWrapper[0]));

        m_stages.add(wrapper);
      }

      return m_stages;
    }
Determine if service checks need to be ran after the stages.
@param upgradeContext the upgrade context
@return Return the stages, which may potentially be followed by service checks.
ambari-server/src/main/java/org/apache/ambari/server/stack/upgrade/Grouping.java