private RepositoryVersionEntity getComponentRepositoryVersion(Long clusterId, String serviceName, String componentName) throws AmbariException {
    RepositoryVersionEntity repositoryVersion = null;
    if (!StringUtils.isEmpty(serviceName)) {
      Service service = clusters.getCluster(clusterId).getService(serviceName);
      if (null != service) {
        repositoryVersion = service.getDesiredRepositoryVersion();

        if (!StringUtils.isEmpty(componentName) && service.getServiceComponents().containsKey(componentName)) {
          ServiceComponent serviceComponent = service.getServiceComponent(componentName);
          if (null != serviceComponent) {
            repositoryVersion = serviceComponent.getDesiredRepositoryVersion();
          }
        }
      }
    }
    return repositoryVersion;
  }
Collects full metadata info about clusters for agent.
@return metadata info about clusters
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java