aboutsummaryrefslogtreecommitdiffstats
path: root/container-core
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-11-15 16:45:06 +0100
committerGitHub <noreply@github.com>2018-11-15 16:45:06 +0100
commit7618b690625dba6736ede7065896a7726ad1600d (patch)
tree2b10d2fe4a3223093c2103fe8db08f3173c7157a /container-core
parentf89fcfbc1f9c955d79f5313c1ec0862ecfa7a7a9 (diff)
parent787b7a115ad2fea0658601c3ebee6bcdb74f2550 (diff)
Merge pull request #7674 from vespa-engine/balder/do-not-pool-objects-in-a-never-purged-map
When pooling ClusterMonitors and SearchClusters you will add a cluste…
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());