@Transactional
  public void process() throws AmbariException {
    LOG.info("Updating existing repo versions with service repos.");

    try {

      List<ClusterEntity> clusters = clusterDao.findAll();
      for (ClusterEntity cluster: clusters) {
        for (ClusterServiceEntity service : cluster.getClusterServiceEntities()) {
          RepositoryVersionEntity repositoryVersion = service.getServiceDesiredStateEntity().getDesiredRepositoryVersion();

          StackId stackId = repositoryVersion.getStackId();
          StackInfo stack = stackManager.getStack(stackId.getStackName(), stackId.getStackVersion());
        
          if (stack !=null) {
            if (updateRepoVersion(stack, repositoryVersion)) {
              repositoryVersionDao.merge(repositoryVersion);
            }
          } else {
	    throw new AmbariException(String.format("Stack %s %s was not found on the file system. In the event that it was removed, " +
              "please ensure that it exists before starting Ambari Server.",  stackId.getStackName(), stackId.getStackVersion()));
          } 
        }
      }
    }
    catch(Exception ex) {
      throw new AmbariException(
          "An error occured during updating current repository versions with stack repositories.",
          ex);
    }
  }
Updates the active {@link RepositoryVersionEntity} for clusters with add-on services defined in management packs.
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/stack/UpdateActiveRepoVersionOnStartup.java