public Redundancy build(boolean isHosted, Boolean isStreaming, int subGroups, int leafGroups,  int totalNodes) {
        if (isHosted) {
            if (globalMinRedundancy != null && ( finalRedundancy == null || finalRedundancy * leafGroups < globalMinRedundancy ))
                initialRedundancy = finalRedundancy = (int)Math.ceil((double)globalMinRedundancy / leafGroups);
            if (readyCopies == null) {
                if (isStreaming == Boolean.TRUE) {
                    readyCopies = finalRedundancy;
                }
                else { // If isStreaming is null (mixed mode cluster) there are no good options ...
                    if (leafGroups > 1)
                        readyCopies = 1;
                    else
                        readyCopies = finalRedundancy > 1 ? 2 : 1;
                }
            }
            else {
                readyCopies = Math.min(readyCopies, finalRedundancy);
            }
            return new Redundancy(initialRedundancy, finalRedundancy, readyCopies, leafGroups, totalNodes);
        } else {
            if (globalMinRedundancy != null && ( finalRedundancy == null || finalRedundancy < globalMinRedundancy))
                initialRedundancy = finalRedundancy = globalMinRedundancy;
            if (readyCopies == null) {
                if (isStreaming == Boolean.TRUE)
                    readyCopies = finalRedundancy;
                else // If isStreaming is null (mixed mode cluster) there are no good options ...
                    readyCopies = finalRedundancy > 1 ? Math.max(subGroups, 2) : 1;
            }
            subGroups = Math.max(1, subGroups);
            IndexedHierarchicDistributionValidator.validateThatLeafGroupsCountIsAFactorOfRedundancy(finalRedundancy, subGroups);
            IndexedHierarchicDistributionValidator.validateThatReadyCopiesIsCompatibleWithRedundancy(finalRedundancy, readyCopies, subGroups);
            if (initialRedundancy == null)
                initialRedundancy = finalRedundancy;
            return new Redundancy(initialRedundancy/subGroups, finalRedundancy/subGroups,
                                  readyCopies/subGroups, subGroups, totalNodes);
        }
    }
@param isHosted
@param isStreaming true if this cluster only has schemas with streaming mode, false if it only has schemas
                   without streaming, null if it has both
@param subGroups
@param leafGroups
@param totalNodes
@return
config-model/src/main/java/com/yahoo/vespa/model/content/cluster/RedundancyBuilder.java