You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2012/03/18 11:10:52 UTC

[2/3] Unify migration code

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/src/java/org/apache/cassandra/db/migration/MigrationHelper.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/migration/MigrationHelper.java b/src/java/org/apache/cassandra/db/migration/MigrationHelper.java
deleted file mode 100644
index cbda1bf..0000000
--- a/src/java/org/apache/cassandra/db/migration/MigrationHelper.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.db.migration;
-
-import java.io.DataOutput;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.*;
-import java.util.concurrent.Future;
-
-import com.google.common.collect.Iterables;
-
-import org.apache.cassandra.config.CFMetaData;
-import org.apache.cassandra.config.ConfigurationException;
-import org.apache.cassandra.config.KSMetaData;
-import org.apache.cassandra.config.Schema;
-import org.apache.cassandra.db.ColumnFamilyStore;
-import org.apache.cassandra.db.RowMutation;
-import org.apache.cassandra.db.SystemTable;
-import org.apache.cassandra.db.Table;
-import org.apache.cassandra.db.marshal.UTF8Type;
-import org.apache.cassandra.service.StorageService;
-import org.apache.cassandra.utils.ByteBufferUtil;
-import org.apache.cassandra.utils.FBUtilities;
-
-public class MigrationHelper
-{
-    private static final Map<Class<?>, Class<?>> primitiveToWrapper = new HashMap<Class<?>, Class<?>>();
-    static
-    {
-        primitiveToWrapper.put(boolean.class, Boolean.class);
-        primitiveToWrapper.put(byte.class, Byte.class);
-        primitiveToWrapper.put(short.class, Short.class);
-        primitiveToWrapper.put(char.class, Character.class);
-        primitiveToWrapper.put(int.class, Integer.class);
-        primitiveToWrapper.put(long.class, Long.class);
-        primitiveToWrapper.put(float.class, Float.class);
-        primitiveToWrapper.put(double.class, Double.class);
-    }
-
-    public static ByteBuffer searchComposite(String name, boolean start)
-    {
-        assert name != null;
-        ByteBuffer nameBytes = UTF8Type.instance.decompose(name);
-        int length = nameBytes.remaining();
-        byte[] bytes = new byte[2 + length + 1];
-        bytes[0] = (byte)((length >> 8) & 0xFF);
-        bytes[1] = (byte)(length & 0xFF);
-        ByteBufferUtil.arrayCopy(nameBytes, 0, bytes, 2, length);
-        bytes[bytes.length - 1] = (byte)(start ? 0 : 1);
-        return ByteBuffer.wrap(bytes);
-    }
-
-    public static void flushSchemaCFs()
-    {
-        flushSchemaCF(SystemTable.SCHEMA_KEYSPACES_CF);
-        flushSchemaCF(SystemTable.SCHEMA_COLUMNFAMILIES_CF);
-        flushSchemaCF(SystemTable.SCHEMA_COLUMNS_CF);
-    }
-
-    public static void flushSchemaCF(String cfName)
-    {
-        Future<?> flush = SystemTable.schemaCFS(cfName).forceFlush();
-
-        if (flush != null)
-            FBUtilities.waitOnFuture(flush);
-    }
-
-    /* Migration Helper implementations */
-
-    public static RowMutation addKeyspace(KSMetaData ksm, long timestamp, boolean withSchemaRecord) throws ConfigurationException, IOException
-    {
-        RowMutation mutation = null;
-
-        if (withSchemaRecord)
-        {
-            mutation = ksm.toSchema(timestamp);
-            mutation.apply();
-        }
-
-        Schema.instance.load(ksm);
-
-        if (!StorageService.instance.isClientMode())
-            Table.open(ksm.name);
-
-        return mutation;
-    }
-
-    public static RowMutation addColumnFamily(CFMetaData cfm, long timestamp, boolean withSchemaRecord) throws ConfigurationException, IOException
-    {
-        KSMetaData ksm = Schema.instance.getTableDefinition(cfm.ksName);
-        ksm = KSMetaData.cloneWith(ksm, Iterables.concat(ksm.cfMetaData().values(), Collections.singleton(cfm)));
-
-        Schema.instance.load(cfm);
-
-        RowMutation mutation = null;
-
-        if (withSchemaRecord)
-        {
-            mutation = cfm.toSchema(timestamp);
-            mutation.apply();
-        }
-
-        // make sure it's init-ed w/ the old definitions first,
-        // since we're going to call initCf on the new one manually
-        Table.open(cfm.ksName);
-
-        Schema.instance.setTableDefinition(ksm);
-
-        if (!StorageService.instance.isClientMode())
-            Table.open(ksm.name).initCf(cfm.cfId, cfm.cfName);
-
-        return mutation;
-    }
-
-    public static RowMutation updateKeyspace(KSMetaData newState, long timestamp, boolean withSchemaRecord) throws ConfigurationException, IOException
-    {
-        KSMetaData oldKsm = Schema.instance.getKSMetaData(newState.name);
-
-        RowMutation mutation = null;
-
-        if (withSchemaRecord)
-        {
-            mutation = oldKsm.diff(newState, timestamp);
-            mutation.apply();
-        }
-
-        KSMetaData newKsm = KSMetaData.cloneWith(oldKsm.reloadAttributes(), oldKsm.cfMetaData().values());
-
-        Schema.instance.setTableDefinition(newKsm);
-
-        if (!StorageService.instance.isClientMode())
-            Table.open(newState.name).createReplicationStrategy(newKsm);
-
-        return mutation;
-    }
-
-    public static RowMutation updateColumnFamily(CFMetaData newState, long timestamp, boolean withSchemaRecord) throws ConfigurationException, IOException
-    {
-        CFMetaData cfm = Schema.instance.getCFMetaData(newState.ksName, newState.cfName);
-
-        RowMutation mutation = null;
-
-        if (withSchemaRecord)
-        {
-            mutation = cfm.diff(newState, timestamp);
-            mutation.apply();
-        }
-
-        cfm.reload();
-
-        if (!StorageService.instance.isClientMode())
-        {
-            Table table = Table.open(cfm.ksName);
-            table.getColumnFamilyStore(cfm.cfName).reload();
-        }
-
-        return mutation;
-    }
-
-    public static RowMutation dropKeyspace(String ksName, long timestamp, boolean withSchemaRecord) throws IOException
-    {
-        KSMetaData ksm = Schema.instance.getTableDefinition(ksName);
-        String snapshotName = Table.getTimestampedSnapshotName(ksName);
-
-        // remove all cfs from the table instance.
-        for (CFMetaData cfm : ksm.cfMetaData().values())
-        {
-            ColumnFamilyStore cfs = Table.open(ksm.name).getColumnFamilyStore(cfm.cfName);
-
-            Schema.instance.purge(cfm);
-
-            if (!StorageService.instance.isClientMode())
-            {
-                cfs.snapshot(snapshotName);
-                Table.open(ksm.name).dropCf(cfm.cfId);
-            }
-        }
-
-        RowMutation mutation = null;
-
-        if (withSchemaRecord)
-        {
-            mutation = ksm.dropFromSchema(timestamp);
-            mutation.apply();
-        }
-
-        // remove the table from the static instances.
-        Table.clear(ksm.name);
-        Schema.instance.clearTableDefinition(ksm);
-
-        return mutation;
-    }
-
-    public static RowMutation dropColumnFamily(String ksName, String cfName, long timestamp, boolean withSchemaRecord) throws IOException
-    {
-        KSMetaData ksm = Schema.instance.getTableDefinition(ksName);
-        ColumnFamilyStore cfs = Table.open(ksName).getColumnFamilyStore(cfName);
-
-        // reinitialize the table.
-        CFMetaData cfm = ksm.cfMetaData().get(cfName);
-
-        Schema.instance.purge(cfm);
-        Schema.instance.setTableDefinition(makeNewKeyspaceDefinition(ksm, cfm));
-
-        RowMutation mutation = null;
-
-        if (withSchemaRecord)
-        {
-            mutation = cfm.dropFromSchema(timestamp);
-            mutation.apply();
-        }
-
-        if (!StorageService.instance.isClientMode())
-        {
-            cfs.snapshot(Table.getTimestampedSnapshotName(cfs.columnFamily));
-            Table.open(ksm.name).dropCf(cfm.cfId);
-        }
-
-        return mutation;
-    }
-
-    private static KSMetaData makeNewKeyspaceDefinition(KSMetaData ksm, CFMetaData toExclude)
-    {
-        // clone ksm but do not include the new def
-        List<CFMetaData> newCfs = new ArrayList<CFMetaData>(ksm.cfMetaData().values());
-        newCfs.remove(toExclude);
-        assert newCfs.size() == ksm.cfMetaData().size() - 1;
-        return KSMetaData.cloneWith(ksm, newCfs);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/src/java/org/apache/cassandra/db/migration/UpdateColumnFamily.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/migration/UpdateColumnFamily.java b/src/java/org/apache/cassandra/db/migration/UpdateColumnFamily.java
deleted file mode 100644
index 40d56e2..0000000
--- a/src/java/org/apache/cassandra/db/migration/UpdateColumnFamily.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.db.migration;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import org.apache.cassandra.config.CFMetaData;
-import org.apache.cassandra.config.ConfigurationException;
-import org.apache.cassandra.config.Schema;
-import org.apache.cassandra.db.RowMutation;
-
-public class UpdateColumnFamily extends Migration
-{
-    private final CFMetaData newState;
-
-    public UpdateColumnFamily(CFMetaData newState) throws ConfigurationException
-    {
-        super(System.nanoTime());
-
-        if (Schema.instance.getCFMetaData(newState.ksName, newState.cfName) == null)
-            throw new ConfigurationException(String.format("(ks=%s, cf=%s) cannot be updated because it doesn't exist.", newState.ksName, newState.cfName));
-
-        this.newState = newState;
-    }
-
-    protected RowMutation applyImpl() throws ConfigurationException, IOException
-    {
-        return MigrationHelper.updateColumnFamily(newState, timestamp, true);
-    }
-
-    @Override
-    public String toString()
-    {
-        return String.format("Update column family with %s", newState);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/src/java/org/apache/cassandra/db/migration/UpdateKeyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/migration/UpdateKeyspace.java b/src/java/org/apache/cassandra/db/migration/UpdateKeyspace.java
deleted file mode 100644
index 267ec1e..0000000
--- a/src/java/org/apache/cassandra/db/migration/UpdateKeyspace.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.db.migration;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import org.apache.cassandra.config.ConfigurationException;
-import org.apache.cassandra.config.KSMetaData;
-import org.apache.cassandra.config.Schema;
-import org.apache.cassandra.db.RowMutation;
-import org.apache.cassandra.thrift.KsDef;
-
-public class UpdateKeyspace extends Migration
-{
-    private final KSMetaData newState;
-
-    public UpdateKeyspace(KSMetaData newState) throws ConfigurationException
-    {
-        super(System.nanoTime());
-
-        if (!newState.cfMetaData().isEmpty())
-            throw new ConfigurationException("Updated keyspace must not contain any column families.");
-
-        if (Schema.instance.getKSMetaData(newState.name) == null)
-            throw new ConfigurationException(newState.name + " cannot be updated because it doesn't exist.");
-
-        this.newState = newState;
-    }
-
-    protected RowMutation applyImpl() throws ConfigurationException, IOException
-    {
-        RowMutation mutation = MigrationHelper.updateKeyspace(newState, timestamp, true);
-        logger.info("Keyspace updated. Please perform any manual operations.");
-        return mutation;
-    }
-
-    @Override
-    public String toString()
-    {
-        return String.format("Update keyspace %s with %s", newState.name, newState);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/src/java/org/apache/cassandra/service/MigrationManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/MigrationManager.java b/src/java/org/apache/cassandra/service/MigrationManager.java
index 467b5f9..0f9169d 100644
--- a/src/java/org/apache/cassandra/service/MigrationManager.java
+++ b/src/java/org/apache/cassandra/service/MigrationManager.java
@@ -23,7 +23,9 @@ import java.io.DataOutputStream;
 import java.io.IOError;
 import java.io.IOException;
 import java.net.InetAddress;
+import java.nio.ByteBuffer;
 import java.util.*;
+import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.ArrayList;
@@ -37,16 +39,23 @@ import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.concurrent.Stage;
 import org.apache.cassandra.concurrent.StageManager;
+import org.apache.cassandra.config.CFMetaData;
+import org.apache.cassandra.config.ConfigurationException;
 import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.config.KSMetaData;
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.db.*;
+import org.apache.cassandra.db.filter.QueryFilter;
+import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.gms.*;
 import org.apache.cassandra.io.util.FastByteArrayInputStream;
 import org.apache.cassandra.io.util.FastByteArrayOutputStream;
 import org.apache.cassandra.net.IAsyncResult;
 import org.apache.cassandra.net.Message;
 import org.apache.cassandra.net.MessagingService;
+import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
+import org.apache.cassandra.utils.UUIDGen;
 import org.apache.cassandra.utils.WrappedRunnable;
 import org.apache.commons.lang.ArrayUtils;
 
@@ -56,6 +65,7 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
 
     // try that many times to send migration request to the node before giving up
     private static final int MIGRATION_REQUEST_RETRIES = 3;
+    private static final ByteBuffer LAST_MIGRATION_KEY = ByteBufferUtil.bytes("Last Migration");
 
     public void onJoin(InetAddress endpoint, EndpointState epState)
     {}
@@ -109,6 +119,78 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
         return StageManager.getStage(Stage.MIGRATION).getActiveCount() == 0;
     }
 
+    public static void announceNewKeyspace(KSMetaData ksm) throws ConfigurationException
+    {
+        ksm.validate();
+
+        if (Schema.instance.getTableDefinition(ksm.name) != null)
+            throw new ConfigurationException(String.format("Cannot add already existing keyspace '%s'.", ksm.name));
+
+        announce(ksm.toSchema(System.nanoTime()));
+    }
+
+    public static void announceNewColumnFamily(CFMetaData cfm) throws ConfigurationException
+    {
+        cfm.validate();
+
+        KSMetaData ksm = Schema.instance.getTableDefinition(cfm.ksName);
+        if (ksm == null)
+            throw new ConfigurationException(String.format("Cannot add column family '%s' to non existing keyspace '%s'.", cfm.cfName, cfm.ksName));
+        else if (ksm.cfMetaData().containsKey(cfm.cfName))
+            throw new ConfigurationException(String.format("Cannot add already existing column family '%s' to keyspace '%s'.", cfm.cfName, cfm.ksName));
+
+        announce(cfm.toSchema(System.nanoTime()));
+    }
+
+    public static void announceKeyspaceUpdate(KSMetaData ksm) throws ConfigurationException
+    {
+        ksm.validate();
+
+        KSMetaData oldKsm = Schema.instance.getKSMetaData(ksm.name);
+        if (oldKsm == null)
+            throw new ConfigurationException(String.format("Cannot update non existing keyspace '%s'.", ksm.name));
+
+        announce(oldKsm.toSchemaUpdate(ksm, System.nanoTime()));
+    }
+
+    public static void announceColumnFamilyUpdate(CFMetaData cfm) throws ConfigurationException
+    {
+        cfm.validate();
+
+        CFMetaData oldCfm = Schema.instance.getCFMetaData(cfm.ksName, cfm.cfName);
+        if (oldCfm == null)
+            throw new ConfigurationException(String.format("Cannot update non existing column family '%s' in keyspace '%s'.", cfm.cfName, cfm.ksName));
+
+        announce(oldCfm.toSchemaUpdate(cfm, System.nanoTime()));
+    }
+
+    public static void announceKeyspaceDrop(String ksName) throws ConfigurationException
+    {
+        KSMetaData oldKsm = Schema.instance.getKSMetaData(ksName);
+        if (oldKsm == null)
+            throw new ConfigurationException(String.format("Cannot drop non existing keyspace '%s'.", ksName));
+
+        announce(oldKsm.dropFromSchema(System.nanoTime()));
+    }
+
+    public static void announceColumnFamilyDrop(String ksName, String cfName) throws ConfigurationException
+    {
+        CFMetaData oldCfm = Schema.instance.getCFMetaData(ksName, cfName);
+        if (oldCfm == null)
+            throw new ConfigurationException(String.format("Cannot drop non existing column family '%s' in keyspace '%s'.", cfName, ksName));
+
+        announce(oldCfm.dropFromSchema(System.nanoTime()));
+    }
+
+    /**
+     * actively announce a new version to active hosts via rpc
+     * @param schema The schema mutation to be applied
+     */
+    private static void announce(RowMutation schema)
+    {
+        FBUtilities.waitOnFuture(announce(Collections.singletonList(schema)));
+    }
+
     private static void pushSchemaMutation(InetAddress endpoint, Collection<RowMutation> schema)
     {
         try
@@ -122,16 +204,22 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
         }
     }
 
-    /**
-     * actively announce a new version to active hosts via rpc
-     * @param schema The list of schema mutations to be applied on the recipient
-     */
-    public static void announce(Collection<RowMutation> schema)
+    // Returns a future on the local application of the schema
+    private static Future<?> announce(final Collection<RowMutation> schema)
     {
+        Future<?> f = StageManager.getStage(Stage.MIGRATION).submit(new Callable<Object>()
+        {
+            public Object call() throws Exception
+            {
+                DefsTable.mergeSchema(schema);
+                return null;
+            }
+        });
+
         for (InetAddress endpoint : Gossiper.instance.getLiveMembers())
         {
             if (endpoint.equals(FBUtilities.getBroadcastAddress()))
-                continue; // don't push schema mutation to self
+                continue; // we've delt with localhost already
 
             // don't send migrations to the nodes with the versions older than < 1.1
             if (Gossiper.instance.getVersion(endpoint) < MessagingService.VERSION_11)
@@ -139,6 +227,7 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
 
             pushSchemaMutation(endpoint, schema);
         }
+        return f;
     }
 
     /**
@@ -275,6 +364,24 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
         }
     }
 
+    /**
+     * Used only in case node has old style migration schema (newly updated)
+     * @return the UUID identifying version of the last applied migration
+     */
+    @Deprecated
+    public static UUID getLastMigrationId()
+    {
+        DecoratedKey<?> dkey = StorageService.getPartitioner().decorateKey(LAST_MIGRATION_KEY);
+        Table defs = Table.open(Table.SYSTEM_TABLE);
+        ColumnFamilyStore cfStore = defs.getColumnFamilyStore(DefsTable.OLD_SCHEMA_CF);
+        QueryFilter filter = QueryFilter.getNamesFilter(dkey, new QueryPath(DefsTable.OLD_SCHEMA_CF), LAST_MIGRATION_KEY);
+        ColumnFamily cf = cfStore.getColumnFamily(filter);
+        if (cf == null || cf.getColumnNames().size() == 0)
+            return null;
+        else
+            return UUIDGen.getUUID(cf.getColumn(LAST_MIGRATION_KEY).value());
+    }
+
     static class MigrationTask extends WrappedRunnable
     {
         private final InetAddress endpoint;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/src/java/org/apache/cassandra/service/StorageProxy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageProxy.java b/src/java/org/apache/cassandra/service/StorageProxy.java
index d4c4474..802a477 100644
--- a/src/java/org/apache/cassandra/service/StorageProxy.java
+++ b/src/java/org/apache/cassandra/service/StorageProxy.java
@@ -813,7 +813,8 @@ public class StorageProxy implements StorageProxyMBean
                 logger.debug("LocalReadRunnable reading " + command);
 
             Table table = Table.open(command.table);
-            ReadResponse result = ReadVerbHandler.getResponse(command, command.getRow(table));
+            Row r = command.getRow(table);
+            ReadResponse result = ReadVerbHandler.getResponse(command, r);
             MessagingService.instance().addLatency(FBUtilities.getBroadcastAddress(), System.currentTimeMillis() - start);
             handler.response(result);
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/src/java/org/apache/cassandra/thrift/CassandraServer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/CassandraServer.java b/src/java/org/apache/cassandra/thrift/CassandraServer.java
index 3c53ac1..1611c2b 100644
--- a/src/java/org/apache/cassandra/thrift/CassandraServer.java
+++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java
@@ -36,27 +36,23 @@ import org.slf4j.LoggerFactory;
 
 import org.antlr.runtime.RecognitionException;
 import org.apache.cassandra.auth.Permission;
-import org.apache.cassandra.concurrent.Stage;
-import org.apache.cassandra.concurrent.StageManager;
 import org.apache.cassandra.config.*;
 import org.apache.cassandra.cql.CQLStatement;
 import org.apache.cassandra.cql.QueryProcessor;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.db.marshal.MarshalException;
-import org.apache.cassandra.db.migration.*;
 import org.apache.cassandra.db.context.CounterContext;
 import org.apache.cassandra.dht.*;
 import org.apache.cassandra.io.util.FastByteArrayOutputStream;
 import org.apache.cassandra.locator.*;
 import org.apache.cassandra.scheduler.IRequestScheduler;
 import org.apache.cassandra.service.ClientState;
+import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.service.SocketSessionManagementService;
 import org.apache.cassandra.service.StorageProxy;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.ByteBufferUtil;
-import org.apache.cassandra.utils.FBUtilities;
-import org.apache.cassandra.utils.WrappedRunnable;
 import org.apache.thrift.TException;
 
 public class CassandraServer implements Cassandra.Iface
@@ -911,22 +907,7 @@ public class CassandraServer implements Cassandra.Iface
         requestScheduler.release();
     }
 
-    // helper method to apply migration on the migration stage. typical migration failures will throw an
-    // InvalidRequestException. atypical failures will throw a RuntimeException.
-    private static void applyMigrationOnStage(final Migration m)
-    {
-        Future f = StageManager.getStage(Stage.MIGRATION).submit(new WrappedRunnable()
-        {
-            public void runMayThrow() throws Exception
-            {
-                m.apply();
-            }
-        });
-
-        FBUtilities.waitOnFuture(f);
-    }
-
-    public synchronized String system_add_column_family(CfDef cf_def)
+    public String system_add_column_family(CfDef cf_def)
     throws InvalidRequestException, SchemaDisagreementException, TException
     {
         logger.debug("add_column_family");
@@ -938,7 +919,7 @@ public class CassandraServer implements Cassandra.Iface
         try
         {
             cf_def.unsetId(); // explicitly ignore any id set by client (Hector likes to set zero)
-            applyMigrationOnStage(new AddColumnFamily(CFMetaData.fromThrift(cf_def)));
+            MigrationManager.announceNewColumnFamily(CFMetaData.fromThrift(cf_def));
             return Schema.instance.getVersion().toString();
         }
         catch (ConfigurationException e)
@@ -949,7 +930,7 @@ public class CassandraServer implements Cassandra.Iface
         }
     }
 
-    public synchronized String system_drop_column_family(String column_family)
+    public String system_drop_column_family(String column_family)
     throws InvalidRequestException, SchemaDisagreementException, TException
     {
         logger.debug("drop_column_family");
@@ -960,7 +941,7 @@ public class CassandraServer implements Cassandra.Iface
 
         try
         {
-            applyMigrationOnStage(new DropColumnFamily(cState.getKeyspace(), column_family));
+            MigrationManager.announceColumnFamilyDrop(cState.getKeyspace(), column_family);
             return Schema.instance.getVersion().toString();
         }
         catch (ConfigurationException e)
@@ -971,7 +952,7 @@ public class CassandraServer implements Cassandra.Iface
         }
     }
 
-    public synchronized String system_add_keyspace(KsDef ks_def)
+    public String system_add_keyspace(KsDef ks_def)
     throws InvalidRequestException, SchemaDisagreementException, TException
     {
         logger.debug("add_keyspace");
@@ -1001,7 +982,7 @@ public class CassandraServer implements Cassandra.Iface
             }
 
             ThriftValidation.validateKsDef(ks_def);
-            applyMigrationOnStage(new AddKeyspace(KSMetaData.fromThrift(ks_def, cfDefs.toArray(new CFMetaData[cfDefs.size()]))));
+            MigrationManager.announceNewKeyspace(KSMetaData.fromThrift(ks_def, cfDefs.toArray(new CFMetaData[cfDefs.size()])));
             return Schema.instance.getVersion().toString();
         }
         catch (ConfigurationException e)
@@ -1012,7 +993,7 @@ public class CassandraServer implements Cassandra.Iface
         }
     }
 
