Enable 16 distribution bits only for prod regions
@@ -6,6 +6,7 @@ import com.google.common.collect.Sets;
import com.yahoo.config.model.ConfigModelContext;
import com.yahoo.config.model.producer.AbstractConfigProducerRoot;
import com.yahoo.config.provision.ClusterSpec;
+import com.yahoo.config.provision.Environment;
import com.yahoo.config.provision.RegionName;
import com.yahoo.config.provision.Zone;
import com.yahoo.vespa.config.content.MessagetyperouteselectorpolicyConfig;
@@ -46,6 +47,7 @@ import org.w3c.dom.Element;
import java.util.*;
import java.util.logging.Level;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* A content cluster.
@@ -585,18 +587,19 @@ public class ContentCluster extends AbstractConfigProducer implements StorDistri
/**
* Returns the distribution bits this cluster should use.
- * OnHosted Vespa this is hardcoded not computed from the nodes because reducing the number of nodes is a common
- * operation while reducing the number of distribution bits can lead to consistency problems.
+ * On Hosted Vespa this is hardcoded and not computed from the nodes because reducing the number of nodes is a common
+ * operation, while reducing the number of distribution bits can lead to consistency problems.
* This hardcoded value should work fine from 1-200 nodes. Those who have more will need to set this value
* in config and not remove it again if they reduce the node count.
*/
public int distributionBits() {
- if (zone.region().equals(RegionName.from("us-west-1"))) return 16; // TODO: Enable for all hosted zones (i.e when zone isn't default)
- if (zone.region().equals(RegionName.from("us-central-1"))) return 16; // TODO: Enable for all hosted zones (i.e when zone isn't default)
- if (zone.region().equals(RegionName.from("eu-west-1"))) return 16; // TODO: Enable for all hosted zones (i.e when zone isn't default)
- if (zone.region().equals(RegionName.from("ap-northeast-1"))) return 16; // TODO: Enable for all hosted zones (i.e when zone isn't default)
- if (zone.region().equals(RegionName.from("ap-northeast-2"))) return 16; // TODO: Enable for all hosted zones (i.e when zone isn't default)
- if (zone.region().equals(RegionName.from("us-east-3"))) return 16; // TODO: Enable for all hosted zones (i.e when zone isn't default)
+ // TODO: Enable for all hosted zones (i.e when zone isn't default)
+ List<RegionName> prodRegionsWith16DistributionBits =
+ Stream.of("us-west-1", "us-central-1", "eu-west-1", "ap-northeast-1", "ap-northeast-2", "us-east-3")
+ .map(RegionName::from).collect(Collectors.toList());
+ if (zone.environment().equals(Environment.prod) && prodRegionsWith16DistributionBits.contains(zone.region()))
+ return 16;
+ else
return DistributionBitCalculator.getDistributionBits(getNodeCountPerGroup(), getDistributionMode());
}
