From 39a431d9d821cf6bcb54da7198b6a64e09b0f120 Mon Sep 17 00:00:00 2001 From: Blake Eggleston Date: Tue, 24 Sep 2019 14:27:18 -0700 Subject: [PATCH] Gossip tokens on startup if available Patch by Blake Eggleston; Reviewed by Marcus Eriksson and Sam Tunnicliffe for CASSANDRA-15335 --- CHANGES.txt | 1 + .../org/apache/cassandra/service/StorageService.java | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 6bf3ee1455..ca6ea2e6ff 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.0.19 + * Gossip tokens on startup if available (CASSANDRA-15335) * Fix resource leak in CompressedSequentialWriter (CASSANDRA-15340) * Fix merge which reverted CASSANDRA-14993 (CASSANDRA-15289) * Fix LegacyLayout RangeTombstoneList IndexOutOfBoundsException when upgrading and RangeTombstone bounds are asymmetric (CASSANDRA-15172) diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java index d349b4b7c0..2af7fb764c 100644 --- a/src/java/org/apache/cassandra/service/StorageService.java +++ b/src/java/org/apache/cassandra/service/StorageService.java @@ -34,6 +34,7 @@ import javax.management.openmbean.TabularData; import javax.management.openmbean.TabularDataSupport; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.collect.*; import com.google.common.util.concurrent.*; @@ -56,6 +57,7 @@ import org.apache.cassandra.concurrent.ScheduledExecutors; import org.apache.cassandra.concurrent.Stage; import org.apache.cassandra.concurrent.StageManager; import org.apache.cassandra.config.CFMetaData; +import org.apache.cassandra.config.Config; import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.config.Schema; import org.apache.cassandra.config.ViewDefinition; @@ -767,6 +769,15 @@ public class StorageService extends NotificationBroadcasterSupport implements IE { checkForEndpointCollision(); } + else 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 // for bootstrap to get the load info it needs.