Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 2954b1835 -> 89c558a43


Improve nodetool status performance for large cluster

patch by yukim; reviewed by Paulo Motta for CASSANDRA-7238


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

Branch: refs/heads/cassandra-3.0
Commit: 6c6b7e40c39e0f1d1c37352a19f8bd73c205bc6d
Parents: 725b9b1
Author: Yuki Morishita <[email protected]>
Authored: Tue Jan 26 16:27:37 2016 -0600
Committer: Yuki Morishita <[email protected]>
Committed: Wed Feb 10 17:33:11 2016 -0600

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/service/StorageService.java       | 32 +++++++++++---------
 2 files changed, 19 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c6b7e40/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 72b3d59..3bbef11 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.14
+ * Improve nodetool status performance for large cluster (CASSANDRA-7238)
  * Make it clear what DTCS timestamp_resolution is used for (CASSANDRA-11041)
  * Gossiper#isEnabled is not thread safe (CASSANDRA-11116)
  * Avoid major compaction mixing repaired and unrepaired sstables in DTCS 
(CASSANDRA-11113)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6c6b7e40/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 d8b1869..02f6cf4 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -3599,14 +3599,15 @@ public class StorageService extends 
NotificationBroadcasterSupport implements IE
 
             for (String keyspace : keyspaceNames)
             {
+                // replication strategy of the current keyspace
+                AbstractReplicationStrategy strategy = 
Keyspace.open(keyspace).getReplicationStrategy();
+                Multimap<InetAddress, Range<Token>> endpointToRanges = 
strategy.getAddressRanges();
+
                 logger.debug("Calculating ranges to stream and request for 
keyspace {}", keyspace);
                 for (Token newToken : newTokens)
                 {
-                    // replication strategy of the current keyspace (aka table)
-                    AbstractReplicationStrategy strategy = 
Keyspace.open(keyspace).getReplicationStrategy();
-
                     // getting collection of the currently used ranges by this 
keyspace
-                    Collection<Range<Token>> currentRanges = 
getRangesForEndpoint(keyspace, localAddress);
+                    Collection<Range<Token>> currentRanges = 
endpointToRanges.get(localAddress);
                     // collection of ranges which this node will serve after 
move to the new token
                     Collection<Range<Token>> updatedRanges = 
strategy.getPendingAddressRanges(tokenMetaClone, newToken, localAddress);
 
@@ -4018,18 +4019,19 @@ public class StorageService extends 
NotificationBroadcasterSupport implements IE
      */
     public LinkedHashMap<InetAddress, Float> effectiveOwnership(String 
keyspace) throws IllegalStateException
     {
-
-       if (keyspace != null)
-       {
+        AbstractReplicationStrategy strategy;
+        if (keyspace != null)
+        {
             Keyspace keyspaceInstance = 
Schema.instance.getKeyspaceInstance(keyspace);
-            if(keyspaceInstance == null)
+            if (keyspaceInstance == null)
                 throw new IllegalArgumentException("The keyspace " + keyspace 
+ ", does not exist");
 
-            if(keyspaceInstance.getReplicationStrategy() instanceof 
LocalStrategy)
+            if (keyspaceInstance.getReplicationStrategy() instanceof 
LocalStrategy)
                 throw new IllegalStateException("Ownership values for 
keyspaces with LocalStrategy are meaningless");
-       }
-       else
-       {
+            strategy = keyspaceInstance.getReplicationStrategy();
+        }
+        else
+        {
             List<String> nonSystemKeyspaces = 
Schema.instance.getNonSystemKeyspaces();
 
             //system_traces is a non-system keyspace however it needs to be 
counted as one for this process
@@ -4044,8 +4046,9 @@ public class StorageService extends 
NotificationBroadcasterSupport implements IE
             keyspace = "system_traces";
 
             Keyspace keyspaceInstance = 
Schema.instance.getKeyspaceInstance(keyspace);
-            if(keyspaceInstance == null)
+            if (keyspaceInstance == null)
                 throw new IllegalArgumentException("The node does not have " + 
keyspace + " yet, probably still bootstrapping");
+            strategy = keyspaceInstance.getReplicationStrategy();
         }
 
         TokenMetadata metadata = tokenMetadata.cloneOnlyTokenMap();
@@ -4060,6 +4063,7 @@ public class StorageService extends 
NotificationBroadcasterSupport implements IE
         Map<Token, Float> tokenOwnership = 
getPartitioner().describeOwnership(tokenMetadata.sortedTokens());
         LinkedHashMap<InetAddress, Float> finalOwnership = 
Maps.newLinkedHashMap();
 
+        Multimap<InetAddress, Range<Token>> endpointToRanges = 
strategy.getAddressRanges();
         // calculate ownership per dc
         for (Collection<InetAddress> endpoints : endpointsGroupedByDc)
         {
@@ -4067,7 +4071,7 @@ public class StorageService extends 
NotificationBroadcasterSupport implements IE
             for (InetAddress endpoint : endpoints)
             {
                 float ownership = 0.0f;
-                for (Range<Token> range : getRangesForEndpoint(keyspace, 
endpoint))
+                for (Range<Token> range : endpointToRanges.get(endpoint))
                 {
                     if (tokenOwnership.containsKey(range.right))
                         ownership += tokenOwnership.get(range.right);

Reply via email to