cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject git commit: include metadata for system keyspace itself in schema tables patch by jbellis; reviewed by slebresne for CASSANDRA-4416
Date Tue, 02 Oct 2012 03:46:32 GMT
Updated Branches:
  refs/heads/trunk e05a5fc12 -> d41d5f6db


include metadata for system keyspace itself in schema tables
patch by jbellis; reviewed by slebresne for CASSANDRA-4416


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

Branch: refs/heads/trunk
Commit: d41d5f6db29721726765723a1cba8d38bb52ce22
Parents: e05a5fc
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Mon Oct 1 22:44:39 2012 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Mon Oct 1 22:46:04 2012 -0500

----------------------------------------------------------------------
 CHANGES.txt                                        |    9 +++++--
 .../cassandra/config/DatabaseDescriptor.java       |    2 +
 src/java/org/apache/cassandra/config/Schema.java   |    6 +---
 src/java/org/apache/cassandra/db/DefsTable.java    |    6 ++--
 src/java/org/apache/cassandra/db/SystemTable.java  |   18 +++++++++++++++
 .../org/apache/cassandra/tools/SSTableExport.java  |    6 -----
 6 files changed, 31 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/d41d5f6d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index d3932b7..9067ba8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 1.2-beta2
+ * include metadata for system keyspace itself in schema tables (CASSANDRA-4416)
  * add check to PropertyFileSnitch to verify presence of location for
    local node (CASSANDRA-4728)
  * add PBSPredictor consistency modeler (CASSANDRA-4261)
@@ -7,14 +8,16 @@
  * adjust blockFor calculation to account for pending ranges due to node 
    movement (CASSANDRA-833)
  * Change CQL version to 3.0.0 and stop accepting 3.0.0-beta1 (CASSANDRA-4649)
- * (CQL3) Make prepared statement global instead of per connection (CASSANDRA-4449)
+ * (CQL3) Make prepared statement global instead of per connection 
+   (CASSANDRA-4449)
  * Fix scrubbing of CQL3 created tables (CASSANDRA-4685)
- * (CQL3) Fix validation when using counter and regular columns in the same table
-   (CASSANDRA-4706)
+ * (CQL3) Fix validation when using counter and regular columns in the same 
+   table (CASSANDRA-4706)
  * Fix bug starting Cassandra with simple authentication (CASSANDRA-4648)
  * Add support for batchlog in CQL3 (CASSANDRA-4545)
  * Add support for multiple column family outputs in CFOF (CASSANDRA-4208)
 
+
 1.2-beta1
  * add atomic_batch_mutate (CASSANDRA-4542, -4635)
  * increase default max_hint_window_in_ms to 3h (CASSANDRA-4632)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d41d5f6d/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 e3ce40c..91bd9b6 100644
--- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
+++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
@@ -464,8 +464,10 @@ public class DatabaseDescriptor
 
             // Hardcoded system tables
             List<KSMetaData> systemKeyspaces = Arrays.asList(KSMetaData.systemKeyspace(),
KSMetaData.traceKeyspace());
+            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.setTableDefinition(ksmd);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d41d5f6d/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 dd16b4b..de89140 100644
--- a/src/java/org/apache/cassandra/config/Schema.java
+++ b/src/java/org/apache/cassandra/config/Schema.java
@@ -64,6 +64,7 @@ public class Schema
 
     // 59adb24e-f3cd-3e02-97f0-5b395827453f
     public static final UUID emptyVersion;
