summaryrefslogtreecommitdiffstats
path: root/documentapi
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-04-26 09:48:25 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2019-04-26 09:48:25 +0200
commit953119d5105331fa04b1c58d15ff957eeb81b7b8 (patch)
tree668bfd4d8ea544632ac8f42899c345a4f1a95c9c /documentapi
parent5c2cd3bd5a770a14e995a3ae36959a76053e2968 (diff)
Also protect oldClusterVersionGottenCount
Diffstat (limited to 'documentapi')
-rw-r--r--documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/StoragePolicy.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/StoragePolicy.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/StoragePolicy.java
index 75de698cc5e..2d6d47cf8ab 100644
--- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/StoragePolicy.java
+++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/StoragePolicy.java
@@ -30,6 +30,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.Random;
import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;
@@ -317,7 +318,7 @@ public class StoragePolicy extends ExternalSlobrokPolicy {
private final Distribution distribution;
private final InstabilityChecker persistentFailureChecker;
private AtomicReference<ClusterState> safeCachedClusterState = new AtomicReference<>(null);
- private int oldClusterVersionGottenCount = 0;
+ private final AtomicInteger oldClusterVersionGottenCount = new AtomicInteger(0);
private final int maxOldClusterVersionBeforeSendingRandom; // Reset cluster version protection
DistributorSelectionLogic(Parameters params, ExternalSlobrokPolicy policy) {
@@ -456,8 +457,8 @@ public class StoragePolicy extends ExternalSlobrokPolicy {
private void resetCachedStateIfClusterStateVersionLikelyRolledBack(ClusterState newState) {
ClusterState cachedClusterState = safeCachedClusterState.get();
if (cachedClusterState != null && cachedClusterState.getVersion() > newState.getVersion()) {
- if (++oldClusterVersionGottenCount >= maxOldClusterVersionBeforeSendingRandom) {
- oldClusterVersionGottenCount = 0;
+ if (oldClusterVersionGottenCount.incrementAndGet() >= maxOldClusterVersionBeforeSendingRandom) {
+ oldClusterVersionGottenCount.set(0);
safeCachedClusterState.set(null);
}
}