@Test public void missingClusterVersionShouldNotCauseException() throws Exception { init(false); activeRepoUpdater.process(); }
@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) { StackInfo stack = stackManager.getStack(cluster.getDesiredStack().getStackName(), cluster.getDesiredStack().getStackVersion()); LOG.info("Updating existing repo versions for cluster {} on stack {}-{}", cluster.getClusterName(), stack.getName(), stack.getVersion()); ClusterVersionEntity clusterVersion = clusterVersionDao.findByClusterAndStateCurrent(cluster.getClusterName()); if (null != clusterVersion) { RepositoryVersionEntity repoVersion = clusterVersion.getRepositoryVersion(); updateRepoVersion(stack, repoVersion); repositoryVersionDao.merge(repoVersion); } else { LOG.warn("Missing cluster version for cluster {}", cluster.getClusterName()); } } } catch(Exception ex) { throw new AmbariException( "An error occured during updating current repository versions with stack repositories.", ex); } }
UpdateActiveRepoVersionOnStartup { @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) { StackInfo stack = stackManager.getStack(cluster.getDesiredStack().getStackName(), cluster.getDesiredStack().getStackVersion()); LOG.info("Updating existing repo versions for cluster {} on stack {}-{}", cluster.getClusterName(), stack.getName(), stack.getVersion()); ClusterVersionEntity clusterVersion = clusterVersionDao.findByClusterAndStateCurrent(cluster.getClusterName()); if (null != clusterVersion) { RepositoryVersionEntity repoVersion = clusterVersion.getRepositoryVersion(); updateRepoVersion(stack, repoVersion); repositoryVersionDao.merge(repoVersion); } else { LOG.warn("Missing cluster version for cluster {}", cluster.getClusterName()); } } } catch(Exception ex) { throw new AmbariException( "An error occured during updating current repository versions with stack repositories.", ex); } } }
UpdateActiveRepoVersionOnStartup { @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) { StackInfo stack = stackManager.getStack(cluster.getDesiredStack().getStackName(), cluster.getDesiredStack().getStackVersion()); LOG.info("Updating existing repo versions for cluster {} on stack {}-{}", cluster.getClusterName(), stack.getName(), stack.getVersion()); ClusterVersionEntity clusterVersion = clusterVersionDao.findByClusterAndStateCurrent(cluster.getClusterName()); if (null != clusterVersion) { RepositoryVersionEntity repoVersion = clusterVersion.getRepositoryVersion(); updateRepoVersion(stack, repoVersion); repositoryVersionDao.merge(repoVersion); } else { LOG.warn("Missing cluster version for cluster {}", cluster.getClusterName()); } } } catch(Exception ex) { throw new AmbariException( "An error occured during updating current repository versions with stack repositories.", ex); } } @Inject  UpdateActiveRepoVersionOnStartup(ClusterDAO clusterDao,
      ClusterVersionDAO clusterVersionDao,
      RepositoryVersionDAO repositoryVersionDao,
      RepositoryVersionHelper repositoryVersionHelper,
      AmbariMetaInfo metaInfo); }
UpdateActiveRepoVersionOnStartup { @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) { StackInfo stack = stackManager.getStack(cluster.getDesiredStack().getStackName(), cluster.getDesiredStack().getStackVersion()); LOG.info("Updating existing repo versions for cluster {} on stack {}-{}", cluster.getClusterName(), stack.getName(), stack.getVersion()); ClusterVersionEntity clusterVersion = clusterVersionDao.findByClusterAndStateCurrent(cluster.getClusterName()); if (null != clusterVersion) { RepositoryVersionEntity repoVersion = clusterVersion.getRepositoryVersion(); updateRepoVersion(stack, repoVersion); repositoryVersionDao.merge(repoVersion); } else { LOG.warn("Missing cluster version for cluster {}", cluster.getClusterName()); } } } catch(Exception ex) { throw new AmbariException( "An error occured during updating current repository versions with stack repositories.", ex); } } @Inject  UpdateActiveRepoVersionOnStartup(ClusterDAO clusterDao,
      ClusterVersionDAO clusterVersionDao,
      RepositoryVersionDAO repositoryVersionDao,
      RepositoryVersionHelper repositoryVersionHelper,
      AmbariMetaInfo metaInfo); @Transactional void process(); }
UpdateActiveRepoVersionOnStartup { @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) { StackInfo stack = stackManager.getStack(cluster.getDesiredStack().getStackName(), cluster.getDesiredStack().getStackVersion()); LOG.info("Updating existing repo versions for cluster {} on stack {}-{}", cluster.getClusterName(), stack.getName(), stack.getVersion()); ClusterVersionEntity clusterVersion = clusterVersionDao.findByClusterAndStateCurrent(cluster.getClusterName()); if (null != clusterVersion) { RepositoryVersionEntity repoVersion = clusterVersion.getRepositoryVersion(); updateRepoVersion(stack, repoVersion); repositoryVersionDao.merge(repoVersion); } else { LOG.warn("Missing cluster version for cluster {}", cluster.getClusterName()); } } } catch(Exception ex) { throw new AmbariException( "An error occured during updating current repository versions with stack repositories.", ex); } } @Inject  UpdateActiveRepoVersionOnStartup(ClusterDAO clusterDao,
      ClusterVersionDAO clusterVersionDao,
      RepositoryVersionDAO repositoryVersionDao,
      RepositoryVersionHelper repositoryVersionHelper,
      AmbariMetaInfo metaInfo); @Transactional void process();  }