diff options
9 files changed, 15 insertions, 200 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java index 2fa3217ef4a..6c0c2c1260f 100644 --- a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java +++ b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java @@ -87,7 +87,10 @@ public interface ModelContext { return 0.9999; } - String docprocLoadBalancerType(); + // TODO Remove when 7.238 is last + default String docprocLoadBalancerType() { + return "adaptive"; + } /// Default setting for the gc-options attribute if not specified explicit by application String jvmGCOptions(); diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java index af3a8335475..2232e57a06f 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java @@ -42,7 +42,6 @@ public class TestProperties implements ModelContext.Properties { private double defaultTermwiseLimit = 1.0; private double threadPoolSizeFactor = 0.0; private double queueSizeFactor = 0.0; - private String docprocLoadBalancerType = null; private String jvmGCOptions = null; private Optional<EndpointCertificateSecrets> endpointCertificateSecrets = Optional.empty(); private AthenzDomain athenzDomain; @@ -64,7 +63,6 @@ public class TestProperties implements ModelContext.Properties { @Override public boolean useDedicatedNodeForLogserver() { return useDedicatedNodeForLogserver; } @Override public Optional<EndpointCertificateSecrets> endpointCertificateSecrets() { return endpointCertificateSecrets; } @Override public double defaultTermwiseLimit() { return defaultTermwiseLimit; } - @Override public String docprocLoadBalancerType() { return docprocLoadBalancerType; } @Override public double threadPoolSizeFactor() { return threadPoolSizeFactor; } @@ -76,10 +74,6 @@ public class TestProperties implements ModelContext.Properties { @Override public Optional<AthenzDomain> athenzDomain() { return Optional.ofNullable(athenzDomain); } @Override public Optional<ApplicationRoles> applicationRoles() { return Optional.ofNullable(applicationRoles); } - public TestProperties setDocprocLoadBalancerType(String type) { - docprocLoadBalancerType = type; - return this; - } public TestProperties setJvmGCOptions(String gcOptions) { jvmGCOptions = gcOptions; return this; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java index 82fbfe87de3..5127616ad5e 100755 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java @@ -18,7 +18,6 @@ import com.yahoo.container.QrSearchersConfig; import com.yahoo.container.bundle.BundleInstantiationSpecification; import com.yahoo.container.core.ApplicationMetadataConfig; import com.yahoo.container.core.document.ContainerDocumentConfig; -import com.yahoo.container.handler.ThreadPoolProvider; import com.yahoo.container.handler.ThreadpoolConfig; import com.yahoo.container.jdisc.JdiscBindingsConfig; import com.yahoo.container.jdisc.config.HealthMonitorConfig; @@ -162,7 +161,6 @@ public abstract class ContainerCluster<CONTAINER extends Container> private final double threadPoolSizeFactor; private final double queueSizeFactor; - private final String docprocLoadbalancerType; public ContainerCluster(AbstractConfigProducer<?> parent, String subId, String name, DeployState deployState) { @@ -172,7 +170,6 @@ public abstract class ContainerCluster<CONTAINER extends Container> this.zone = (deployState != null) ? deployState.zone() : Zone.defaultZone(); this.threadPoolSizeFactor = deployState.getProperties().threadPoolSizeFactor(); this.queueSizeFactor = deployState.getProperties().queueSizeFactor(); - this.docprocLoadbalancerType = deployState.getProperties().docprocLoadBalancerType(); componentGroup = new ComponentGroup<>(this, "component"); @@ -202,10 +199,6 @@ public abstract class ContainerCluster<CONTAINER extends Container> return queueSizeFactor; } - public String getDocprocLoadbalancerType() { - return docprocLoadbalancerType; - } - public void setZone(Zone zone) { this.zone = zone; } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/routing/DocumentProtocol.java b/config-model/src/main/java/com/yahoo/vespa/model/routing/DocumentProtocol.java index 3b9b8778e31..c2a85790f89 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/routing/DocumentProtocol.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/routing/DocumentProtocol.java @@ -150,23 +150,20 @@ public final class DocumentProtocol implements Protocol, Documentrouteselectorpo String policy = policy(docproc); for (DocprocChain chain : docproc.getChains().allChains().allComponents()) { - addChainHop(table, cluster.getConfigId(), policy, chain, cluster.getDocprocLoadbalancerType()); + addChainHop(table, cluster.getConfigId(), policy, chain); } } } } - private static void addChainHop(RoutingTableSpec table, String configId, String policy, DocprocChain chain, String docprocLoadBalancerType) { + private static void addChainHop(RoutingTableSpec table, String configId, String policy, DocprocChain chain) { final StringBuilder selector = new StringBuilder(); if (policy != null) { selector.append(configId).append("/").append(policy).append("/").append(chain.getSessionName()); } else { selector.append("[LoadBalancer:cluster=").append(configId) - .append(";session=").append(chain.getSessionName()); - if ((docprocLoadBalancerType != null) && ! docprocLoadBalancerType.isEmpty()) { - selector.append(";type=").append(docprocLoadBalancerType); - } - selector.append("]"); + .append(";session=").append(chain.getSessionName()) + .append("]"); } table.addHop(new HopSpec(chain.getServiceName(), selector.toString())); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java index 3a2bc9f1a81..74a9e72e255 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java @@ -153,7 +153,6 @@ public class ModelContextImpl implements ModelContext { private final double defaultTermwiseLimit; private final double threadPoolSizeFactor; private final double queueSizefactor; - private final String docprocLoadBalancerType; private final String jvmGCOPtions; private final Optional<AthenzDomain> athenzDomain; private final Optional<ApplicationRoles> applicationRoles; @@ -196,8 +195,6 @@ public class ModelContextImpl implements ModelContext { .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); queueSizefactor = Flags.DEFAULT_QUEUE_SIZE_FACTOR.bindTo(flagSource) .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); - docprocLoadBalancerType = Flags.DOCPROC_LOADBALANCER_TYPE.bindTo(flagSource) - .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); jvmGCOPtions = Flags.JVM_GC_OPTIONS.bindTo(flagSource) .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); this.athenzDomain = athenzDomain; @@ -260,11 +257,6 @@ public class ModelContextImpl implements ModelContext { } @Override - public String docprocLoadBalancerType() { - return docprocLoadBalancerType; - } - - @Override public boolean useDistributorBtreeDb() { return useDistributorBtreeDb; } diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/LegacyLoadBalancer.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/LegacyLoadBalancer.java deleted file mode 100644 index c1e580794b4..00000000000 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/LegacyLoadBalancer.java +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.documentapi.messagebus.protocol; - -import com.yahoo.jrt.slobrok.api.Mirror; - -import java.util.List; - -/** - * Load balances over a set of nodes based on statistics gathered from those nodes. - * - * @author thomasg - */ -class LegacyLoadBalancer extends LoadBalancer { - - static class LegacyNodeMetrics extends NodeMetrics { - double weight = 1.0; - } - - private double position = 0.0; - - public LegacyLoadBalancer(String cluster) { - super(cluster); - } - - /** - * The load balancing operation: Returns a node choice from the given choices, - * based on previously gathered statistics on the nodes, and a running "position" - * which is increased by 1 on each call to this. - * - * @param choices the node choices, represented as Slobrok entries - * @return the chosen node, or null only if the given choices were zero - */ - @Override - Node getRecipient(List<Mirror.Entry> choices) { - if (choices.isEmpty()) return null; - - double weightSum = 0.0; - Node selectedNode = null; - synchronized (this) { - for (Mirror.Entry entry : choices) { - LegacyNodeMetrics nodeMetrics = (LegacyNodeMetrics)getNodeMetrics(entry); - - weightSum += nodeMetrics.weight; - - if (weightSum > position) { - selectedNode = new Node(entry, nodeMetrics); - break; - } - } - if (selectedNode == null) { // Position>sum of all weights: Wrap around (but keep the remainder for some reason) - position -= weightSum; - selectedNode = new Node(choices.get(0), getNodeMetrics(choices.get(0))); - } - position += 1.0; - selectedNode.metrics.incSend(); - } - return selectedNode; - } - - @Override - protected NodeMetrics createNodeMetrics() { - return new LegacyNodeMetrics(); - } - - /** Scale weights such that ratios are preserved */ - private void increaseWeights() { - for (NodeMetrics nodeMetrics : getNodeWeights()) { - LegacyNodeMetrics n = (LegacyNodeMetrics) nodeMetrics; - if (n == null) continue; - double want = n.weight * 1.01010101010101010101; - n.weight = Math.max(1.0, want); - } - } - - @Override - void received(Node node, boolean busy) { - if (busy) { - synchronized (this) { - LegacyNodeMetrics n = (LegacyNodeMetrics) node.metrics; - double wantWeight = n.weight - 0.01; - if (wantWeight < 1.0) { - increaseWeights(); - n.weight = 1.0; - } else { - n.weight = wantWeight; - } - node.metrics.incBusy(); - } - } - } - -} diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/LoadBalancerPolicy.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/LoadBalancerPolicy.java index 4f955f3649e..3c670299f3e 100644 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/LoadBalancerPolicy.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/LoadBalancerPolicy.java @@ -26,7 +26,6 @@ import java.util.Map; public class LoadBalancerPolicy extends SlobrokPolicy { private final String session; private final String pattern; - private final LoadBalancer loadBalancer; LoadBalancerPolicy(String param) { @@ -48,19 +47,12 @@ public class LoadBalancerPolicy extends SlobrokPolicy { } pattern = cluster + "/*/" + session; - String type = params.get("type"); - if ("adaptive".equals(type)) { - loadBalancer = new AdaptiveLoadBalancer(cluster); - } else if ("legacy".equals(type)) { - loadBalancer = new LegacyLoadBalancer(cluster); - } else { - loadBalancer = new LegacyLoadBalancer(cluster); - } + loadBalancer = new AdaptiveLoadBalancer(cluster); } @Override public void select(RoutingContext context) { - LegacyLoadBalancer.Node node = getRecipient(context); + LoadBalancer.Node node = getRecipient(context); if (node != null) { context.setContext(node); @@ -77,7 +69,7 @@ public class LoadBalancerPolicy extends SlobrokPolicy { @return Returns a hop representing the TCP address of the target, or null if none could be found. */ - private LegacyLoadBalancer.Node getRecipient(RoutingContext context) { + private LoadBalancer.Node getRecipient(RoutingContext context) { List<Mirror.Entry> lastLookup = lookup(context, pattern); return loadBalancer.getRecipient(lastLookup); } @@ -85,7 +77,7 @@ public class LoadBalancerPolicy extends SlobrokPolicy { public void merge(RoutingContext context) { RoutingNodeIterator it = context.getChildIterator(); Reply reply = it.removeReply(); - LegacyLoadBalancer.Node target = (LegacyLoadBalancer.Node)context.getContext(); + LoadBalancer.Node target = (LoadBalancer.Node)context.getContext(); boolean busy = false; for (int i = 0; i < reply.getNumErrors(); i++) { diff --git a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/LoadBalancerTestCase.java b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/LoadBalancerTestCase.java index 088259b74ac..582bd53d8e7 100644 --- a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/LoadBalancerTestCase.java +++ b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/LoadBalancerTestCase.java @@ -33,7 +33,7 @@ public class LoadBalancerTestCase { } private static void assertIllegalArgument(String clusterName, String recipient, String expectedMessage) { - LegacyLoadBalancer policy = new LegacyLoadBalancer(clusterName); + LoadBalancer policy = new AdaptiveLoadBalancer(clusterName); try { fail("Expected exception, got index " + policy.getIndex(recipient) + "."); } catch (IllegalArgumentException e) { @@ -44,9 +44,9 @@ public class LoadBalancerTestCase { @Test public void testLoadBalancerCreation() { LoadBalancerPolicy lbp = new LoadBalancerPolicy("cluster=docproc/cluster.mobile.indexing;session=chain.mobile.indexing"); - assertTrue(lbp.getLoadBalancer() instanceof LegacyLoadBalancer); + assertTrue(lbp.getLoadBalancer() instanceof AdaptiveLoadBalancer); lbp = new LoadBalancerPolicy("cluster=docproc/cluster.mobile.indexing;session=chain.mobile.indexing;type=legacy"); - assertTrue(lbp.getLoadBalancer() instanceof LegacyLoadBalancer); + assertTrue(lbp.getLoadBalancer() instanceof AdaptiveLoadBalancer); lbp = new LoadBalancerPolicy("cluster=docproc/cluster.mobile.indexing;session=chain.mobile.indexing;type=adaptive"); assertTrue(lbp.getLoadBalancer() instanceof AdaptiveLoadBalancer); } @@ -110,64 +110,6 @@ public class LoadBalancerTestCase { assertEquals(1019, weights.get(2).pending()); } - @Test - public void testLegacyLoadBalancer() { - LoadBalancer lb = new LegacyLoadBalancer("foo"); - - List<Mirror.Entry> entries = Arrays.asList(new Mirror.Entry("foo/0/default", "tcp/bar:1"), - new Mirror.Entry("foo/1/default", "tcp/bar:2"), - new Mirror.Entry("foo/2/default", "tcp/bar:3")); - List<LoadBalancer.NodeMetrics> weights = lb.getNodeWeights(); - - { - for (int i = 0; i < 99; i++) { - LoadBalancer.Node node = lb.getRecipient(entries); - assertEquals("foo/" + (i % 3) + "/default" , node.entry.getName()); - } - - assertEquals(33, weights.get(0).sent()); - assertEquals(33, weights.get(1).sent()); - assertEquals(33, weights.get(2).sent()); - - weights.get(0).reset(); - weights.get(1).reset(); - weights.get(2).reset(); - } - - { - // Simulate that one node is overloaded. It returns busy twice as often as the others. - for (int i = 0; i < 100; i++) { - lb.received(new LoadBalancer.Node(new Mirror.Entry("foo/0/default", "tcp/bar:1"), weights.get(0)), true); - lb.received(new LoadBalancer.Node(new Mirror.Entry("foo/0/default", "tcp/bar:1"), weights.get(0)), false); - lb.received(new LoadBalancer.Node(new Mirror.Entry("foo/0/default", "tcp/bar:1"), weights.get(0)), false); - - lb.received(new LoadBalancer.Node(new Mirror.Entry("foo/2/default", "tcp/bar:3"), weights.get(2)), true); - lb.received(new LoadBalancer.Node(new Mirror.Entry("foo/2/default", "tcp/bar:3"), weights.get(2)), false); - lb.received(new LoadBalancer.Node(new Mirror.Entry("foo/2/default", "tcp/bar:3"), weights.get(2)), false); - - lb.received(new LoadBalancer.Node(new Mirror.Entry("foo/1/default", "tcp/bar:2"), weights.get(1)), true); - lb.received(new LoadBalancer.Node(new Mirror.Entry("foo/1/default", "tcp/bar:2"), weights.get(1)), true); - lb.received(new LoadBalancer.Node(new Mirror.Entry("foo/1/default", "tcp/bar:2"), weights.get(1)), false); - } - - assertEquals(421, (int)(100 * ((LegacyLoadBalancer.LegacyNodeMetrics)weights.get(0)).weight / ((LegacyLoadBalancer.LegacyNodeMetrics)weights.get(1)).weight)); - assertEquals(100, (int)(100 * ((LegacyLoadBalancer.LegacyNodeMetrics)weights.get(1)).weight)); - assertEquals(421, (int)(100 * ((LegacyLoadBalancer.LegacyNodeMetrics)weights.get(2)).weight / ((LegacyLoadBalancer.LegacyNodeMetrics)weights.get(1)).weight)); - } - - - assertEquals("foo/0/default" , lb.getRecipient(entries).entry.getName()); - assertEquals("foo/0/default" , lb.getRecipient(entries).entry.getName()); - assertEquals("foo/1/default" , lb.getRecipient(entries).entry.getName()); - assertEquals("foo/2/default" , lb.getRecipient(entries).entry.getName()); - assertEquals("foo/2/default" , lb.getRecipient(entries).entry.getName()); - assertEquals("foo/2/default" , lb.getRecipient(entries).entry.getName()); - assertEquals("foo/2/default" , lb.getRecipient(entries).entry.getName()); - assertEquals("foo/0/default" , lb.getRecipient(entries).entry.getName()); - assertEquals("foo/0/default" , lb.getRecipient(entries).entry.getName()); - assertEquals("foo/0/default" , lb.getRecipient(entries).entry.getName()); - } - private void verifyLoadBalancerOneItemOnly(LoadBalancer lb) { List<Mirror.Entry> entries = Arrays.asList(new Mirror.Entry("foo/0/default", "tcp/bar:1") ); @@ -181,7 +123,6 @@ public class LoadBalancerTestCase { } @Test public void testLoadBalancerOneItemOnly() { - verifyLoadBalancerOneItemOnly(new LegacyLoadBalancer("foo")); verifyLoadBalancerOneItemOnly(new AdaptiveLoadBalancer("foo")); } } diff --git a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java index 74522f4c517..a50cd723111 100644 --- a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java +++ b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java @@ -147,11 +147,6 @@ public class Flags { "Takes effect at redeployment", ZONE_ID, APPLICATION_ID); - public static final UnboundStringFlag DOCPROC_LOADBALANCER_TYPE = defineStringFlag( - "docproc-loadbalancer-type", "", - "Selects what kind of load balancer to use for document processing {'adaptive', 'legacy' ''}", - "Takes effect at redeployment", - ZONE_ID, APPLICATION_ID); public static final UnboundStringFlag JVM_GC_OPTIONS = defineStringFlag( "jvm-gc-options", "", "Sets deafult jvm gc options", |