-    public synchronized String system_drop_keyspace(String keyspace)
+    public String system_drop_keyspace(String keyspace)
     throws InvalidRequestException, SchemaDisagreementException, TException
     {
         logger.debug("drop_keyspace");
@@ -1022,7 +1003,7 @@ public class CassandraServer implements Cassandra.Iface
 
         try
         {
-            applyMigrationOnStage(new DropKeyspace(keyspace));
+            MigrationManager.announceKeyspaceDrop(keyspace);
             return Schema.instance.getVersion().toString();
         }
         catch (ConfigurationException e)
@@ -1036,7 +1017,7 @@ public class CassandraServer implements Cassandra.Iface
     /** update an existing keyspace, but do not allow column family modifications.
      * @throws SchemaDisagreementException
      */
-    public synchronized String system_update_keyspace(KsDef ks_def)
+    public String system_update_keyspace(KsDef ks_def)
     throws InvalidRequestException, SchemaDisagreementException, TException
     {
         logger.debug("update_keyspace");
@@ -1050,7 +1031,7 @@ public class CassandraServer implements Cassandra.Iface
         try
         {
             ThriftValidation.validateKsDef(ks_def);
-            applyMigrationOnStage(new UpdateKeyspace(KSMetaData.fromThrift(ks_def)));
+            MigrationManager.announceKeyspaceUpdate(KSMetaData.fromThrift(ks_def));
             return Schema.instance.getVersion().toString();
         }
         catch (ConfigurationException e)
@@ -1061,7 +1042,7 @@ public class CassandraServer implements Cassandra.Iface
         }
     }
 
