|
46 | 46 | import java.util.Set;
|
47 | 47 | import java.util.concurrent.ConcurrentHashMap;
|
48 | 48 | import java.util.concurrent.atomic.AtomicInteger;
|
49 |
| -import java.util.concurrent.atomic.AtomicLong; |
50 | 49 | import java.util.stream.Collectors;
|
51 | 50 |
|
52 | 51 | import static com.couchbase.client.core.config.ConfigurationProvider.TRIGGERED_BY_CONFIG_CHANGE_NOTIFICATION;
|
@@ -97,12 +96,6 @@ public class KeyValueBucketRefresher implements BucketRefresher {
|
97 | 96 | */
|
98 | 97 | private final ConfigurationProvider provider;
|
99 | 98 |
|
100 |
| - /** |
101 |
| - * The global offset is used to make sure each KV node eventually gets used |
102 |
| - * by shifting on each invocation. |
103 |
| - */ |
104 |
| - private final AtomicLong nodeOffset = new AtomicLong(0); |
105 |
| - |
106 | 99 | /**
|
107 | 100 | * Holds all current registrations and their last timestamp when the bucket has been
|
108 | 101 | * updated.
|
@@ -242,7 +235,7 @@ private List<NodeInfo> filterEligibleNodes(final String name) {
|
242 | 235 | }
|
243 | 236 |
|
244 | 237 | List<NodeInfo> nodes = new ArrayList<>(config.nodes());
|
245 |
| - shiftNodeList(nodes); |
| 238 | + Collections.shuffle(nodes); |
246 | 239 |
|
247 | 240 | return nodes
|
248 | 241 | .stream()
|
@@ -313,16 +306,6 @@ private ConfigVersion currentVersion(String bucketName) {
|
313 | 306 | return config == null ? ConfigVersion.ZERO : config.version();
|
314 | 307 | }
|
315 | 308 |
|
316 |
| - /** |
317 |
| - * Helper method to transparently rearrange the node list based on the current global offset. |
318 |
| - * |
319 |
| - * @param nodeList the list to shift. |
320 |
| - */ |
321 |
| - private <T> void shiftNodeList(final List<T> nodeList) { |
322 |
| - int shiftBy = (int) (nodeOffset.getAndIncrement() % nodeList.size()); |
323 |
| - Collections.rotate(nodeList, -shiftBy); |
324 |
| - } |
325 |
| - |
326 | 309 | @Override
|
327 | 310 | public Mono<Void> register(final String name) {
|
328 | 311 | return Mono.defer(() -> {
|
|
0 commit comments