cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [01/16] cassandra git commit: Fix nodetool status logic to detect if their is more than 1 user keyspace
Date Wed, 17 Feb 2016 10:32:28 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 393c6ec4f -> f4b21f5ff
  refs/heads/cassandra-2.2 f3b5ff842 -> f7c75857d
  refs/heads/cassandra-3.0 9cfbc31bc -> 931d2e5f3
  refs/heads/trunk 48815d4a1 -> 09fd433cb


Fix nodetool status logic to detect if their is more than 1 user keyspace

explanation

patch by krummas & slebresne; reviewed by krummas & slebresne for CASSANDRA-10176


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

Branch: refs/heads/cassandra-2.1
Commit: f4b21f5ffa962de19901d1841f89f529ccc335b3
Parents: 393c6ec
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Wed Feb 3 21:04:17 2016 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Wed Feb 17 11:23:54 2016 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../org/apache/cassandra/config/Schema.java     | 22 ++++++++++++++++++--
 .../locator/AbstractReplicationStrategy.java    |  5 +++++
 .../locator/NetworkTopologyStrategy.java        |  6 ++++++
 .../cassandra/service/StorageService.java       | 22 ++++++++++++--------
 5 files changed, 45 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f4b21f5f/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9f51291..9a9c4f7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.14
+ * Fix incorrect warning in 'nodetool status' (CASSANDRA-10176)
  * Properly release sstable ref when doing offline scrub (CASSANDRA-10697)
  * Improve nodetool status performance for large cluster (CASSANDRA-7238)
  * Make it clear what DTCS timestamp_resolution is used for (CASSANDRA-11041)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f4b21f5f/src/java/org/apache/cassandra/config/Schema.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/Schema.java b/src/java/org/apache/cassandra/config/Schema.java
index fada670..739c8ca 100644
--- a/src/java/org/apache/cassandra/config/Schema.java
+++ b/src/java/org/apache/cassandra/config/Schema.java
@@ -28,12 +28,14 @@ import com.google.common.collect.Sets;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.cassandra.auth.Auth;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.Keyspace;
 import org.apache.cassandra.db.index.SecondaryIndex;
 import org.apache.cassandra.db.index.SecondaryIndexManager;
 import org.apache.cassandra.io.sstable.Descriptor;
 import org.apache.cassandra.service.MigrationManager;
+import org.apache.cassandra.tracing.Tracing;
 import org.apache.cassandra.utils.ConcurrentBiMap;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.Pair;
@@ -67,6 +69,7 @@ public class Schema
     // 59adb24e-f3cd-3e02-97f0-5b395827453f
     public static final UUID emptyVersion;
     public static final ImmutableSet<String> systemKeyspaceNames = ImmutableSet.of(Keyspace.SYSTEM_KS);
+    public static final ImmutableSet<String> replicatedSystemKeyspaceNames = ImmutableSet.of(Tracing.TRACE_KS,
Auth.AUTH_KS);
 
     static
     {
@@ -288,12 +291,27 @@ public class Schema
         return keyspaces.get(keyspaceName);
     }
 
+    private Set<String> getNonSystemKeyspacesSet()
+    {
+        return Sets.difference(keyspaces.keySet(), systemKeyspaceNames);
+    }
+
     /**
-     * @return collection of the non-system keyspaces
+     * @return collection of the non-system keyspaces (note that this count as system only
the
+     * non replicated keyspaces, so keyspace like system_traces which are replicated are
actually
+     * returned. See getUserKeyspace() below if you don't want those)
      */
     public List<String> getNonSystemKeyspaces()
     {
-        return ImmutableList.copyOf(Sets.difference(keyspaces.keySet(), systemKeyspaceNames));
+        return ImmutableList.copyOf(getNonSystemKeyspacesSet());
+    }
+
+    /**
+     * @return collection of the user defined keyspaces
+     */
+    public List<String> getUserKeyspaces()
+    {
+        return ImmutableList.copyOf(Sets.difference(getNonSystemKeyspacesSet(), replicatedSystemKeyspaceNames));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f4b21f5f/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java b/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
index b6599f1..2178e17 100644
--- a/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
+++ b/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
@@ -303,6 +303,11 @@ public abstract class AbstractReplicationStrategy
         return strategyClass;
     }
 
+    public boolean hasSameSettings(AbstractReplicationStrategy other)
+    {
+        return getClass().equals(other.getClass()) && getReplicationFactor() == other.getReplicationFactor();
+    }
+
     protected void validateReplicationFactor(String rf) throws ConfigurationException
     {
         try

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f4b21f5f/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java b/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java
index 5e5ecb7..a792aa8 100644
--- a/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java
+++ b/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java
@@ -199,4 +199,10 @@ public class NetworkTopologyStrategy extends AbstractReplicationStrategy
         // We explicitely allow all options
         return null;
     }
+
+    @Override
+    public boolean hasSameSettings(AbstractReplicationStrategy other)
+    {
+        return super.hasSameSettings(other) && ((NetworkTopologyStrategy) other).datacenters.equals(datacenters);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f4b21f5f/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 02f6cf4..98e2251 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -4032,18 +4032,22 @@ public class StorageService extends NotificationBroadcasterSupport
implements IE
         }
         else
         {
-            List<String> nonSystemKeyspaces = Schema.instance.getNonSystemKeyspaces();
+            List<String> userKeyspaces = Schema.instance.getUserKeyspaces();
 
-            //system_traces is a non-system keyspace however it needs to be counted as one
for this process
-            int specialTableCount = 0;
-            if (nonSystemKeyspaces.contains("system_traces"))
+            if (userKeyspaces.size() > 0)
             {
-                specialTableCount += 1;
+                keyspace = userKeyspaces.iterator().next();
+                AbstractReplicationStrategy replicationStrategy = Schema.instance.getKeyspaceInstance(keyspace).getReplicationStrategy();
+                for (String keyspaceName : userKeyspaces)
+                {
+                    if (!Schema.instance.getKeyspaceInstance(keyspaceName).getReplicationStrategy().hasSameSettings(replicationStrategy))
+                        throw new IllegalStateException("Non-system keyspaces don't have
the same replication settings, effective ownership information is meaningless");
+                }
+            }
+            else
+            {
+                keyspace = "system_traces";
             }
-            if (nonSystemKeyspaces.size() > specialTableCount)
-                throw new IllegalStateException("Non-system keyspaces don't have the same
replication settings, effective ownership information is meaningless");
-
-            keyspace = "system_traces";
 
             Keyspace keyspaceInstance = Schema.instance.getKeyspaceInstance(keyspace);
             if (keyspaceInstance == null)


Mime
View raw message