cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject cassandra git commit: Populate TokenMetadata early during startup.
Date Fri, 15 May 2015 09:55:00 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 311cb7783 -> 5012463b6


Populate TokenMetadata early during startup.

Patch by marcuse; reviewed by thobbs for CASSANDRA-9317


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/5012463b
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/5012463b
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/5012463b

Branch: refs/heads/trunk
Commit: 5012463b60e31c78a5a2af5e0ca78b64e4dc38a6
Parents: 311cb77
Author: Marcus Eriksson <marcuse@apache.org>
Authored: Thu May 7 11:09:15 2015 +0200
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Fri May 15 11:53:45 2015 +0200

----------------------------------------------------------------------
 CHANGES.txt                                         |  1 +
 .../apache/cassandra/service/CassandraDaemon.java   |  1 +
 .../apache/cassandra/service/StorageService.java    | 16 +++++++++++++++-
 3 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/5012463b/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 0efba98..bcae76f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.2
+ * Populate TokenMetadata early during startup (CASSANDRA-9317)
  * Make Functions.declared thread-safe
  * Add client warnings to native protocol v4 (CASSANDRA-8930)
  * Allow roles cache to be invalidated (CASSANDRA-8967)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5012463b/src/java/org/apache/cassandra/service/CassandraDaemon.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/CassandraDaemon.java b/src/java/org/apache/cassandra/service/CassandraDaemon.java
index c1b4ad6..914600e 100644
--- a/src/java/org/apache/cassandra/service/CassandraDaemon.java
+++ b/src/java/org/apache/cassandra/service/CassandraDaemon.java
@@ -173,6 +173,7 @@ public class CassandraDaemon
             }
         });
 
+        StorageService.instance.populateTokenMetadata();
         // load schema from disk
         Schema.instance.loadFromDisk();
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5012463b/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index c0ea872..4573449 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -565,6 +565,21 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
             MessagingService.instance().listen(FBUtilities.getLocalAddress());
     }
 
+    public void populateTokenMetadata()
+    {
+        if (Boolean.parseBoolean(System.getProperty("cassandra.load_ring_state", "true")))
+        {
+            logger.info("Populating token metadata from system tables");
+            Multimap<InetAddress, Token> loadedTokens = SystemKeyspace.loadTokens();
+            if (!shouldBootstrap()) // if we have not completed bootstrapping, we should
not add ourselves as a normal token
+                loadedTokens.putAll(FBUtilities.getBroadcastAddress(), SystemKeyspace.getSavedTokens());
+            for (InetAddress ep : loadedTokens.keySet())
+                tokenMetadata.updateNormalTokens(loadedTokens.get(ep), ep);
+
+            logger.info("Token metadata: {}", tokenMetadata);
+        }
+    }
+
     public synchronized void initServer() throws ConfigurationException
     {
         initServer(RING_DELAY);
@@ -605,7 +620,6 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
                 }
                 else
                 {
-                    tokenMetadata.updateNormalTokens(loadedTokens.get(ep), ep);
                     if (loadedHostIds.containsKey(ep))
                         tokenMetadata.updateHostId(loadedHostIds.get(ep), ep);
                     Gossiper.instance.addSavedEndpoint(ep);


Mime
View raw message