cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yu...@apache.org
Subject [1/3] git commit: Allow alter keyspace on system_traces
Date Wed, 02 Oct 2013 15:11:30 GMT
Updated Branches:
  refs/heads/cassandra-2.0 32c3f44a6 -> 88944ffcd
  refs/heads/trunk 7a1436704 -> 040e67efd


Allow alter keyspace on system_traces

patch by yukim; reviewed by jbellis for CASSANDRA-6016


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

Branch: refs/heads/cassandra-2.0
Commit: 88944ffcd85ae59fc92202a5a547b3c65efa03f0
Parents: 32c3f44
Author: Yuki Morishita <yukim@apache.org>
Authored: Wed Oct 2 10:06:53 2013 -0500
Committer: Yuki Morishita <yukim@apache.org>
Committed: Wed Oct 2 10:06:53 2013 -0500

----------------------------------------------------------------------
 CHANGES.txt                                              |  1 +
 pylib/cqlshlib/cql3handling.py                           |  2 +-
 .../org/apache/cassandra/config/DatabaseDescriptor.java  |  9 ++-------
 src/java/org/apache/cassandra/config/Schema.java         |  2 +-
 .../org/apache/cassandra/service/CassandraDaemon.java    |  8 ++++----
 src/java/org/apache/cassandra/service/ClientState.java   | 10 +++++++---
 .../org/apache/cassandra/service/StorageService.java     | 11 +++++++++--
 7 files changed, 25 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/88944ffc/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 80aed13..a1acc94 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -14,6 +14,7 @@
  * Add more hooks for compaction strategy implementations (CASSANDRA-6111)
  * Fix potential NPE on composite 2ndary indexes (CASSANDRA-6098)
  * Delete can potentially be skipped in batch (CASSANDRA-6115)
+ * Allow alter keyspace on system_traces (CASSANDRA-6016)
 Merged from 1.2:
  * lock access to TM.endpointToHostIdMap (CASSANDRA-6103)
  * Allow estimated memtable size to exceed slab allocator size (CASSANDRA-6078)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/88944ffc/pylib/cqlshlib/cql3handling.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/cql3handling.py b/pylib/cqlshlib/cql3handling.py
index 366adcb..3b50cc9 100644
--- a/pylib/cqlshlib/cql3handling.py
+++ b/pylib/cqlshlib/cql3handling.py
@@ -43,7 +43,7 @@ class UnexpectedTableStructure(UserWarning):
         return 'Unexpected table structure; may not translate correctly to CQL. ' + self.msg
 
 SYSTEM_KEYSPACES = ('system', 'system_traces', 'system_auth')
