private RequestStageContainer createRequest(UpgradeContext upgradeContext) throws AmbariException {
    ActionManager actionManager = getManagementController().getActionManager();

    RequestStageContainer requestStages = new RequestStageContainer(
        actionManager.getNextRequestId(), null, s_requestFactory.get(), actionManager);

    Direction direction = upgradeContext.getDirection();
    RepositoryVersionEntity repositoryVersion = upgradeContext.getRepositoryVersion();

    requestStages.setRequestContext(String.format("%s %s %s", direction.getVerb(true),
        direction.getPreposition(), repositoryVersion.getVersion()));

    return requestStages;
  }
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