cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1178599 - in /cassandra/branches/cassandra-1.0: ./ src/java/org/apache/cassandra/config/ src/java/org/apache/cassandra/cql/ src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/service/
Date Mon, 03 Oct 2011 21:51:48 GMT
Author: jbellis
Date: Mon Oct  3 21:51:48 2011
New Revision: 1178599

URL: http://svn.apache.org/viewvc?rev=1178599&view=rev
Log:
add system.versions ColumnFamily
patch by jbellis; reviewed by Paul Cannon for CASSANDRA-3140

Modified:
    cassandra/branches/cassandra-1.0/CHANGES.txt
    cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/config/CFMetaData.java
    cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
    cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/cql/QueryProcessor.java
    cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/SystemTable.java
    cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java

Modified: cassandra/branches/cassandra-1.0/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/CHANGES.txt?rev=1178599&r1=1178598&r2=1178599&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/CHANGES.txt (original)
+++ cassandra/branches/cassandra-1.0/CHANGES.txt Mon Oct  3 21:51:48 2011
@@ -2,6 +2,7 @@
  * describe_ring should include datacenter/topology information (CASSANDRA-2882)
  * Thrift sockets are not properly buffered (CASSANDRA-3261)
  * performance improvement for bytebufferutil compare function (CASSANDRA-3286)
