@Override
  public Void call() throws Exception {

    Type type = new TypeToken<Map<String, Map<String, Object>>>(){}.getType();
    Gson gson = new Gson();

    Map<String, Map<String, Object>> latestUrlMap = null;

    Long time = System.currentTimeMillis();
    try {
      if (sourceUri.startsWith("http")) {

        URLStreamProvider streamProvider = new URLStreamProvider(
            LOOKUP_CONNECTION_TIMEOUT, LOOKUP_READ_TIMEOUT,
            null, null, null);

        LOG.info("Loading latest URL info for stack {}-{} from {}", stack.getName(),
                stack.getVersion(), sourceUri);

        latestUrlMap = gson.fromJson(new InputStreamReader(
            streamProvider.readFrom(sourceUri)), type);
      } else {
        File jsonFile = null;
        if (sourceUri.charAt(0) == '.') {
          jsonFile = new File(stackRepoFolder, sourceUri);
        } else {
          jsonFile = new File(sourceUri);
        }

        if (jsonFile.exists()) {
          LOG.info("Loading latest URL info for stack {}-{} from {}", stack.getName(),
                  stack.getVersion(), jsonFile);
          latestUrlMap = gson.fromJson(new FileReader(jsonFile), type);
        }
      }
    } catch (Exception e) {
      LOG.info("Could not load the URI for stack {}-{} from {}, ({}).  Using default repository values",
          stack.getName(), stack.getVersion(), sourceUri, e.getMessage());
      throw e;
    } finally {
      LOG.info("Loaded uri {} in {}ms", sourceUri, System.currentTimeMillis() - time);
    }

    StackId stackId = new StackId(stack);
    if (latestUrlMap == null || !latestUrlMap.containsKey(stackId.toString())) {
      return null;
    }

    Map<String, Object> map = latestUrlMap.get(stackId.toString());
    if (null == map) {
      return null;
    }

    // !!! use this to prevent double loading of VDF.
    Map<URI, VersionDefinitionXml> parsedMap = new HashMap<>();

    if (map.containsKey("manifests")) {

      @SuppressWarnings("unchecked")
      Map<String, Object> versionMap = (Map<String, Object>) map.get("manifests");

      // EACH VDF is for ONLY ONE repository.  We must provide a merged view.
      // there is no good way around this, so we have to make some concessions

      // !!! each key is a version number, and the value is a map containing
      // os_family -> VDF link

      for (Entry<String, Object> entry : versionMap.entrySet()) {
        String version = entry.getKey();

        @SuppressWarnings("unchecked")
        Map<String, String> osMap = (Map<String, String>) entry.getValue();

        VersionDefinitionXml xml = mergeDefinitions(stackId, version, osMap, parsedMap);

        if (null != xml) {
          stack.addVersionDefinition(version, xml);
        }
      }
    }

    if (map.containsKey("latest-vdf")) {
      // !!! this is an os_family -> VDF link.  It's identical to the version entry in the 'manifests'
      // structure.  This is the source of truth for the default, unspecified version when
      // doing a bluerpint install
      @SuppressWarnings("unchecked")
      Map<String, String> osMap = (Map<String, String>) map.get("latest-vdf");

      VersionDefinitionXml xml = mergeDefinitions(stackId, null, osMap, parsedMap);
      xml.setStackDefault(true);
      stack.setLatestVersionDefinition(xml);
    }

    return null;
  }
Encapsulates the work to resolve the latest repo information for a stack.
This class must be used AFTER the stack has created its owned repositories.
ambari-server/src/main/java/org/apache/ambari/server/state/stack/LatestRepoCallable.java