This is an automated email from the ASF dual-hosted git repository. mck pushed a commit to branch cassandra-3.0 in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cassandra-3.0 by this push: new 2374a74 Fix NPE when using allocate_tokens_for_keyspace on new DC/rack 2374a74 is described below commit 2374a74eba6a4df84f9bda3fd311916c820e9cd6 Author: Mick Semb Wever <m...@apache.org> AuthorDate: Sun Aug 4 20:31:05 2019 +0200 Fix NPE when using allocate_tokens_for_keyspace on new DC/rack patch by Jaydeepkumar Chovatia; reviewed by Mick Semb Wever for CASSANDRA-14592 --- CHANGES.txt | 1 + .../org/apache/cassandra/dht/tokenallocator/TokenAllocation.java | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index c07457b..e4f4d22 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.0.19 + * Fix NPE when using allocate_tokens_for_keyspace on new DC/rack (CASSANDRA-14592) * Filter sstables earlier when running cleanup (CASSANDRA-15100) * Use mean row count instead of mean column count for index selectivity calculation (CASSANDRA-15259) * Avoid updating unchanged gossip states (CASSANDRA-15097) diff --git a/src/java/org/apache/cassandra/dht/tokenallocator/TokenAllocation.java b/src/java/org/apache/cassandra/dht/tokenallocator/TokenAllocation.java index 971a120..5501378 100644 --- a/src/java/org/apache/cassandra/dht/tokenallocator/TokenAllocation.java +++ b/src/java/org/apache/cassandra/dht/tokenallocator/TokenAllocation.java @@ -199,7 +199,11 @@ public class TokenAllocation final int replicas = rs.getReplicationFactor(dc); Topology topology = tokenMetadata.getTopology(); - int racks = topology.getDatacenterRacks().get(dc).asMap().size(); + + // if topology hasn't been setup yet for this endpoint+rack then treat it as a separate unit + int racks = topology.getDatacenterRacks().get(dc) != null && topology.getDatacenterRacks().get(dc).containsKey(snitch.getRack(endpoint)) + ? topology.getDatacenterRacks().get(dc).asMap().size() + : 1; if (racks >= replicas) { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org