summaryrefslogtreecommitdiffstats
path: root/container-core
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-11-15 16:17:16 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2018-11-15 16:17:16 +0100
commit787b7a115ad2fea0658601c3ebee6bcdb74f2550 (patch)
tree79ea97d29e6f3aea31fabf7f15c5b2f259e5c9b3 /container-core
parent8ece4a3e82807740081aa64ed620a4fc879696bb (diff)
When pooling ClusterMonitors and SearchClusters you will add a cluster every time there is a reconfig.
As nothing will purge them, you both keep stuff alive forever and end up with more clusters that you have. Hence the magic for not removing vipstatus when there are multiple clusters kick in preventing nodes being taken OOR. Now it is using the ComponentId for identifying a cluster.
Diffstat (limited to 'container-core')
-rw-r--r--container-core/src/main/java/com/yahoo/container/handler/ClustersStatus.java22
-rw-r--r--container-core/src/main/java/com/yahoo/container/handler/VipStatus.java19
-rw-r--r--container-core/src/test/java/com/yahoo/container/handler/VipStatusTestCase.java6
3 files changed, 36 insertions, 11 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/handler/ClustersStatus.java b/container-core/src/main/java/com/yahoo/container/handler/ClustersStatus.java
index a5e23bd45d3..484628397c0 100644
--- a/container-core/src/main/java/com/yahoo/container/handler/ClustersStatus.java
+++ b/container-core/src/main/java/com/yahoo/container/handler/ClustersStatus.java
@@ -32,7 +32,7 @@ public class ClustersStatus extends AbstractComponent {
private final Object mutex = new Object();
/** The status of clusters, when known. Note that clusters may exist for which there is no knowledge yet. */
- private final Map<Object, Boolean> clusterStatus = new HashMap<>();
+ private final Map<String, Boolean> clusterStatus = new HashMap<>();
public void setContainerHasClusters(boolean containerHasClusters) {
synchronized (mutex) {
@@ -48,18 +48,34 @@ public class ClustersStatus extends AbstractComponent {
}
}
- public void setUp(Object clusterIdentifier) {
+ void setUp(String clusterIdentifier) {
synchronized (mutex) {
clusterStatus.put(clusterIdentifier, Boolean.TRUE);
}
}
- public void setDown(Object clusterIdentifier) {
+ void setDown(String clusterIdentifier) {
synchronized (mutex) {
clusterStatus.put(clusterIdentifier, Boolean.FALSE);
}
}
+ /**
+ @deprecated Use setUp(String) instead
+ */
+ @Deprecated
+ public void setUp(Object clusterIdentifier) {
+ setUp((String) clusterIdentifier);
+ }
+
+ /**
+ @deprecated Use setDown(String) instead
+ */
+ @Deprecated
+ public void setDown(Object clusterIdentifier) {
+ setDown((String) clusterIdentifier);
+ }
+
/** Returns whether this container should receive traffic based on the state of this */
public boolean containerShouldReceiveTraffic() {
synchronized (mutex) {
diff --git a/container-core/src/main/java/com/yahoo/container/handler/VipStatus.java b/container-core/src/main/java/com/yahoo/container/handler/VipStatus.java
index be386b1b84e..ebb56af8853 100644
--- a/container-core/src/main/java/com/yahoo/container/handler/VipStatus.java
+++ b/container-core/src/main/java/com/yahoo/container/handler/VipStatus.java
@@ -1,9 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.handler;
-import java.util.IdentityHashMap;
-import java.util.Map;
-
import com.google.inject.Inject;
import com.yahoo.container.QrSearchersConfig;
import com.yahoo.container.core.VipStatusConfig;
@@ -52,15 +49,27 @@ public class VipStatus {
}
/** Note that a cluster (which influences up/down state) is up */
- public void addToRotation(Object clusterIdentifier) {
+ public void addToRotation(String clusterIdentifier) {
clustersStatus.setUp(clusterIdentifier);
}
/** Note that a cluster (which influences up/down state) is down */
- public void removeFromRotation(Object clusterIdentifier) {
+ public void removeFromRotation(String clusterIdentifier) {
clustersStatus.setDown(clusterIdentifier);
}
+ /** @deprecated Use addToRotation(String) instead */
+ @Deprecated
+ public void addToRotation(Object clusterIdentifier) {
+ addToRotation((String) clusterIdentifier);
+ }
+
+ /** @deprecated Use removeFromRotation(String) instead */
+ @Deprecated
+ public void removeFromRotation(Object clusterIdentifier) {
+ removeFromRotation((String) clusterIdentifier);
+ }
+
/** Returns whether this container should receive traffic at this time */
public boolean isInRotation() {
if (inRotationOverride != null) return inRotationOverride;
diff --git a/container-core/src/test/java/com/yahoo/container/handler/VipStatusTestCase.java b/container-core/src/test/java/com/yahoo/container/handler/VipStatusTestCase.java
index e54f968f41d..4c1c1622140 100644
--- a/container-core/src/test/java/com/yahoo/container/handler/VipStatusTestCase.java
+++ b/container-core/src/test/java/com/yahoo/container/handler/VipStatusTestCase.java
@@ -18,9 +18,9 @@ public class VipStatusTestCase {
clustersStatus.setContainerHasClusters(true);
VipStatus v = new VipStatus(clustersStatus);
- Object cluster1 = new Object();
- Object cluster2 = new Object();
- Object cluster3 = new Object();
+ String cluster1 = new String("a");
+ String cluster2 = new String("b");
+ String cluster3 = new String("c");
// initial state
assertFalse(v.isInRotation());