diff options
Diffstat (limited to 'config-model/src/main/java/com/yahoo/vespa/model/content/cluster/RedundancyBuilder.java')
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/content/cluster/RedundancyBuilder.java | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/RedundancyBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/RedundancyBuilder.java index e7bafdf52e4..d310db067a6 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/RedundancyBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/RedundancyBuilder.java @@ -20,7 +20,7 @@ public class RedundancyBuilder { // Always global (across groups) private Integer globalMinRedundancy = null; - RedundancyBuilder(ModelElement clusterXml) { + public RedundancyBuilder(ModelElement clusterXml) { ModelElement redundancyElement = clusterXml.child("redundancy"); if (redundancyElement != null) { initialRedundancy = redundancyElement.integerAttribute("reply-after"); @@ -47,22 +47,40 @@ public class RedundancyBuilder { throw new IllegalArgumentException("Either <redundancy> or <min-redundancy> must be set"); } - public Redundancy build(boolean isHosted, int subGroups, int leafGroups, int 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 + */ + 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 (leafGroups > 1) - readyCopies = 1; - else - readyCopies = finalRedundancy > 1 ? 2 : 1; + 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; + } } return new Redundancy(initialRedundancy, finalRedundancy, readyCopies, leafGroups, totalNodes); } else { if (globalMinRedundancy != null && ( finalRedundancy == null || finalRedundancy < globalMinRedundancy)) initialRedundancy = finalRedundancy = globalMinRedundancy; - if (readyCopies == null) - readyCopies = finalRedundancy > 1 ? Math.max(subGroups, 2) : 1; + 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); |