-NONALTERBALE_KEYSPACES = ('system', 'system_traces')
+NONALTERBALE_KEYSPACES = ('system')
 
 class Cql3ParsingRuleSet(CqlParsingRuleSet):
     keywords = set((

http://git-wip-us.apache.org/repos/asf/cassandra/blob/88944ffc/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
index 81c7308..ead9654 100644
--- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
+++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
@@ -463,15 +463,10 @@ public class DatabaseDescriptor
         memtableAllocator = FBUtilities.classForName(allocatorClass, "allocator");
 
         // Hardcoded system keyspaces
-        List<KSMetaData> systemKeyspaces = Arrays.asList(KSMetaData.systemKeyspace(),
KSMetaData.traceKeyspace());
+        List<KSMetaData> systemKeyspaces = Arrays.asList(KSMetaData.systemKeyspace());
         assert systemKeyspaces.size() == Schema.systemKeyspaceNames.size();
         for (KSMetaData ksmd : systemKeyspaces)
-        {
-            // install the definition
-            for (CFMetaData cfm : ksmd.cfMetaData().values())
-                Schema.instance.load(cfm);
-            Schema.instance.setKeyspaceDefinition(ksmd);
-        }
+            Schema.instance.load(ksmd);
 
         /* Load the seeds for node contact points */
         if (conf.seed_provider == null)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/88944ffc/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 2a9a731..d822704 100644
--- a/src/java/org/apache/cassandra/config/Schema.java
+++ b/src/java/org/apache/cassandra/config/Schema.java
@@ -64,7 +64,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,
Tracing.TRACE_KS);
+    public static final ImmutableSet<String> systemKeyspaceNames = ImmutableSet.of(Keyspace.SYSTEM_KS);
 
     static
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/88944ffc/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 f7e8af4..1de5b49 100644
--- a/src/java/org/apache/cassandra/service/CassandraDaemon.java
+++ b/src/java/org/apache/cassandra/service/CassandraDaemon.java
@@ -25,8 +25,6 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Arrays;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 import javax.management.StandardMBean;
@@ -35,7 +33,6 @@ import com.addthis.metrics.reporter.config.ReporterConfig;
 
 import com.google.common.collect.Iterables;
 import com.google.common.collect.SetMultimap;
-
 import org.apache.log4j.PropertyConfigurator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -43,7 +40,10 @@ import org.slf4j.LoggerFactory;
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.config.Schema;
-import org.apache.cassandra.db.*;
+import org.apache.cassandra.db.ColumnFamilyStore;
+import org.apache.cassandra.db.Keyspace;
+import org.apache.cassandra.db.MeteredFlusher;
+import org.apache.cassandra.db.SystemKeyspace;
 import org.apache.cassandra.db.commitlog.CommitLog;
 import org.apache.cassandra.db.compaction.CompactionManager;
 import org.apache.cassandra.db.compaction.LegacyLeveledManifest;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/88944ffc/src/java/org/apache/cassandra/service/ClientState.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/ClientState.java b/src/java/org/apache/cassandra/service/ClientState.java
index 3798845..472fe53 100644
--- a/src/java/org/apache/cassandra/service/ClientState.java
+++ b/src/java/org/apache/cassandra/service/ClientState.java
@@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
+import com.google.common.collect.Sets;
 import org.apache.commons.lang3.StringUtils;
 
 import org.apache.cassandra.auth.*;
@@ -35,6 +36,7 @@ import org.apache.cassandra.db.SystemKeyspace;
 import org.apache.cassandra.exceptions.AuthenticationException;
 import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.exceptions.UnauthorizedException;
+import org.apache.cassandra.tracing.Tracing;
 import org.apache.cassandra.utils.Pair;
 import org.apache.cassandra.utils.SemanticVersion;
 
@@ -202,11 +204,13 @@ public class ClientState
         if (!(perm.equals(Permission.ALTER) || perm.equals(Permission.DROP) || perm.equals(Permission.CREATE)))
             return;
 
-        if (Schema.systemKeyspaceNames.contains(keyspace.toLowerCase()))
+        // prevent system keyspace modification
+        if (Keyspace.SYSTEM_KS.equalsIgnoreCase(keyspace))
             throw new UnauthorizedException(keyspace + " keyspace is not user-modifiable.");
 
-        // we want to allow altering AUTH_KS itself.
-        if (keyspace.equals(Auth.AUTH_KS) && !(resource.isKeyspaceLevel() &&
perm.equals(Permission.ALTER)))
+        // we want to allow altering AUTH_KS and TRACING_KS.
+        Set<String> allowAlter = Sets.newHashSet(Auth.AUTH_KS, Tracing.TRACE_KS);
+        if (allowAlter.contains(keyspace.toLowerCase()) && !(resource.isKeyspaceLevel()
&& perm.equals(Permission.ALTER)))
             throw new UnauthorizedException(String.format("Cannot %s %s", perm, resource));
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/88944ffc/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 d28fcb5..bff909e 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -742,6 +742,13 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
             }
         }
 
+        // if we don't have system_traces keyspace at this point, then create it manually
+        if (Schema.instance.getKSMetaData(Tracing.TRACE_KS) == null)
+        {
+            KSMetaData tracingKeyspace = KSMetaData.traceKeyspace();
+            MigrationManager.announceNewKeyspace(tracingKeyspace, 0);
+        }
+
         if (!isSurveyMode)
         {
             // start participating in the ring.
@@ -2298,7 +2305,7 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
 
     public int forceRepairAsync(final String keyspace, final boolean isSequential, final
boolean isLocal, final Collection<Range<Token>> ranges, final String... columnFamilies)
     {
-        if (Keyspace.SYSTEM_KS.equals(keyspace) || Tracing.TRACE_KS.equals(keyspace) || ranges.isEmpty())
+        if (Keyspace.SYSTEM_KS.equals(keyspace) || ranges.isEmpty())
             return 0;
 
         final int cmd = nextRepairCommand.incrementAndGet();
@@ -2348,7 +2355,7 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
 
     public void forceKeyspaceRepairRange(final String keyspaceName, final Collection<Range<Token>>
ranges, boolean isSequential, boolean isLocal, final String... columnFamilies) throws IOException
     {
-        if (Schema.systemKeyspaceNames.contains(keyspaceName))
+        if (Keyspace.SYSTEM_KS.equalsIgnoreCase(keyspaceName))
             return;
         createRepairTask(nextRepairCommand.incrementAndGet(), keyspaceName, ranges, isSequential,
isLocal, columnFamilies).run();
     }


Mime
View raw message