-    public synchronized String system_update_column_family(CfDef cf_def)
+    public String system_update_column_family(CfDef cf_def)
     throws InvalidRequestException, SchemaDisagreementException, TException
     {
         logger.debug("update_column_family");
@@ -1077,10 +1058,8 @@ public class CassandraServer implements Cassandra.Iface
 
         try
         {
-            // ideally, apply() would happen on the stage with the
             CFMetaData.applyImplicitDefaults(cf_def);
-            UpdateColumnFamily update = new UpdateColumnFamily(CFMetaData.fromThrift(cf_def));
-            applyMigrationOnStage(update);
+            MigrationManager.announceColumnFamilyUpdate(CFMetaData.fromThrift(cf_def));
             return Schema.instance.getVersion().toString();
         }
         catch (ConfigurationException e)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/src/java/org/apache/cassandra/thrift/ThriftValidation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/ThriftValidation.java b/src/java/org/apache/cassandra/thrift/ThriftValidation.java
index ff833df..eaaf61a 100644
--- a/src/java/org/apache/cassandra/thrift/ThriftValidation.java
+++ b/src/java/org/apache/cassandra/thrift/ThriftValidation.java
@@ -33,7 +33,6 @@ import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.db.marshal.AsciiType;
 import org.apache.cassandra.db.marshal.MarshalException;
 import org.apache.cassandra.db.marshal.TypeParser;
-import org.apache.cassandra.db.migration.Migration;
 import org.apache.cassandra.dht.IPartitioner;
 import org.apache.cassandra.dht.RandomPartitioner;
 import org.apache.cassandra.dht.Token;
@@ -587,6 +586,8 @@ public class ThriftValidation
         {
             if (cf_def.name.length() > 32)
                 throw new InvalidRequestException(String.format("Column family names shouldn't be more than 32 character long (got \"%s\")", cf_def.name));
+            if (!CFMetaData.isNameValid(cf_def.name))
+                throw new ConfigurationException(String.format("Invalid column family name. Should be only alphanumerical characters (got \"%s\")", cf_def.name));
             if (cf_def.key_alias != null)
             {
                 if (!cf_def.key_alias.hasRemaining())
@@ -664,7 +665,7 @@ public class ThriftValidation
                     if (cfType == ColumnFamilyType.Super)
                         throw new InvalidRequestException("Secondary indexes are not supported on supercolumns");
                     assert c.index_name != null; // should have a default set by now if none was provided
-                    if (!Migration.isLegalName(c.index_name))
+                    if (!CFMetaData.isNameValid(c.index_name))
                         throw new InvalidRequestException("Illegal index name " + c.index_name);
                     // check index names against this CF _and_ globally
                     if (indexNames.contains(c.index_name))
@@ -719,6 +720,8 @@ public class ThriftValidation
     {
         if (ks_def.name.length() > 32)
             throw new ConfigurationException(String.format("Keyspace names shouldn't be more than 32 character long (got \"%s\")", ks_def.name));
+        if (!CFMetaData.isNameValid(ks_def.name))
+            throw new ConfigurationException(String.format("Invalid keyspace name. Should be only alphanumerical characters (got \"%s\")", ks_def.name));
 
         // Attempt to instantiate the ARS, which will throw a ConfigException if
         //  the strategy_options aren't fully formed or if the ARS Classname is invalid.

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/long/org/apache/cassandra/db/LongTableTest.java
----------------------------------------------------------------------
diff --git a/test/long/org/apache/cassandra/db/LongTableTest.java b/test/long/org/apache/cassandra/db/LongTableTest.java
index 9d34394..47ea238 100644
--- a/test/long/org/apache/cassandra/db/LongTableTest.java
+++ b/test/long/org/apache/cassandra/db/LongTableTest.java
@@ -20,7 +20,7 @@ package org.apache.cassandra.db;
 
 import org.junit.Test;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.db.filter.QueryFilter;
 import org.apache.cassandra.utils.WrappedRunnable;
 import static org.apache.cassandra.Util.column;
@@ -30,7 +30,7 @@ import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 
-public class LongTableTest extends CleanupHelper
+public class LongTableTest extends SchemaLoader
 {
     @Test
     public void testGetRowMultiColumn() throws Throwable

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/long/org/apache/cassandra/db/MeteredFlusherTest.java
----------------------------------------------------------------------
diff --git a/test/long/org/apache/cassandra/db/MeteredFlusherTest.java b/test/long/org/apache/cassandra/db/MeteredFlusherTest.java
index bb29bf1..ba2d2fd 100644
--- a/test/long/org/apache/cassandra/db/MeteredFlusherTest.java
+++ b/test/long/org/apache/cassandra/db/MeteredFlusherTest.java
@@ -26,14 +26,14 @@ import java.nio.ByteBuffer;
 
 import org.junit.Test;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.ConfigurationException;
 import org.apache.cassandra.db.marshal.UTF8Type;
-import org.apache.cassandra.db.migration.AddColumnFamily;
+import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
-public class MeteredFlusherTest extends CleanupHelper
+public class MeteredFlusherTest extends SchemaLoader
 {
     @Test
     public void testManyMemtables() throws IOException, ConfigurationException
@@ -42,7 +42,7 @@ public class MeteredFlusherTest extends CleanupHelper
         for (int i = 0; i < 100; i++)
         {
             CFMetaData metadata = new CFMetaData(table.name, "_CF" + i, ColumnFamilyType.Standard, UTF8Type.instance, null);
-            new AddColumnFamily(metadata).apply();
+            MigrationManager.announceNewColumnFamily(metadata);
         }
 
         ByteBuffer name = ByteBufferUtil.bytes("c");

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/long/org/apache/cassandra/db/compaction/LongCompactionSpeedTest.java
----------------------------------------------------------------------
diff --git a/test/long/org/apache/cassandra/db/compaction/LongCompactionSpeedTest.java b/test/long/org/apache/cassandra/db/compaction/LongCompactionSpeedTest.java
index cc305ce..8338c2c 100644
--- a/test/long/org/apache/cassandra/db/compaction/LongCompactionSpeedTest.java
+++ b/test/long/org/apache/cassandra/db/compaction/LongCompactionSpeedTest.java
@@ -22,13 +22,13 @@ import java.util.*;
 
 import org.apache.cassandra.config.Schema;
 import org.junit.Test;
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.Util;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.io.sstable.SSTableReader;
 import org.apache.cassandra.io.sstable.SSTableUtils;
 
-public class LongCompactionSpeedTest extends CleanupHelper
+public class LongCompactionSpeedTest extends SchemaLoader
 {
     public static final String TABLE1 = "Keyspace1";
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/AbstractSerializationsTester.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/AbstractSerializationsTester.java b/test/unit/org/apache/cassandra/AbstractSerializationsTester.java
index e908ae7..4b64fc0 100644
--- a/test/unit/org/apache/cassandra/AbstractSerializationsTester.java
+++ b/test/unit/org/apache/cassandra/AbstractSerializationsTester.java
@@ -30,7 +30,7 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
-public class AbstractSerializationsTester extends CleanupHelper
+public class AbstractSerializationsTester extends SchemaLoader
 {
     protected static final String CUR_VER = System.getProperty("cassandra.version", "0.7");
     protected static final Map<String, Integer> VERSION_MAP = new HashMap<String, Integer> ()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/CleanupHelper.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/CleanupHelper.java b/test/unit/org/apache/cassandra/CleanupHelper.java
deleted file mode 100644
index 94645a4..0000000
--- a/test/unit/org/apache/cassandra/CleanupHelper.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License.  You may obtain a copy of the License at
-*
-*    http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied.  See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.cassandra;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import org.junit.BeforeClass;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.db.*;
-import org.apache.cassandra.db.commitlog.CommitLog;
-import org.apache.cassandra.db.filter.QueryPath;
-import org.apache.cassandra.io.util.FileUtils;
-import org.apache.cassandra.utils.ByteBufferUtil;
-
-public class CleanupHelper
-{
-    private static Logger logger = LoggerFactory.getLogger(CleanupHelper.class);
-
-    @BeforeClass
-    public static void cleanupLoadSchema() throws IOException
-    {
-        cleanupAndLeaveDirs();
-        SchemaLoader.loadSchema(); // also opens CommitLog, so make sure this is last
-    }
-
-    public static void cleanupAndLeaveDirs() throws IOException
-    {
-        mkdirs();
-        cleanup();
-        mkdirs();
-        CommitLog.instance.resetUnsafe(); // cleanup screws w/ CommitLog, this brings it back to safe state
-    }
-
-    public static void cleanup() throws IOException
-    {
-        // clean up commitlog
-        String[] directoryNames = { DatabaseDescriptor.getCommitLogLocation(), };
-        for (String dirName : directoryNames)
-        {
-            File dir = new File(dirName);
-            if (!dir.exists())
-                throw new RuntimeException("No such directory: " + dir.getAbsolutePath());
-            FileUtils.deleteRecursive(dir);
-        }
-
-        cleanupSavedCaches();
-
-        // clean up data directory which are stored as data directory/table/data files
-        for (String dirName : DatabaseDescriptor.getAllDataFileLocations())
-        {
-            File dir = new File(dirName);
-            if (!dir.exists())
-                throw new RuntimeException("No such directory: " + dir.getAbsolutePath());
-            FileUtils.deleteRecursive(dir);
-        }
-    }
-
-    public static void mkdirs()
-    {
-        try
-        {
-            DatabaseDescriptor.createAllDirectories();
-        }
-        catch (IOException e)
-        {
-            throw new RuntimeException(e);
-        }
-    }
-
-    protected void insertData(String keyspace, String columnFamily, int offset, int numberOfRows) throws IOException
-    {
-        for (int i = offset; i < offset + numberOfRows; i++)
-        {
-            ByteBuffer key = ByteBufferUtil.bytes("key" + i);
-            RowMutation rowMutation = new RowMutation(keyspace, key);
-            QueryPath path = new QueryPath(columnFamily, null, ByteBufferUtil.bytes("col" + i));
-
-            rowMutation.add(path, ByteBufferUtil.bytes("val" + i), System.currentTimeMillis());
-            rowMutation.applyUnsafe();
-        }
-    }
-
-    /* usually used to populate the cache */
-    protected void readData(String keyspace, String columnFamily, int offset, int numberOfRows) throws IOException
-    {
-        ColumnFamilyStore store = Table.open(keyspace).getColumnFamilyStore(columnFamily);
-        for (int i = offset; i < offset + numberOfRows; i++)
-        {
-            DecoratedKey key = Util.dk("key" + i);
-            QueryPath path = new QueryPath(columnFamily, null, ByteBufferUtil.bytes("col" + i));
-
-            store.getColumnFamily(key, path, ByteBufferUtil.EMPTY_BYTE_BUFFER, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, 1);
-        }
-    }
-
-    protected static void cleanupSavedCaches()
-    {
-        File cachesDir = new File(DatabaseDescriptor.getSavedCachesLocation());
-
-        if (!cachesDir.exists() || !cachesDir.isDirectory())
-            return;
-
-        FileUtils.delete(cachesDir.listFiles());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/EmbeddedServer.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/EmbeddedServer.java b/test/unit/org/apache/cassandra/EmbeddedServer.java
index 24b3afa..4406103 100644
--- a/test/unit/org/apache/cassandra/EmbeddedServer.java
+++ b/test/unit/org/apache/cassandra/EmbeddedServer.java
@@ -27,7 +27,7 @@ import org.apache.cassandra.service.CassandraDaemon;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
-public class EmbeddedServer extends CleanupHelper
+public class EmbeddedServer extends SchemaLoader
 {
     protected static CassandraDaemon daemon = null;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/SchemaLoader.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/SchemaLoader.java b/test/unit/org/apache/cassandra/SchemaLoader.java
index 5d8ca46..e1d86d4 100644
--- a/test/unit/org/apache/cassandra/SchemaLoader.java
+++ b/test/unit/org/apache/cassandra/SchemaLoader.java
@@ -18,22 +18,29 @@
 
 package org.apache.cassandra;
 
+import java.io.File;
+import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.*;
 
-import org.apache.cassandra.db.commitlog.CommitLog;
-import org.apache.cassandra.utils.ByteBufferUtil;
 
 import com.google.common.base.Charsets;
 import org.apache.cassandra.config.*;
-import org.apache.cassandra.db.ColumnFamilyType;
+import org.apache.cassandra.db.*;
+import org.apache.cassandra.db.commitlog.CommitLog;
+import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.db.marshal.*;
+import org.apache.cassandra.gms.Gossiper;
 import org.apache.cassandra.io.compress.CompressionParameters;
 import org.apache.cassandra.io.compress.SnappyCompressor;
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.locator.AbstractReplicationStrategy;
 import org.apache.cassandra.locator.SimpleStrategy;
+import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.thrift.IndexType;
+import org.apache.cassandra.utils.ByteBufferUtil;
 
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -43,8 +50,11 @@ public class SchemaLoader
     private static Logger logger = LoggerFactory.getLogger(SchemaLoader.class);
 
     @BeforeClass
-    public static void loadSchema()
+    public static void loadSchema() throws IOException
     {
+        // Cleanup first
+        cleanupAndLeaveDirs();
+
         CommitLog.instance.allocator.enableReserveSegmentCreation();
 
         Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
@@ -55,9 +65,13 @@ public class SchemaLoader
             }
         });
 
+
+        // Migrations aren't happy if gossiper is not started
+        startGossiper();
         try
         {
-            Schema.instance.load(schemaDefinition());
+            for (KSMetaData ksm : schemaDefinition())
+                MigrationManager.announceNewKeyspace(ksm);
         }
         catch (ConfigurationException e)
         {
@@ -65,6 +79,17 @@ public class SchemaLoader
         }
     }
 
+    public static void startGossiper()
+    {
+        Gossiper.instance.start((int) (System.currentTimeMillis() / 1000));
+    }
+
+    @AfterClass
+    public static void stopGossiper()
+    {
+        Gossiper.instance.stop();
+    }
+
     public static Collection<KSMetaData> schemaDefinition() throws ConfigurationException
     {
         List<KSMetaData> schema = new ArrayList<KSMetaData>();
@@ -289,4 +314,84 @@ public class SchemaLoader
     {
         return new CFMetaData(ksName, cfName, ColumnFamilyType.Standard, comp, null).defaultValidator(comp);
     }
+
+    public static void cleanupAndLeaveDirs() throws IOException
+    {
+        mkdirs();
+        cleanup();
+        mkdirs();
+        CommitLog.instance.resetUnsafe(); // cleanup screws w/ CommitLog, this brings it back to safe state
+    }
+
+    public static void cleanup() throws IOException
+    {
+        // clean up commitlog
+        String[] directoryNames = { DatabaseDescriptor.getCommitLogLocation(), };
+        for (String dirName : directoryNames)
+        {
+            File dir = new File(dirName);
+            if (!dir.exists())
+                throw new RuntimeException("No such directory: " + dir.getAbsolutePath());
+            FileUtils.deleteRecursive(dir);
+        }
+
+        cleanupSavedCaches();
+
+        // clean up data directory which are stored as data directory/table/data files
+        for (String dirName : DatabaseDescriptor.getAllDataFileLocations())
+        {
+            File dir = new File(dirName);
+            if (!dir.exists())
+                throw new RuntimeException("No such directory: " + dir.getAbsolutePath());
+            FileUtils.deleteRecursive(dir);
+        }
+    }
+
+    public static void mkdirs()
+    {
+        try
+        {
+            DatabaseDescriptor.createAllDirectories();
+        }
+        catch (IOException e)
+        {
+            throw new RuntimeException(e);
+        }
+    }
+
+    protected void insertData(String keyspace, String columnFamily, int offset, int numberOfRows) throws IOException
+    {
+        for (int i = offset; i < offset + numberOfRows; i++)
+        {
+            ByteBuffer key = ByteBufferUtil.bytes("key" + i);
+            RowMutation rowMutation = new RowMutation(keyspace, key);
+            QueryPath path = new QueryPath(columnFamily, null, ByteBufferUtil.bytes("col" + i));
+
+            rowMutation.add(path, ByteBufferUtil.bytes("val" + i), System.currentTimeMillis());
+            rowMutation.applyUnsafe();
+        }
+    }
+
+    /* usually used to populate the cache */
+    protected void readData(String keyspace, String columnFamily, int offset, int numberOfRows) throws IOException
+    {
+        ColumnFamilyStore store = Table.open(keyspace).getColumnFamilyStore(columnFamily);
+        for (int i = offset; i < offset + numberOfRows; i++)
+        {
+            DecoratedKey key = Util.dk("key" + i);
+            QueryPath path = new QueryPath(columnFamily, null, ByteBufferUtil.bytes("col" + i));
+
+            store.getColumnFamily(key, path, ByteBufferUtil.EMPTY_BYTE_BUFFER, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, 1);
+        }
+    }
+
+    protected static void cleanupSavedCaches()
+    {
+        File cachesDir = new File(DatabaseDescriptor.getSavedCachesLocation());
+
+        if (!cachesDir.exists() || !cachesDir.isDirectory())
+            return;
+
+        FileUtils.delete(cachesDir.listFiles());
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/cli/CliTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cli/CliTest.java b/test/unit/org/apache/cassandra/cli/CliTest.java
index 4490cf5..44ceab8 100644
--- a/test/unit/org/apache/cassandra/cli/CliTest.java
+++ b/test/unit/org/apache/cassandra/cli/CliTest.java
@@ -18,8 +18,9 @@
 
 package org.apache.cassandra.cli;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.service.EmbeddedCassandraService;
 import org.apache.cassandra.thrift.*;
 import org.apache.thrift.TException;
@@ -33,7 +34,7 @@ import java.util.regex.Pattern;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-public class CliTest extends CleanupHelper
+public class CliTest extends SchemaLoader
 {
     // please add new statements here so they could be auto-runned by this test.
     private String[] statements = {
@@ -208,6 +209,7 @@ public class CliTest extends CleanupHelper
     @Test
     public void testCli() throws IOException, TException, ConfigurationException, ClassNotFoundException, TimedOutException, NotFoundException, SchemaDisagreementException, NoSuchFieldException, InvalidRequestException, UnavailableException, InstantiationException, IllegalAccessException
     {
+        Schema.instance.clear(); // Schema are now written on disk and will be reloaded
         new EmbeddedCassandraService().start();
 
         // new error/output streams for CliSessionState

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/config/CFMetaDataTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/config/CFMetaDataTest.java b/test/unit/org/apache/cassandra/config/CFMetaDataTest.java
index be9c0e1..99be709 100644
--- a/test/unit/org/apache/cassandra/config/CFMetaDataTest.java
+++ b/test/unit/org/apache/cassandra/config/CFMetaDataTest.java
@@ -22,7 +22,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.HashMap;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.cql3.QueryProcessor;
 import org.apache.cassandra.cql3.UntypedResultSet;
@@ -49,7 +49,7 @@ import static org.junit.Assert.assertEquals;
 import java.util.Map;
 import java.nio.ByteBuffer;
 
-public class CFMetaDataTest extends CleanupHelper
+public class CFMetaDataTest extends SchemaLoader
 {
     private static String KEYSPACE = "Keyspace1";
     private static String COLUMN_FAMILY = "Standard1";

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java b/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
index b79e8a3..99fc58d 100644
--- a/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
+++ b/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
@@ -18,10 +18,10 @@
 */
 package org.apache.cassandra.config;
 
-import org.apache.cassandra.CleanupHelper;
-import org.apache.cassandra.db.migration.AddKeyspace;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.gms.Gossiper;
 import org.apache.cassandra.locator.SimpleStrategy;
+import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.thrift.InvalidRequestException;
 
 import org.junit.Test;
@@ -62,7 +62,7 @@ public class DatabaseDescriptorTest
     @Test
     public void testTransKsMigration() throws IOException, ConfigurationException
     {
-        CleanupHelper.cleanupAndLeaveDirs();
+        SchemaLoader.cleanupAndLeaveDirs();
         DatabaseDescriptor.loadSchemas();
         assert Schema.instance.getNonSystemTables().size() == 0;
 
@@ -71,10 +71,8 @@ public class DatabaseDescriptorTest
         try
         {
             // add a few.
-            AddKeyspace ks0 = new AddKeyspace(KSMetaData.testMetadata("ks0", SimpleStrategy.class, KSMetaData.optsWithRF(3)));
-            ks0.apply();
-            AddKeyspace ks1 = new AddKeyspace(KSMetaData.testMetadata("ks1", SimpleStrategy.class, KSMetaData.optsWithRF(3)));
-            ks1.apply();
+            MigrationManager.announceNewKeyspace(KSMetaData.testMetadata("ks0", SimpleStrategy.class, KSMetaData.optsWithRF(3)));
+            MigrationManager.announceNewKeyspace(KSMetaData.testMetadata("ks1", SimpleStrategy.class, KSMetaData.optsWithRF(3)));
 
             assert Schema.instance.getTableDefinition("ks0") != null;
             assert Schema.instance.getTableDefinition("ks1") != null;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/config/DefsTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/config/DefsTest.java b/test/unit/org/apache/cassandra/config/DefsTest.java
index 87e75cb..862483f 100644
--- a/test/unit/org/apache/cassandra/config/DefsTest.java
+++ b/test/unit/org/apache/cassandra/config/DefsTest.java
@@ -24,7 +24,7 @@ import java.nio.ByteBuffer;
 import java.util.*;
 import java.util.concurrent.ExecutionException;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.Util;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.filter.QueryFilter;
@@ -32,41 +32,21 @@ import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.db.marshal.BytesType;
 import org.apache.cassandra.db.marshal.UTF8Type;
 import org.apache.cassandra.db.marshal.TimeUUIDType;
-import org.apache.cassandra.db.migration.AddColumnFamily;
-import org.apache.cassandra.db.migration.AddKeyspace;
-import org.apache.cassandra.db.migration.DropColumnFamily;
-import org.apache.cassandra.db.migration.DropKeyspace;
-import org.apache.cassandra.db.migration.Migration;
-import org.apache.cassandra.db.migration.UpdateColumnFamily;
-import org.apache.cassandra.db.migration.UpdateKeyspace;
-import org.apache.cassandra.gms.Gossiper;
 import org.apache.cassandra.io.sstable.Component;
 import org.apache.cassandra.io.sstable.Descriptor;
 import org.apache.cassandra.io.sstable.SSTableDeletingTask;
 import org.apache.cassandra.locator.OldNetworkTopologyStrategy;
 import org.apache.cassandra.locator.SimpleStrategy;
+import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.thrift.CfDef;
 import org.apache.cassandra.thrift.ColumnDef;
 import org.apache.cassandra.thrift.IndexType;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
 import org.junit.Test;
 
-public class DefsTest extends CleanupHelper
+public class DefsTest extends SchemaLoader
 {
-    @BeforeClass
-    public static void startGossiper()
-    {
-        Gossiper.instance.start((int) (System.currentTimeMillis() / 1000));
-    }
-
-    @AfterClass
-    public static void stopGossiper()
-    {
-        Gossiper.instance.stop();
-    }
 
     @Test
     public void ensureStaticCFMIdsAreLessThan1000()
@@ -135,11 +115,11 @@ public class DefsTest extends CleanupHelper
     {
         String[] valid = {"1", "a", "_1", "b_", "__", "1_a"};
         for (String s : valid)
-            assert Migration.isLegalName(s);
+            assert CFMetaData.isNameValid(s);
 
         String[] invalid = {"b@t", "dash-y", "", " ", "dot.s", ".hidden"};
         for (String s : invalid)
-            assert !Migration.isLegalName(s);
+            assert !CFMetaData.isNameValid(s);
     }
 
     @Test
@@ -167,16 +147,12 @@ public class DefsTest extends CleanupHelper
         CFMetaData newCf = addTestCF("MadeUpKeyspace", "NewCF", "new cf");
         try
         {
-            new AddColumnFamily(newCf).apply();
+            MigrationManager.announceNewColumnFamily(newCf);
             throw new AssertionError("You shouldn't be able to do anything to a keyspace that doesn't exist.");
         }
         catch (ConfigurationException expected)
         {
         }
-        catch (IOException unexpected)
-        {
-            throw new AssertionError("Unexpected exception.");
-        }
     }
 
     @Test
@@ -189,7 +165,7 @@ public class DefsTest extends CleanupHelper
         CFMetaData newCf = addTestCF(original.name, cf, null);
 
         assert !Schema.instance.getTableDefinition(ks).cfMetaData().containsKey(newCf.cfName);
-        new AddColumnFamily(newCf).apply();
+        MigrationManager.announceNewColumnFamily(newCf);
 
         assert Schema.instance.getTableDefinition(ks).cfMetaData().containsKey(newCf.cfName);
         assert Schema.instance.getTableDefinition(ks).cfMetaData().get(newCf.cfName).equals(newCf);
@@ -205,7 +181,7 @@ public class DefsTest extends CleanupHelper
         CFMetaData newCf = addTestCF(original.name, cf, "A New Column Family");
 
         assert !Schema.instance.getTableDefinition(ks).cfMetaData().containsKey(newCf.cfName);
-        new AddColumnFamily(newCf).apply();
+        MigrationManager.announceNewColumnFamily(newCf);
 
         assert Schema.instance.getTableDefinition(ks).cfMetaData().containsKey(newCf.cfName);
         assert Schema.instance.getTableDefinition(ks).cfMetaData().get(newCf.cfName).equals(newCf);
@@ -246,7 +222,7 @@ public class DefsTest extends CleanupHelper
         store.getFlushPath(1024, Descriptor.CURRENT_VERSION);
         assert store.directories.sstableLister().list().size() > 0;
 
-        new DropColumnFamily(ks.name, cfm.cfName).apply();
+        MigrationManager.announceColumnFamilyDrop(ks.name, cfm.cfName);
 
         assert !Schema.instance.getTableDefinition(ks.name).cfMetaData().containsKey(cfm.cfName);
 
@@ -280,10 +256,10 @@ public class DefsTest extends CleanupHelper
 
         KSMetaData newKs = KSMetaData.testMetadata(newCf.ksName, SimpleStrategy.class, KSMetaData.optsWithRF(5), newCf);
 
-        new AddKeyspace(newKs).apply();
+        MigrationManager.announceNewKeyspace(newKs);
 
         assert Schema.instance.getTableDefinition(newCf.ksName) != null;
-        assert Schema.instance.getTableDefinition(newCf.ksName) == newKs;
+        assert Schema.instance.getTableDefinition(newCf.ksName).equals(newKs);
 
         // test reads and writes.
         RowMutation rm = new RowMutation(newCf.ksName, dk.key);
@@ -319,7 +295,7 @@ public class DefsTest extends CleanupHelper
         store.forceBlockingFlush();
         assert store.directories.sstableLister().list().size() > 0;
 
-        new DropKeyspace(ks.name).apply();
+        MigrationManager.announceKeyspaceDrop(ks.name);
 
         assert Schema.instance.getTableDefinition(ks.name) == null;
 
@@ -366,7 +342,7 @@ public class DefsTest extends CleanupHelper
             rm.add(new QueryPath(cfm.cfName, null, ByteBufferUtil.bytes(("col" + i))), ByteBufferUtil.bytes("anyvalue"), 1L);
         rm.apply();
 
-        new DropKeyspace(ks.name).apply();
+        MigrationManager.announceKeyspaceDrop(ks.name);
 
         assert Schema.instance.getTableDefinition(ks.name) == null;
     }
@@ -378,7 +354,7 @@ public class DefsTest extends CleanupHelper
 
         KSMetaData newKs = KSMetaData.testMetadata("EmptyKeyspace", SimpleStrategy.class, KSMetaData.optsWithRF(5));
 
-        new AddKeyspace(newKs).apply();
+        MigrationManager.announceNewKeyspace(newKs);
         assert Schema.instance.getTableDefinition("EmptyKeyspace") != null;
 
         CFMetaData newCf = addTestCF("EmptyKeyspace", "AddedLater", "A new CF to add to an empty KS");
@@ -387,7 +363,7 @@ public class DefsTest extends CleanupHelper
         assert !Schema.instance.getTableDefinition(newKs.name).cfMetaData().containsKey(newCf.cfName);
 
         //add the new CF to the empty space
-        new AddColumnFamily(newCf).apply();
+        MigrationManager.announceNewColumnFamily(newCf);
 
         assert Schema.instance.getTableDefinition(newKs.name).cfMetaData().containsKey(newCf.cfName);
         assert Schema.instance.getTableDefinition(newKs.name).cfMetaData().get(newCf.cfName).equals(newCf);
@@ -414,29 +390,16 @@ public class DefsTest extends CleanupHelper
         CFMetaData cf = addTestCF("UpdatedKeyspace", "AddedStandard1", "A new cf for a new ks");
         KSMetaData oldKs = KSMetaData.testMetadata(cf.ksName, SimpleStrategy.class, KSMetaData.optsWithRF(5), cf);
 
-        new AddKeyspace(oldKs).apply();
+        MigrationManager.announceNewKeyspace(oldKs);
 
         assert Schema.instance.getTableDefinition(cf.ksName) != null;
-        assert Schema.instance.getTableDefinition(cf.ksName) == oldKs;
-
-        // anything with cf defs should fail.
-        CFMetaData cf2 = addTestCF(cf.ksName, "AddedStandard2", "A new cf for a new ks");
-        KSMetaData newBadKs = KSMetaData.testMetadata(cf.ksName, SimpleStrategy.class, KSMetaData.optsWithRF(4), cf2);
-        try
-        {
-            new UpdateKeyspace(newBadKs).apply();
-            throw new AssertionError("Should not have been able to update a KS with a KS that described column families.");
-        }
-        catch (ConfigurationException ex)
-        {
-            // expected.
-        }
+        assert Schema.instance.getTableDefinition(cf.ksName).equals(oldKs);
 
         // names should match.
         KSMetaData newBadKs2 = KSMetaData.testMetadata(cf.ksName + "trash", SimpleStrategy.class, KSMetaData.optsWithRF(4));
         try
         {
-            new UpdateKeyspace(newBadKs2).apply();
+            MigrationManager.announceKeyspaceUpdate(newBadKs2);
             throw new AssertionError("Should not have been able to update a KS with an invalid KS name.");
         }
         catch (ConfigurationException ex)
@@ -445,7 +408,7 @@ public class DefsTest extends CleanupHelper
         }
 
         KSMetaData newKs = KSMetaData.testMetadata(cf.ksName, OldNetworkTopologyStrategy.class, KSMetaData.optsWithRF(1));
-        new UpdateKeyspace(newKs).apply();
+        MigrationManager.announceKeyspaceUpdate(newKs);
 
         KSMetaData newFetchedKs = Schema.instance.getKSMetaData(newKs.name);
         assert newFetchedKs.strategyClass.equals(newKs.strategyClass);
@@ -458,10 +421,10 @@ public class DefsTest extends CleanupHelper
         // create a keyspace with a cf to update.
         CFMetaData cf = addTestCF("UpdatedCfKs", "Standard1added", "A new cf that will be updated");
         KSMetaData ksm = KSMetaData.testMetadata(cf.ksName, SimpleStrategy.class, KSMetaData.optsWithRF(1), cf);
-        new AddKeyspace(ksm).apply();
+        MigrationManager.announceNewKeyspace(ksm);
 
         assert Schema.instance.getTableDefinition(cf.ksName) != null;
-        assert Schema.instance.getTableDefinition(cf.ksName) == ksm;
+        assert Schema.instance.getTableDefinition(cf.ksName).equals(ksm);
         assert Schema.instance.getCFMetaData(cf.ksName, cf.cfName) != null;
 
         // updating certain fields should fail.
@@ -473,22 +436,22 @@ public class DefsTest extends CleanupHelper
 
         // test valid operations.
         newCfm.comment("Modified comment");
-        new UpdateColumnFamily(newCfm).apply(); // doesn't get set back here.
+        MigrationManager.announceColumnFamilyUpdate(newCfm); // doesn't get set back here.
 
         newCfm.readRepairChance(0.23);
-        new UpdateColumnFamily(newCfm).apply();
+        MigrationManager.announceColumnFamilyUpdate(newCfm);
 
         newCfm.gcGraceSeconds(12);
-        new UpdateColumnFamily(newCfm).apply();
+        MigrationManager.announceColumnFamilyUpdate(newCfm);
 
         newCfm.defaultValidator(UTF8Type.instance);
-        new UpdateColumnFamily(newCfm).apply();
+        MigrationManager.announceColumnFamilyUpdate(newCfm);
 
         newCfm.minCompactionThreshold(3);
-        new UpdateColumnFamily(newCfm).apply();
+        MigrationManager.announceColumnFamilyUpdate(newCfm);
 
         newCfm.maxCompactionThreshold(33);
-        new UpdateColumnFamily(newCfm).apply();
+        MigrationManager.announceColumnFamilyUpdate(newCfm);
 
         // can't test changing the reconciler because there is only one impl.
 
@@ -570,8 +533,7 @@ public class DefsTest extends CleanupHelper
         ColumnDefinition cdOld = meta.getColumn_metadata().values().iterator().next();
         ColumnDefinition cdNew = new ColumnDefinition(cdOld.name, cdOld.getValidator(), null, null, null);
         meta.columnMetadata(Collections.singletonMap(cdOld.name, cdNew));
-        UpdateColumnFamily update = new UpdateColumnFamily(meta);
-        update.apply();
+        MigrationManager.announceColumnFamilyUpdate(meta);
 
         // check
         assert cfs.indexManager.getIndexedColumns().isEmpty();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/CleanupTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/CleanupTest.java b/test/unit/org/apache/cassandra/db/CleanupTest.java
index c9a48ea..94e28c9 100644
--- a/test/unit/org/apache/cassandra/db/CleanupTest.java
+++ b/test/unit/org/apache/cassandra/db/CleanupTest.java
@@ -27,7 +27,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.Util;
 import org.apache.cassandra.config.ConfigurationException;
 import org.apache.cassandra.db.columniterator.IdentityQueryFilter;
@@ -47,7 +47,7 @@ import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.NodeId;
 import org.junit.Test;
 
-public class CleanupTest extends CleanupHelper
+public class CleanupTest extends SchemaLoader
 {
     public static final int LOOPS = 200;
     public static final String TABLE1 = "Keyspace1";

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
index e312c40..a0ee315 100644
--- a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
+++ b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
@@ -26,7 +26,7 @@ import java.util.*;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.Util;
 import org.apache.cassandra.config.ColumnDefinition;
 import org.apache.cassandra.config.ConfigurationException;
@@ -56,7 +56,7 @@ import static org.junit.Assert.assertNull;
 
 import org.junit.Test;
 
-public class ColumnFamilyStoreTest extends CleanupHelper
+public class ColumnFamilyStoreTest extends SchemaLoader
 {
     static byte[] bytes1, bytes2;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/CommitLogTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/CommitLogTest.java b/test/unit/org/apache/cassandra/db/CommitLogTest.java
index 4d7a344..e4b04a4 100644
--- a/test/unit/org/apache/cassandra/db/CommitLogTest.java
+++ b/test/unit/org/apache/cassandra/db/CommitLogTest.java
@@ -26,13 +26,13 @@ import java.util.zip.Checksum;
 
 import org.junit.Test;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.db.commitlog.CommitLog;
 import org.apache.cassandra.db.filter.QueryPath;
 
 import static org.apache.cassandra.utils.ByteBufferUtil.bytes;
 
-public class CommitLogTest extends CleanupHelper
+public class CommitLogTest extends SchemaLoader
 {
     @Test
     public void testRecoveryWithEmptyLog() throws Exception

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/CounterMutationTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/CounterMutationTest.java b/test/unit/org/apache/cassandra/db/CounterMutationTest.java
index 5558a9b..12b5559 100644
--- a/test/unit/org/apache/cassandra/db/CounterMutationTest.java
+++ b/test/unit/org/apache/cassandra/db/CounterMutationTest.java
@@ -27,14 +27,14 @@ import static org.junit.Assert.fail;
 
 import org.apache.cassandra.db.context.CounterContext;
 import org.apache.cassandra.db.filter.*;
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.thrift.*;
 import org.apache.cassandra.utils.*;
 import org.apache.cassandra.Util;
 import static org.apache.cassandra.db.context.CounterContext.ContextState;
 import static org.apache.cassandra.utils.ByteBufferUtil.bytes;
 
-public class CounterMutationTest extends CleanupHelper
+public class CounterMutationTest extends SchemaLoader
 {
     @Test
     public void testMergeOldShards() throws IOException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/KeyCacheTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/KeyCacheTest.java b/test/unit/org/apache/cassandra/db/KeyCacheTest.java
index a47e2ea..c674604 100644
--- a/test/unit/org/apache/cassandra/db/KeyCacheTest.java
+++ b/test/unit/org/apache/cassandra/db/KeyCacheTest.java
@@ -33,14 +33,14 @@ import org.apache.cassandra.thrift.ColumnParent;
 import org.junit.AfterClass;
 import org.junit.Test;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.Util;
 import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.db.compaction.CompactionManager;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import static junit.framework.Assert.assertEquals;
 
-public class KeyCacheTest extends CleanupHelper
+public class KeyCacheTest extends SchemaLoader
 {
     private static final String TABLE1 = "KeyCacheSpace";
     private static final String COLUMN_FAMILY1 = "Standard1";

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/KeyCollisionTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/KeyCollisionTest.java b/test/unit/org/apache/cassandra/db/KeyCollisionTest.java
index 9c5aadf..8ef2271 100644
--- a/test/unit/org/apache/cassandra/db/KeyCollisionTest.java
+++ b/test/unit/org/apache/cassandra/db/KeyCollisionTest.java
@@ -25,7 +25,7 @@ import java.util.*;
 
 import org.junit.Test;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.db.columniterator.IdentityQueryFilter;
 import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.dht.*;
@@ -42,7 +42,7 @@ import static org.apache.cassandra.Util.dk;
  * length partitioner that takes the length of the key as token, making
  * collision easy and predictable.
  */
-public class KeyCollisionTest extends CleanupHelper
+public class KeyCollisionTest extends SchemaLoader
 {
     IPartitioner oldPartitioner;
     private static final String KEYSPACE = "Keyspace1";

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/MultitableTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/MultitableTest.java b/test/unit/org/apache/cassandra/db/MultitableTest.java
index 5636dc3..1b22ce3 100644
--- a/test/unit/org/apache/cassandra/db/MultitableTest.java
+++ b/test/unit/org/apache/cassandra/db/MultitableTest.java
@@ -28,10 +28,10 @@ import org.apache.cassandra.Util;
 import org.junit.Test;
 
 import static org.apache.cassandra.db.TableTest.assertColumns;
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import static org.apache.cassandra.Util.column;
 
-public class MultitableTest extends CleanupHelper
+public class MultitableTest extends SchemaLoader
 {
     @Test
     public void testSameCFs() throws IOException, ExecutionException, InterruptedException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/NameSortTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/NameSortTest.java b/test/unit/org/apache/cassandra/db/NameSortTest.java
index 6f2110a..668a2e2 100644
--- a/test/unit/org/apache/cassandra/db/NameSortTest.java
+++ b/test/unit/org/apache/cassandra/db/NameSortTest.java
@@ -25,14 +25,14 @@ import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.concurrent.ExecutionException;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.Util;
 import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 import org.junit.Test;
 
-public class NameSortTest extends CleanupHelper
+public class NameSortTest extends SchemaLoader
 {
     @Test
     public void testNameSort1() throws IOException, ExecutionException, InterruptedException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java b/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java
index af9f7ec..c77dec3 100644
--- a/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java
+++ b/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java
@@ -28,12 +28,12 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static org.apache.cassandra.Util.column;
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.db.compaction.CompactionManager;
 import org.apache.cassandra.db.commitlog.CommitLog;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
-public class RecoveryManager2Test extends CleanupHelper
+public class RecoveryManager2Test extends SchemaLoader
 {
     private static Logger logger = LoggerFactory.getLogger(RecoveryManager2Test.class);
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/RecoveryManager3Test.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RecoveryManager3Test.java b/test/unit/org/apache/cassandra/db/RecoveryManager3Test.java
index 13e041d..f45b5da 100644
--- a/test/unit/org/apache/cassandra/db/RecoveryManager3Test.java
+++ b/test/unit/org/apache/cassandra/db/RecoveryManager3Test.java
@@ -27,7 +27,7 @@ import java.util.concurrent.ExecutionException;
 
 import org.junit.Test;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.Util;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.db.commitlog.CommitLog;
@@ -36,7 +36,7 @@ import org.apache.cassandra.io.util.FileUtils;
 import static org.apache.cassandra.Util.column;
 import static org.apache.cassandra.db.TableTest.assertColumns;
 
-public class RecoveryManager3Test extends CleanupHelper
+public class RecoveryManager3Test extends SchemaLoader
 {
     @Test
     public void testMissingHeader() throws IOException, ExecutionException, InterruptedException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/RecoveryManagerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RecoveryManagerTest.java b/test/unit/org/apache/cassandra/db/RecoveryManagerTest.java
index 4a43eca..68c0b37 100644
--- a/test/unit/org/apache/cassandra/db/RecoveryManagerTest.java
+++ b/test/unit/org/apache/cassandra/db/RecoveryManagerTest.java
@@ -24,14 +24,14 @@ import java.util.concurrent.ExecutionException;
 import org.apache.cassandra.Util;
 import org.junit.Test;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.db.commitlog.CommitLog;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 import static org.apache.cassandra.Util.column;
 import static org.apache.cassandra.db.TableTest.assertColumns;
 
-public class RecoveryManagerTest extends CleanupHelper
+public class RecoveryManagerTest extends SchemaLoader
 {
     @Test
     public void testNothingToRecover() throws IOException {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/RecoveryManagerTruncateTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RecoveryManagerTruncateTest.java b/test/unit/org/apache/cassandra/db/RecoveryManagerTruncateTest.java
index 9161eba..843bbef 100644
--- a/test/unit/org/apache/cassandra/db/RecoveryManagerTruncateTest.java
+++ b/test/unit/org/apache/cassandra/db/RecoveryManagerTruncateTest.java
@@ -25,7 +25,7 @@ import static org.junit.Assert.assertNull;
 import java.io.IOException;
 import java.util.concurrent.ExecutionException;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.Util;
 import org.apache.cassandra.db.commitlog.CommitLog;
 import org.apache.cassandra.db.filter.QueryFilter;
@@ -36,7 +36,7 @@ import org.apache.cassandra.utils.ByteBufferUtil;
 /**
  * Test for the truncate operation.
  */
-public class RecoveryManagerTruncateTest extends CleanupHelper
+public class RecoveryManagerTruncateTest extends SchemaLoader
 {
 	@Test
 	public void testTruncate() throws IOException, ExecutionException, InterruptedException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/RemoveColumnFamilyTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RemoveColumnFamilyTest.java b/test/unit/org/apache/cassandra/db/RemoveColumnFamilyTest.java
index 3c086b0..15369d6 100644
--- a/test/unit/org/apache/cassandra/db/RemoveColumnFamilyTest.java
+++ b/test/unit/org/apache/cassandra/db/RemoveColumnFamilyTest.java
@@ -27,12 +27,12 @@ import static junit.framework.Assert.assertNull;
 import org.apache.cassandra.db.filter.QueryFilter;
 import org.apache.cassandra.db.filter.QueryPath;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.Util;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 
-public class RemoveColumnFamilyTest extends CleanupHelper
+public class RemoveColumnFamilyTest extends SchemaLoader
 {
     @Test
     public void testRemoveColumnFamily() throws IOException, ExecutionException, InterruptedException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush1Test.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush1Test.java b/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush1Test.java
index d13b5e6..f724cb5 100644
--- a/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush1Test.java
+++ b/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush1Test.java
@@ -27,12 +27,12 @@ import static junit.framework.Assert.assertNull;
 import org.apache.cassandra.db.filter.QueryFilter;
 import org.apache.cassandra.db.filter.QueryPath;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.Util;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 
-public class RemoveColumnFamilyWithFlush1Test extends CleanupHelper
+public class RemoveColumnFamilyWithFlush1Test extends SchemaLoader
 {
     @Test
     public void testRemoveColumnFamilyWithFlush1() throws IOException, ExecutionException, InterruptedException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush2Test.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush2Test.java b/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush2Test.java
index 3f6261d..49585dc 100644
--- a/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush2Test.java
+++ b/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush2Test.java
@@ -27,12 +27,12 @@ import static junit.framework.Assert.assertNull;
 import org.apache.cassandra.db.filter.QueryFilter;
 import org.apache.cassandra.db.filter.QueryPath;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.Util;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 
-public class RemoveColumnFamilyWithFlush2Test extends CleanupHelper
+public class RemoveColumnFamilyWithFlush2Test extends SchemaLoader
 {
     @Test
     public void testRemoveColumnFamilyWithFlush2() throws IOException, ExecutionException, InterruptedException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/RemoveColumnTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RemoveColumnTest.java b/test/unit/org/apache/cassandra/db/RemoveColumnTest.java
index cfd8e9c..67afba9 100644
--- a/test/unit/org/apache/cassandra/db/RemoveColumnTest.java
+++ b/test/unit/org/apache/cassandra/db/RemoveColumnTest.java
@@ -28,12 +28,12 @@ import static junit.framework.Assert.assertNull;
 import org.apache.cassandra.db.filter.QueryFilter;
 import org.apache.cassandra.db.filter.QueryPath;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.Util;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 
-public class RemoveColumnTest extends CleanupHelper
+public class RemoveColumnTest extends SchemaLoader
 {
     @Test
     public void testRemoveColumn() throws IOException, ExecutionException, InterruptedException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/RemoveSubColumnTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RemoveSubColumnTest.java b/test/unit/org/apache/cassandra/db/RemoveSubColumnTest.java
index 499653c..70cbaa2 100644
--- a/test/unit/org/apache/cassandra/db/RemoveSubColumnTest.java
+++ b/test/unit/org/apache/cassandra/db/RemoveSubColumnTest.java
@@ -28,11 +28,11 @@ import org.apache.cassandra.db.filter.QueryFilter;
 import org.apache.cassandra.db.filter.QueryPath;
 import static org.apache.cassandra.Util.getBytes;
 import org.apache.cassandra.Util;
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 
-public class RemoveSubColumnTest extends CleanupHelper
+public class RemoveSubColumnTest extends SchemaLoader
 {
     @Test
     public void testRemoveSubColumn() throws IOException, ExecutionException, InterruptedException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java b/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java
index a908783..b15b8c6 100644
--- a/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java
+++ b/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java
@@ -33,12 +33,12 @@ import org.apache.cassandra.db.filter.QueryPath;
 import static org.apache.cassandra.Util.addMutation;
 import static org.apache.cassandra.Util.getBytes;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import static junit.framework.Assert.assertNotNull;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 
-public class RemoveSuperColumnTest extends CleanupHelper
+public class RemoveSuperColumnTest extends SchemaLoader
 {
     @Test
     public void testRemoveSuperColumn() throws IOException, ExecutionException, InterruptedException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/RowCacheTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RowCacheTest.java b/test/unit/org/apache/cassandra/db/RowCacheTest.java
index da5cf63..e6b4578 100644
--- a/test/unit/org/apache/cassandra/db/RowCacheTest.java
+++ b/test/unit/org/apache/cassandra/db/RowCacheTest.java
@@ -23,14 +23,14 @@ import java.util.Collection;
 import org.junit.AfterClass;
 import org.junit.Test;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.Util;
 import org.apache.cassandra.db.compaction.CompactionManager;
 import org.apache.cassandra.service.CacheService;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.db.filter.QueryPath;
 
-public class RowCacheTest extends CleanupHelper
+public class RowCacheTest extends SchemaLoader
 {
     private String KEYSPACE = "RowCacheSpace";
     private String COLUMN_FAMILY = "CachedCF";

http://git-wip-us.apache.org/repos/asf/cassandra/blob/438acfc8/test/unit/org/apache/cassandra/db/RowIterationTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RowIterationTest.java b/test/unit/org/apache/cassandra/db/RowIterationTest.java
index 1e3aece..99e54ff 100644
--- a/test/unit/org/apache/cassandra/db/RowIterationTest.java
+++ b/test/unit/org/apache/cassandra/db/RowIterationTest.java
@@ -29,14 +29,14 @@ import org.apache.cassandra.Util;
 
 import org.junit.Test;
 
-import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.utils.FBUtilities;
 import static junit.framework.Assert.assertEquals;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 
-public class RowIterationTest extends CleanupHelper
+public class RowIterationTest extends SchemaLoader
 {
     public static final String TABLE1 = "Keyspace2";
     public static final InetAddress LOCAL = FBUtilities.getBroadcastAddress();