Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Deduplicate Cassandra service nodes (#6207)
Browse files Browse the repository at this point in the history
Deduplicate Cassandra service nodes
  • Loading branch information
schlosna authored Aug 31, 2022
1 parent 997830e commit 28e882b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -132,8 +134,9 @@ public static CassandraService createInitialized(
public void close() {}

public ImmutableSet<CassandraServer> refreshTokenRangesAndGetServers() {
ImmutableSet.Builder<CassandraServer> servers = ImmutableSet.builder();
ImmutableMap.Builder<CassandraServer, String> hostToDatacentersThisRefresh = ImmutableMap.builder();
// explicitly not using immutable builders to deduplicate nodes
Set<CassandraServer> servers = new HashSet<>();
Map<CassandraServer, String> hostToDatacentersThisRefresh = new HashMap<>();

try {
ImmutableRangeMap.Builder<LightweightOppToken, ImmutableSet<CassandraServer>> newTokenRing =
Expand Down Expand Up @@ -179,9 +182,9 @@ public ImmutableSet<CassandraServer> refreshTokenRangesAndGetServers() {
}
}
tokenMap = tokensInterner.intern(newTokenRing.build());
hostToDatacenter = hostToDatacentersThisRefresh.build();
hostToDatacenter = ImmutableMap.copyOf(hostToDatacentersThisRefresh);
logHostToDatacenterMapping(hostToDatacenter);
return servers.build();
return ImmutableSet.copyOf(servers);
} catch (Exception e) {
log.info(
"Couldn't grab new token ranges for token aware cassandra mapping. We will retry in {} seconds.",
Expand Down
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-6207.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: fix
fix:
description: Deduplicate Cassandra service nodes
links:
- https://github.com/palantir/atlasdb/pull/6207

0 comments on commit 28e882b

Please sign in to comment.