+    public static final ImmutableSet<String> systemKeyspaceNames = ImmutableSet.of(Table.SYSTEM_KS,
Tracing.TRACE_KS);
 
     static
     {
@@ -277,8 +278,7 @@ public class Schema
      */
     public List<String> getNonSystemTables()
     {
-        ImmutableSet<String> system = ImmutableSet.of(Table.SYSTEM_KS, Tracing.TRACE_KS);
-        return ImmutableList.copyOf(Sets.difference(tables.keySet(), system));
+        return ImmutableList.copyOf(Sets.difference(tables.keySet(), systemKeyspaceNames));
     }
 
     /**
@@ -387,8 +387,6 @@ public class Schema
      * (to make ColumnFamily lookup faster)
      *
      * @param cfm The ColumnFamily definition to load
-     *
-     * @throws ConfigurationException if ColumnFamily was already loaded
      */
     public void load(CFMetaData cfm)
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d41d5f6d/src/java/org/apache/cassandra/db/DefsTable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/DefsTable.java b/src/java/org/apache/cassandra/db/DefsTable.java
index e43ce8a..3deac35 100644
--- a/src/java/org/apache/cassandra/db/DefsTable.java
+++ b/src/java/org/apache/cassandra/db/DefsTable.java
@@ -127,8 +127,8 @@ public class DefsTable
     public static final String OLD_MIGRATIONS_CF = "Migrations";
     public static final String OLD_SCHEMA_CF = "Schema";
 
-    /* dumps current keyspace definitions to storage */
-    public static synchronized void dumpToStorage(Collection<KSMetaData> keyspaces)
+    /* saves keyspace definitions to system schema columnfamilies */
+    public static synchronized void save(Collection<KSMetaData> keyspaces)
     {
         long timestamp = System.currentTimeMillis();
 
@@ -289,7 +289,7 @@ public class DefsTable
             }
 
             // store deserialized keyspaces into new place
-            dumpToStorage(keyspaces);
+            save(keyspaces);
 
             logger.info("Truncating deprecated system column families (migrations, schema)...");
             dropColumnFamily(Table.SYSTEM_KS, OLD_MIGRATIONS_CF);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d41d5f6d/src/java/org/apache/cassandra/db/SystemTable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SystemTable.java b/src/java/org/apache/cassandra/db/SystemTable.java
index 8c91e10..ead325f 100644
--- a/src/java/org/apache/cassandra/db/SystemTable.java
+++ b/src/java/org/apache/cassandra/db/SystemTable.java
@@ -29,6 +29,8 @@ import com.google.common.collect.Multimap;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.cassandra.config.KSMetaData;
+import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.cql3.QueryProcessor;
@@ -103,6 +105,22 @@ public class SystemTable
         {
             throw new RuntimeException(e);
         }
+
+        // add entries to system schema columnfamilies for the hardcoded system definitions
+        for (String ksname : Schema.systemKeyspaceNames)
+        {
+            KSMetaData ksmd = Schema.instance.getKSMetaData(ksname);
+
+            // delete old, possibly obsolete entries in schema columnfamilies
+            for (String cfname : Arrays.asList(SystemTable.SCHEMA_KEYSPACES_CF, SystemTable.SCHEMA_COLUMNFAMILIES_CF,
SystemTable.SCHEMA_COLUMNS_CF))
+            {
+                String req = String.format("DELETE FROM system.%s WHERE keyspace_name = '%s'",
cfname, ksmd.name);
+                processInternal(req);
+            }
+
+            // (+1 to timestamp to make sure we don't get shadowed by the tombstones we just
added)
+            ksmd.toSchema(FBUtilities.timestampMicros() + 1).apply();
+        }
     }
 
     private static void setupVersion()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d41d5f6d/src/java/org/apache/cassandra/tools/SSTableExport.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/SSTableExport.java b/src/java/org/apache/cassandra/tools/SSTableExport.java
index 260331d..fe7d6c0 100644
--- a/src/java/org/apache/cassandra/tools/SSTableExport.java
+++ b/src/java/org/apache/cassandra/tools/SSTableExport.java
@@ -501,12 +501,6 @@ public class SSTableExport
         String ssTableFileName = new File(cmd.getArgs()[0]).getAbsolutePath();
 
         DatabaseDescriptor.loadSchemas();
-        if (Schema.instance.getNonSystemTables().size() < 1)
-        {
-            String msg = "no non-system tables are defined";
-            System.err.println(msg);
-            throw new ConfigurationException(msg);
-        }
         Descriptor descriptor = Descriptor.fromFilename(ssTableFileName);
         if (Schema.instance.getCFMetaData(descriptor) == null)
         {


Mime
View raw message