summaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorOlli Virtanen <olli.virtanen@oath.com>2018-10-12 15:56:04 +0200
committerOlli Virtanen <olli.virtanen@oath.com>2018-10-12 15:56:04 +0200
commit18bb6854530466f66c574349861748b3bba13d33 (patch)
tree76bad6f306c35717f15091612007c72ea6db57dd /container-search
parentee6f2a8fb5756d9b13ce89789a0dc6f9b28a1c33 (diff)
Remove group affinity - conflicts with profiles
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/LoadBalancer.java32
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java21
2 files changed, 4 insertions, 49 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/LoadBalancer.java b/container-search/src/main/java/com/yahoo/search/dispatch/LoadBalancer.java
index 455696c16b1..9eac9b9b63d 100644
--- a/container-search/src/main/java/com/yahoo/search/dispatch/LoadBalancer.java
+++ b/container-search/src/main/java/com/yahoo/search/dispatch/LoadBalancer.java
@@ -1,7 +1,6 @@
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.dispatch;
-import com.yahoo.processing.request.CompoundName;
import com.yahoo.search.Query;
import com.yahoo.search.dispatch.SearchCluster.Group;
@@ -24,8 +23,6 @@ public class LoadBalancer {
private static final Logger log = Logger.getLogger(LoadBalancer.class.getName());
- private static final CompoundName QUERY_NODE_GROUP_AFFINITY = new CompoundName("dispatch.group.affinity");
-
private final List<GroupSchedule> scoreboard;
private int needle = 0;
@@ -54,16 +51,7 @@ public class LoadBalancer {
return Optional.empty();
}
- Integer groupAffinity = query.properties().getInteger(QUERY_NODE_GROUP_AFFINITY);
- if (groupAffinity != null) {
- Optional<Group> previouslyChosen = allocateFromGroup(groupAffinity);
- if (previouslyChosen.isPresent()) {
- return previouslyChosen;
- }
- }
- Optional<Group> allocatedGroup = allocateNextGroup();
- allocatedGroup.ifPresent(group -> query.properties().set(QUERY_NODE_GROUP_AFFINITY, group.id()));
- return allocatedGroup;
+ return allocateNextGroup();
}
/**
@@ -83,18 +71,6 @@ public class LoadBalancer {
}
}
- private Optional<Group> allocateFromGroup(int groupId) {
- synchronized (this) {
- for (GroupSchedule schedule : scoreboard) {
- if (schedule.group.id() == groupId) {
- schedule.adjustScore(1);
- return Optional.of(schedule.group);
- }
- }
- }
- return Optional.empty();
- }
-
private Optional<Group> allocateNextGroup() {
synchronized (this) {
GroupSchedule bestSchedule = null;
@@ -139,12 +115,12 @@ public class LoadBalancer {
}
public boolean isPreferredOver(GroupSchedule other) {
- if (! group.hasSufficientCoverage()) {
- return false;
- }
if (other == null) {
return true;
}
+ if (! group.hasSufficientCoverage()) {
+ return false;
+ }
return this.score < other.score;
}
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java
index 5fa9dee8370..b08a3a73a01 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java
@@ -80,27 +80,6 @@ public class LoadBalancerTest {
}
@Test
- public void requreThatLoadBalancerReturnsSameGroupForSameQuery() {
- Node n1 = new SearchCluster.Node(0, "test-node1", 0, 0);
- Node n2 = new SearchCluster.Node(1, "test-node2", 1, 1);
- SearchCluster cluster = new SearchCluster(88.0, Arrays.asList(n1, n2), null, 1, null);
- LoadBalancer lb = new LoadBalancer(cluster);
-
- Query q = new Query();
- // get first group
- Optional<Group> grp = lb.takeGroupForQuery(q);
- Group group = grp.get();
- int id1 = group.id();
- // release allocation
- lb.releaseGroup(group);
-
- // continue with same query
- grp = lb.takeGroupForQuery(q);
- group = grp.get();
- assertThat(group.id(), equalTo(id1));
- }
-
- @Test
public void requreThatLoadBalancerReturnsGroupWithShortestQueue() {
Node n1 = new SearchCluster.Node(0, "test-node1", 0, 0);
Node n2 = new SearchCluster.Node(1, "test-node2", 1, 1);