+ * add system.versions ColumnFamily (CASSANDRA-3140)
 
 
 1.0.0-final

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/config/CFMetaData.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/config/CFMetaData.java?rev=1178599&r1=1178598&r2=1178599&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/config/CFMetaData.java
(original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/config/CFMetaData.java
Mon Oct  3 21:51:48 2011
@@ -77,6 +77,25 @@ public final class CFMetaData
     public static final CFMetaData SchemaCf = newSystemMetadata(Migration.SCHEMA_CF, 3, "current
state of the schema", UTF8Type.instance, null);
     public static final CFMetaData IndexCf = newSystemMetadata(SystemTable.INDEX_CF, 5, "indexes
that have been completed", UTF8Type.instance, null);
     public static final CFMetaData NodeIdCf = newSystemMetadata(SystemTable.NODE_ID_CF, 6,
"nodeId and their metadata", TimeUUIDType.instance, null);
+    public static final CFMetaData VersionCf = newSystemMetadata(SystemTable.VERSION_CF,
7, "server version information", UTF8Type.instance, null);
+    static
+    {
+        try
+        {
+            VersionCf.keyAlias(ByteBufferUtil.bytes("component"))
+                     .keyValidator(UTF8Type.instance)
+                     .columnMetadata(Collections.singletonMap(ByteBufferUtil.bytes("version"),
+                                                              new ColumnDefinition(ByteBufferUtil.bytes("version"),
+                                                                                   UTF8Type.instance,
+                                                                                   null,
+                                                                                   null,
+                                                                                   null)));
+        }
+        catch (ConfigurationException e)
+        {
+            throw new RuntimeException(e);
+        }
+    }
 
     private static IRowCacheProvider initDefaultRowCacheProvider()
     {

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/config/DatabaseDescriptor.java?rev=1178599&r1=1178598&r2=1178599&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
(original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Mon Oct  3 21:51:48 2011
@@ -34,6 +34,7 @@ import org.apache.cassandra.auth.IAuthor
 import org.apache.cassandra.config.Config.RequestSchedulerId;
 import org.apache.cassandra.db.ColumnFamilyStore;
 import org.apache.cassandra.db.DefsTable;
+import org.apache.cassandra.db.SystemTable;
 import org.apache.cassandra.db.Table;
 import org.apache.cassandra.db.migration.Migration;
 import org.apache.cassandra.dht.IPartitioner;
@@ -402,16 +403,18 @@ public class DatabaseDescriptor
                                                    CFMetaData.MigrationsCf,
                                                    CFMetaData.SchemaCf,
                                                    CFMetaData.IndexCf,
-                                                   CFMetaData.NodeIdCf);
+                                                   CFMetaData.NodeIdCf,
+                                                   CFMetaData.VersionCf);
             Schema.instance.load(CFMetaData.StatusCf);
             Schema.instance.load(CFMetaData.HintsCf);
             Schema.instance.load(CFMetaData.MigrationsCf);
             Schema.instance.load(CFMetaData.SchemaCf);
             Schema.instance.load(CFMetaData.IndexCf);
             Schema.instance.load(CFMetaData.NodeIdCf);
+            Schema.instance.load(CFMetaData.VersionCf);
 
             Schema.instance.addSystemTable(systemMeta);
-            
+
             /* Load the seeds for node contact points */
             if (conf.seed_provider == null)
             {

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/cql/QueryProcessor.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/cql/QueryProcessor.java?rev=1178599&r1=1178598&r2=1178599&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/cql/QueryProcessor.java
(original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/cql/QueryProcessor.java
Mon Oct  3 21:51:48 2011
@@ -64,6 +64,8 @@ import static org.apache.cassandra.thrif
 
 public class QueryProcessor
 {
+    public static final String CQL_VERSION = "2.0.0";
+
     private static final Logger logger = LoggerFactory.getLogger(QueryProcessor.class);
 
     private static final long timeLimitForSchemaAgreement = 10 * 1000;

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/SystemTable.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/SystemTable.java?rev=1178599&r1=1178598&r2=1178599&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/SystemTable.java (original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/SystemTable.java Mon
Oct  3 21:51:48 2011
@@ -35,12 +35,14 @@ import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.config.ConfigurationException;
 import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.cql.QueryProcessor;
 import org.apache.cassandra.db.filter.QueryFilter;
 import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.db.marshal.BytesType;
 import org.apache.cassandra.dht.IPartitioner;
 import org.apache.cassandra.dht.Token;
 import org.apache.cassandra.service.StorageService;
+import org.apache.cassandra.thrift.Constants;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.NodeId;
@@ -51,6 +53,7 @@ public class SystemTable
     public static final String STATUS_CF = "LocationInfo"; // keep the old CF string for
backwards-compatibility
     public static final String INDEX_CF = "IndexInfo";
     public static final String NODE_ID_CF = "NodeIdInfo";
+    public static final String VERSION_CF = "Versions";
     private static final ByteBuffer LOCATION_KEY = ByteBufferUtil.bytes("L");
     private static final ByteBuffer RING_KEY = ByteBufferUtil.bytes("Ring");
     private static final ByteBuffer BOOTSTRAP_KEY = ByteBufferUtil.bytes("Bootstrap");
@@ -68,8 +71,38 @@ public class SystemTable
         return StorageService.getPartitioner().decorateKey(key);
     }
     
-    /* if hints become incompatible across versions of cassandra, that logic (and associated
purging) is managed here. */
-    public static void purgeIncompatibleHints() throws IOException
+    public static void finishStartup() throws IOException
+    {
+        setupVersion();
+        purgeIncompatibleHints();
+    }
+
+    private static void setupVersion() throws IOException
+    {
+        RowMutation rm;
+        ColumnFamily cf;
+
+        rm = new RowMutation(Table.SYSTEM_TABLE, ByteBufferUtil.bytes("build"));
+        cf = ColumnFamily.create(Table.SYSTEM_TABLE, VERSION_CF);
+        cf.addColumn(new Column(ByteBufferUtil.bytes("version"), ByteBufferUtil.bytes(FBUtilities.getReleaseVersionString())));
+        rm.add(cf);
+        rm.apply();
+
+        rm = new RowMutation(Table.SYSTEM_TABLE, ByteBufferUtil.bytes("cql"));
+        cf = ColumnFamily.create(Table.SYSTEM_TABLE, VERSION_CF);
+        cf.addColumn(new Column(ByteBufferUtil.bytes("version"), ByteBufferUtil.bytes(QueryProcessor.CQL_VERSION)));
+        rm.add(cf);
+        rm.apply();
+
+        rm = new RowMutation(Table.SYSTEM_TABLE, ByteBufferUtil.bytes("thrift"));
+        cf = ColumnFamily.create(Table.SYSTEM_TABLE, VERSION_CF);
+        cf.addColumn(new Column(ByteBufferUtil.bytes("version"), ByteBufferUtil.bytes(Constants.VERSION)));
+        rm.add(cf);
+        rm.apply();
+    }
+
+    /** if hints become incompatible across versions of cassandra, that logic (and associated
purging) is managed here. */
+    private static void purgeIncompatibleHints() throws IOException
     {
         ByteBuffer upgradeMarker = ByteBufferUtil.bytes("Pre-1.0 hints purged");
         Table table = Table.open(Table.SYSTEM_TABLE);

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java?rev=1178599&r1=1178598&r2=1178599&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
(original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
Mon Oct  3 21:51:48 2011
@@ -206,7 +206,7 @@ public abstract class AbstractCassandraD
             MigrationManager.applyMigrations(currentMigration, lastMigration);
         }
         
-        SystemTable.purgeIncompatibleHints();
+        SystemTable.finishStartup();
 
         // start server internals
         StorageService.instance.registerDaemon(this);



Mime
View raw message