diff --git a/CHANGES.txt b/CHANGES.txt index 22a83fa860..1ecda8bc9a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,6 +5,7 @@ * Add `allocate_tokens_for_local_replication_factor` option for token allocation (CASSANDRA-15260) * Add Alibaba Cloud Platform snitch (CASSANDRA-15092) Merged from 3.0: + * Gossip tokens on startup if available (CASSANDRA-15335) * Fix resource leak in CompressedSequentialWriter (CASSANDRA-15340) * Fix bad merge that reverted CASSANDRA-14993 (CASSANDRA-15289) diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java index ae83e92291..a7c125c865 100644 --- a/src/java/org/apache/cassandra/service/StorageService.java +++ b/src/java/org/apache/cassandra/service/StorageService.java @@ -794,6 +794,15 @@ public class StorageService extends NotificationBroadcasterSupport implements IE else { checkForEndpointCollision(localHostId, SystemKeyspace.loadHostIds().keySet()); + if (SystemKeyspace.bootstrapComplete()) + { + Preconditions.checkState(!Config.isClientMode()); + // tokens are only ever saved to system.local after bootstrap has completed and we're joining the ring, + // or when token update operations (move, decom) are completed + Collection savedTokens = SystemKeyspace.getSavedTokens(); + if (!savedTokens.isEmpty()) + appStates.put(ApplicationState.TOKENS, valueFactory.tokens(savedTokens)); + } } // have to start the gossip service before we can see any info on other nodes. this is necessary