apply CASSANDRA-987 to thrift.CassandraDaemon too...

...and expect that lastMigration might be null

Patch by eevans

git-svn-id: https://svn.apache.org/repos/asf/cassandra/trunk@948929 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eric Evans 2010-05-27 17:46:08 +00:00
parent c924ce55eb
commit 8c323b80e8
2 changed files with 15 additions and 2 deletions

View File

@ -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);
}

View File

@ -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.PropertyConfigurator;
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.TTransportFactory;
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();