Author: eevans
Date: Thu May 27 17:46:08 2010
New Revision: 948929

URL: http://svn.apache.org/viewvc?rev=948929&view=rev
Log:
apply CASSANDRA-987 to thrift.CassandraDaemon too...

...and expect that lastMigration might be null

Patch by eevans

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraDaemon.java
    cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java

Modified: 
cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraDaemon.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraDaemon.java?rev=948929&r1=948928&r2=948929&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraDaemon.java 
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraDaemon.java Thu 
May 27 17:46:08 2010
@@ -110,7 +110,7 @@ public class CassandraDaemon {
         // is to read those migrations from disk and apply them.
         UUID currentMigration = DatabaseDescriptor.getDefsVersion();
         UUID lastMigration = Migration.getLastMigrationId();
-        if (lastMigration.timestamp() > currentMigration.timestamp())
+        if ((lastMigration != null) && (lastMigration.timestamp() > 
currentMigration.timestamp()))
         {
             MigrationManager.applyMigrations(currentMigration, lastMigration);
         }

Modified: 
cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java?rev=948929&r1=948928&r2=948929&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java 
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java 
Thu May 27 17:46:08 2010
@@ -22,6 +22,7 @@ import java.io.File;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.InetAddress;
+import java.util.UUID;
 
 import org.apache.cassandra.config.ConfigurationException;
 import org.slf4j.Logger;
@@ -31,6 +32,7 @@ import org.apache.log4j.PropertyConfigur
 
 import org.apache.cassandra.utils.Mx4jTool;
 import org.apache.cassandra.db.commitlog.CommitLog;
+import org.apache.cassandra.db.migration.Migration;
 import org.apache.thrift.protocol.TBinaryProtocol;
 import org.apache.thrift.protocol.TProtocolFactory;
 import org.apache.thrift.server.TThreadPoolServer;
@@ -40,6 +42,7 @@ import org.apache.thrift.transport.TTran
 import org.apache.thrift.transport.TFramedTransport;
 import org.apache.thrift.TProcessorFactory;
 import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.db.Table;
@@ -104,7 +107,17 @@ public class CassandraDaemon
         // replay the log if necessary and check for compaction candidates
         CommitLog.recover();
         CompactionManager.instance.checkAllColumnFamilies();
-
+        
+        // check to see if CL.recovery modified the lastMigrationId. if it 
did, we need to re apply migrations. this isn't
+        // the same as merely reloading the schema (which wouldn't perform 
file deletion after a DROP). The solution
+        // is to read those migrations from disk and apply them.
+        UUID currentMigration = DatabaseDescriptor.getDefsVersion();
+        UUID lastMigration = Migration.getLastMigrationId();
+        if ((lastMigration != null) && (lastMigration.timestamp() > 
currentMigration.timestamp()))
+        {
+            MigrationManager.applyMigrations(currentMigration, lastMigration);
+        }
+        
         // start server internals
         StorageService.instance.initServer();
         


Reply via email to