cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [2/3] cassandra git commit: Follow-up to CASSANDRA-10238
Date Fri, 18 Sep 2015 11:40:35 GMT
Follow-up to CASSANDRA-10238

call invalidateCacheRings when topology is updated

patch by Stefania Alborghetti; reviewed by Branimir Lambov for
CASSANDRA-10238


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

Branch: refs/heads/cassandra-2.1
Commit: c4de752758c3cf7f5de5a92e4ede30e430a36255
Parents: 6f8e07a
Author: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Authored: Fri Sep 18 08:57:53 2015 +0800
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Fri Sep 18 12:33:51 2015 +0100

----------------------------------------------------------------------
 .../apache/cassandra/locator/PropertyFileSnitch.java  | 14 +++++++++-----
 .../org/apache/cassandra/locator/TokenMetadata.java   |  2 ++
 .../locator/YamlFileNetworkTopologySnitch.java        | 10 ++++++----
 .../org/apache/cassandra/service/StorageService.java  |  3 ++-
 4 files changed, 19 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c4de7527/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java b/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java
index 745eeb8..5b89df1 100644
--- a/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java
+++ b/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java
@@ -59,7 +59,7 @@ public class PropertyFileSnitch extends AbstractNetworkTopologySnitch
 
     public PropertyFileSnitch() throws ConfigurationException
     {
-        reloadConfiguration();
+        reloadConfiguration(false);
 
         try
         {
@@ -68,8 +68,7 @@ public class PropertyFileSnitch extends AbstractNetworkTopologySnitch
             {
                 protected void runMayThrow() throws ConfigurationException
                 {
-                    reloadConfiguration();
-                    StorageService.instance.updateTopology();
+                    reloadConfiguration(true);
                 }
             };
             ResourceWatcher.watch(SNITCH_PROPERTIES_FILENAME, runnable, 60 * 1000);
@@ -131,7 +130,7 @@ public class PropertyFileSnitch extends AbstractNetworkTopologySnitch
         return info[1];
     }
 
-    public void reloadConfiguration() throws ConfigurationException
+    public void reloadConfiguration(boolean isUpdate) throws ConfigurationException
     {
         HashMap<InetAddress, String[]> reloadedMap = new HashMap<InetAddress, String[]>();
 
@@ -198,7 +197,12 @@ public class PropertyFileSnitch extends AbstractNetworkTopologySnitch
 
         endpointMap = reloadedMap;
         if (StorageService.instance != null) // null check tolerates circular dependency;
see CASSANDRA-4145
-            StorageService.instance.getTokenMetadata().invalidateCachedRings();
+        {
+            if (isUpdate)
+                StorageService.instance.updateTopology();
+            else
+                StorageService.instance.getTokenMetadata().invalidateCachedRings();
+        }
 
         if (gossipStarted)
             StorageService.instance.gossipSnitchInfo();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c4de7527/src/java/org/apache/cassandra/locator/TokenMetadata.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/TokenMetadata.java b/src/java/org/apache/cassandra/locator/TokenMetadata.java
index b1b25e8..25d60f0 100644
--- a/src/java/org/apache/cassandra/locator/TokenMetadata.java
+++ b/src/java/org/apache/cassandra/locator/TokenMetadata.java
@@ -413,6 +413,7 @@ public class TokenMetadata
         {
             logger.info("Updating topology for {}", endpoint);
             topology.updateEndpoint(endpoint);
+            invalidateCachedRings();
         }
         finally
         {
@@ -431,6 +432,7 @@ public class TokenMetadata
         {
             logger.info("Updating topology for all endpoints that have changed");
             topology.updateEndpoints();
+            invalidateCachedRings();
         }
         finally
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c4de7527/src/java/org/apache/cassandra/locator/YamlFileNetworkTopologySnitch.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/YamlFileNetworkTopologySnitch.java b/src/java/org/apache/cassandra/locator/YamlFileNetworkTopologySnitch.java
index e6691c4..b75fc28 100644
--- a/src/java/org/apache/cassandra/locator/YamlFileNetworkTopologySnitch.java
+++ b/src/java/org/apache/cassandra/locator/YamlFileNetworkTopologySnitch.java
@@ -103,7 +103,7 @@ public class YamlFileNetworkTopologySnitch
             throws ConfigurationException
     {
         this.topologyConfigFilename = topologyConfigFilename;
-        loadTopologyConfiguration();
+        loadTopologyConfiguration(false);
 
         try
         {
@@ -119,8 +119,7 @@ public class YamlFileNetworkTopologySnitch
                  */
                 protected void runMayThrow() throws ConfigurationException
                 {
-                    loadTopologyConfiguration();
-                    StorageService.instance.updateTopology();
+                    loadTopologyConfiguration(true);
                 }
             };
             ResourceWatcher.watch(topologyConfigFilename, runnable,
@@ -202,7 +201,7 @@ public class YamlFileNetworkTopologySnitch
      * @throws ConfigurationException
      *             on failure
      */
-    private synchronized void loadTopologyConfiguration()
+    private synchronized void loadTopologyConfiguration(boolean isUpdate)
             throws ConfigurationException
     {
         logger.debug("Loading topology configuration from {}",
@@ -354,6 +353,9 @@ public class YamlFileNetworkTopologySnitch
         {
             StorageService.instance.gossipSnitchInfo();
         }
+
+        if (isUpdate && StorageService.instance != null)
+            StorageService.instance.updateTopology();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c4de7527/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 c5f159e..9327b67 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -1411,7 +1411,6 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
     public void updateTopology()
     {
         getTokenMetadata().updateTopology();
-
     }
 
     private void updatePeerInfo(InetAddress endpoint)
@@ -3670,6 +3669,8 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
 
         if (oldSnitch instanceof DynamicEndpointSnitch)
             ((DynamicEndpointSnitch)oldSnitch).unregisterMBean();
+
+        updateTopology();
     }
 
     /**


Mime
View raw message