private void createStage(UpgradeGroupHolder group, UpgradeContext context,
      StackId stackId,
      RequestStageContainer request, UpgradeItemEntity entity, StageWrapper wrapper)
          throws AmbariException {

    boolean skippable = group.skippable;
    boolean supportsAutoSkipOnFailure = group.supportsAutoSkipOnFailure;
    boolean allowRetry = group.allowRetry;

    switch (wrapper.getType()) {
      case CONFIGURE:
      case START:
      case STOP:
      case RESTART:
        makeCommandStage(context, request, stackId, entity, wrapper, skippable,
            supportsAutoSkipOnFailure, allowRetry);
        break;
      case UPGRADE_TASKS:
        makeActionStage(context, request, stackId, entity, wrapper, skippable,
            supportsAutoSkipOnFailure, allowRetry);
        break;
      case SERVICE_CHECK:
        makeServiceCheckStage(context, request, stackId, entity, wrapper,
            skippable, supportsAutoSkipOnFailure, allowRetry);
        break;
      default:
        break;
    }
  }
Creates the Request/Stage/Task entities and the Upgrade entities inside of
a single transaction. We break this out since the work to get us to this
point could take a very long time and involve many queries to the database
as the commands are being built.

@param cluster
         the cluster (not {@code null}).
@param request
         the request to persist with all stages and tasks created in memory
         (not {@code null}).
@param upgradeEntity
         the upgrade to create and associate with the newly created request
         (not {@code null}).
@param upgradeContext
         the upgrade context associated with the upgrade being created.
@return the persisted {@link UpgradeEntity} encapsulating all
        {@link UpgradeGroupEntity} and {@link UpgradeItemEntity}.
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java