private Set<Version> findVersionsToBuild(ApplicationPackage applicationPackage) {
        Set<Version> versions = modelFactoryRegistry.allVersions();

        // If the application specifies a major, skip models on a newer major
        Optional<Integer> requestedMajorVersion = applicationPackage.getMajorVersion();
        if (requestedMajorVersion.isPresent()) {
            versions = keepUpToMajorVersion(requestedMajorVersion.get(), versions);
            if (versions.isEmpty())
                throw new UnknownVespaVersionException("No Vespa versions on or before major version " +
                                                       requestedMajorVersion.get() + " are present");
        }
        return versions;
    }
Builds all applicable model versions

@param allocatedHosts the newest version (major and minor) (which is loaded first) decides the allocated hosts
                      and assigns to this SettableOptional such that it can be used after this method returns
configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java