cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdusba...@apache.org
Subject svn commit: r921962 - in /incubator/cassandra/trunk: src/java/org/apache/cassandra/config/ src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/db/commitlog/ src/java/org/apache/cassandra/io/util/ test/unit/org/apache/cassandra/db/
Date Thu, 11 Mar 2010 17:53:23 GMT
Author: gdusbabek
Date: Thu Mar 11 17:53:22 2010
New Revision: 921962

URL: http://svn.apache.org/viewvc?rev=921962&view=rev
Log:
rename a cf on a single node. Patch by Gary Dusbabek, reviewed by Jonthan Ellis. CASSANDRA-840

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/config/KSMetaData.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/FileUtils.java
    incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/DefsTest.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java?rev=921962&r1=921961&r2=921962&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java Thu Mar
11 17:53:22 2010
@@ -18,7 +18,8 @@
 
 package org.apache.cassandra.config;
 
-import com.google.common.collect.HashMultimap;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.ListMultimap;
 import com.google.common.collect.Multimap;
 import com.google.common.collect.Multimaps;
 import org.apache.cassandra.db.marshal.AbstractType;
@@ -44,6 +45,8 @@ public final class CFMetaData
 
     private static final AtomicInteger idGen = new AtomicInteger(0);
     
+    private static final Map<Integer, String> currentCfNames = new HashMap<Integer,
String>();
+    
     private static final Map<Pair<String, String>, Integer> cfIdMap = new HashMap<Pair<String,
String>, Integer>();
     
     public static final Map<Pair<String, String>, Integer> getCfIdMap()
@@ -51,6 +54,11 @@ public final class CFMetaData
         return Collections.unmodifiableMap(cfIdMap);    
     }
     
+    public static final String getCurrentName(int id)
+    {
+        return currentCfNames.get(id);
+    }
+    
     // this gets called after initialization to make sure that id generation happens properly.
     public static final void fixMaxId()
     {
@@ -79,12 +87,20 @@ public final class CFMetaData
         this.rowCacheSize = rowCacheSize;
         this.keyCacheSize = keyCacheSize;
         this.cfId = cfId;
+        currentCfNames.put(cfId, cfName);
+        cfIdMap.put(new Pair<String, String>(tableName, cfName), cfId);
     }
     
     public CFMetaData(String tableName, String cfName, String columnType, AbstractType comparator,
AbstractType subcolumnComparator, String comment, double rowCacheSize, double keyCacheSize)
     {
         this(tableName, cfName, columnType, comparator, subcolumnComparator, comment, rowCacheSize,
keyCacheSize, nextId());
-        cfIdMap.put(new Pair<String, String>(tableName, cfName), cfId);
+    }
+    
+    /** clones an existing CFMetaData using the same id. */
+    public static CFMetaData rename(CFMetaData cfm, String newName)
+    {
+        purge(cfm);
+        return new CFMetaData(cfm.tableName, newName, cfm.columnType, cfm.comparator, cfm.subcolumnComparator,
cfm.comment, cfm.rowCacheSize, cfm.keyCacheSize, cfm.cfId);
     }
     
     /** used for evicting cf data out of static tracking collections. */
@@ -125,7 +141,6 @@ public final class CFMetaData
 
     public static CFMetaData deserialize(InputStream in) throws IOException
     {
-
         DataInputStream din = new DataInputStream(in);
         String tableName = din.readUTF();
         String cfName = din.readUTF();

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/config/KSMetaData.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/config/KSMetaData.java?rev=921962&r1=921961&r2=921962&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/config/KSMetaData.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/config/KSMetaData.java Thu Mar
11 17:53:22 2010
@@ -86,7 +86,7 @@ public final class KSMetaData
     {
         return cfMetaData;
     }
-    
+        
     public static byte[] serialize(KSMetaData ksm) throws IOException
     {
         ByteArrayOutputStream bout = new ByteArrayOutputStream();

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java?rev=921962&r1=921961&r2=921962&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java Thu Mar 11
17:53:22 2010
@@ -88,6 +88,12 @@ public class ColumnFamily implements ICo
         columnSerializer_ = columnType.equals("Standard") ? Column.serializer() : SuperColumn.serializer(subcolumnComparator);
         columns_ = new ConcurrentSkipListMap<byte[], IColumn>(comparator);
     }
+    
+    /** called during CL recovery when it is determined that a CF name was changed. */
+    public void rename(String newName)
+    {
+        name_ = newName;
+    }
 
     public ColumnFamily cloneMeShallow()
     {

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java?rev=921962&r1=921961&r2=921962&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java Thu Mar 11 17:53:22
2010
@@ -22,18 +22,21 @@ import org.apache.cassandra.config.CFMet
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.config.KSMetaData;
 import org.apache.cassandra.db.commitlog.CommitLog;
-import org.apache.cassandra.db.filter.NamesQueryFilter;
 import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.db.filter.SliceQueryFilter;
 import org.apache.cassandra.utils.FBUtilities;
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.utils.UUIDGen;
 
 import static org.apache.cassandra.config.DatabaseDescriptor.ConfigurationException;
 
 import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileFilter;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
@@ -70,7 +73,8 @@ public class DefsTable
 
             // reinitialize the table.
             DatabaseDescriptor.setTableDefinition(ksm, newVersion);
-            Table.reinitialize(ksm.name);
+            Table.close(ksm.name);
+            Table.open(ksm.name);
             
             // force creation of a new commit log segment.
             CommitLog.instance().forceNewSegment();
@@ -110,7 +114,8 @@ public class DefsTable
             // reinitialize the table.
             CFMetaData.purge(cfm);
             DatabaseDescriptor.setTableDefinition(ksm, newVersion);
-            Table.reinitialize(ksm.name);
+            Table.close(ksm.name);
+            Table.open(ksm.name);
             
             // indicate that some files need to be deleted (eventually)
             SystemTable.markForRemoval(cfm);
@@ -140,6 +145,61 @@ public class DefsTable
             }
         }
     }
+    
+    public static synchronized void rename(CFMetaData oldCfm, String newName) throws IOException,
ConfigurationException
+    {
+        Table.openLock.lock();
+        try
+        {
+            KSMetaData ksm = DatabaseDescriptor.getTableDefinition(oldCfm.tableName);
+            if (ksm == null)
+                throw new ConfigurationException("Keyspace does not already exist.");
+            if (!ksm.cfMetaData().containsKey(oldCfm.cfName))
+                throw new ConfigurationException("CF is not defined in that keyspace.");
+            if (ksm.cfMetaData().containsKey(newName))
+                throw new ConfigurationException("CF is already defined in that keyspace.");
+            
+            // clone the ksm, replacing cfm with the new one.
+            List<CFMetaData> newCfs = new ArrayList<CFMetaData>(ksm.cfMetaData().values());
+            newCfs.remove(oldCfm);
+            assert newCfs.size() == ksm.cfMetaData().size() - 1;
+            CFMetaData newCfm = CFMetaData.rename(oldCfm, newName);
+            newCfs.add(newCfm);
+            ksm = new KSMetaData(ksm.name, ksm.strategyClass, ksm.replicationFactor, ksm.snitch,
newCfs.toArray(new CFMetaData[newCfs.size()]));
+            
+            // store it
+            UUID newVersion = UUIDGen.makeType1UUIDFromHost(FBUtilities.getLocalAddress());
+            RowMutation rm = new RowMutation(Table.DEFINITIONS, newVersion.toString());
+            rm.add(new QueryPath(SCHEMA_CF, null, ksm.name.getBytes()), KSMetaData.serialize(ksm),
System.currentTimeMillis());
+            rm.apply();
+            
+            // reset defs.
+            DatabaseDescriptor.setTableDefinition(ksm, newVersion);
+            Table.close(ksm.name);
+            
+            // rename the files.
+            try
+            {
+                renameStorageFiles(ksm.name, oldCfm.cfName, newCfm.cfName);
+            }
+            catch (IOException e)
+            {
+                // todo: is this a big enough problem to bring the entire node down?  For
sure, it is something that needs to be addressed immediately.
+                ConfigurationException cex = new ConfigurationException("Critical: encountered
IOException while attempting to rename CF storage files for " + oldCfm.cfName);
+                cex.initCause(e);
+                throw cex;
+            }
+            
+            
+            Table.open(ksm.name);
+            
+            CommitLog.instance().forceNewSegment();
+        }
+        finally
+        {
+            Table.openLock.unlock();
+        }
+    }
 
     public static synchronized void dumpToStorage(UUID version) throws IOException
     {
@@ -169,4 +229,46 @@ public class DefsTable
         }
         return tables;
     }
+    
+    static Collection<File> getFiles(String table, final String cf)
+    {
+        List<File> found = new ArrayList<File>();
+        for (String path : DatabaseDescriptor.getAllDataFileLocationsForTable(table))
+        {
+            File[] dbFiles = new File(path).listFiles(new FileFilter()
+            {
+                public boolean accept(File pathname)
+                {
+                    return pathname.getName().startsWith(cf + "-") && pathname.getName().endsWith(".db")
&& pathname.exists();
+                            
+                }
+            });
+            for (File f : dbFiles)
+                found.add(f);
+        }
+        return found;
+    }
+    
+    // if this errors out, we are in a world of hurt.
+    private static void renameStorageFiles(String table, String oldCfName, String newCfName)
throws IOException
+    {
+        // complete as much of the job as possible.  Don't let errors long the way prevent
as much renaming as possible
+        // from happening.
+        IOException mostRecentProblem = null;
+        for (File existing : getFiles(table, oldCfName))
+        {
+            try
+            {
+                String newFileName = existing.getName().replaceFirst("\\w+-", newCfName +
"-");
+                FileUtils.renameWithConfirm(existing, new File(existing.getParent(), newFileName));
+            }
+            catch (IOException ex)
+            {
+                mostRecentProblem = ex;
+            }
+        }
+        if (mostRecentProblem != null)
+            throw new IOException("One or more IOExceptions encountered while renaming files.
Most recent problem is included.", mostRecentProblem);
+        
+    }
 }

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java?rev=921962&r1=921961&r2=921962&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java Thu Mar 11
17:53:22 2010
@@ -127,9 +127,9 @@ public class RowMutation
     }
 
     /** should only be called by commitlog replay code */
-    public void removeColumnFamily(ColumnFamily columnFamily)
+    public void removeColumnFamily(String cfName)
     {
-        modifications_.remove(columnFamily.name());
+        modifications_.remove(cfName);
     }
     
     public boolean isEmpty()

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java?rev=921962&r1=921961&r2=921962&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java Thu Mar 11 17:53:22
2010
@@ -21,6 +21,7 @@ package org.apache.cassandra.db;
 import java.util.*;
 import java.io.IOException;
 import java.io.File;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -85,23 +86,7 @@ public class Table 
 
     // this lock blocks other threads from opening a table during critical operations.
     public static final Lock openLock = new ReentrantLock();
-
-    public static void reinitialize(String table) throws IOException
-    {
-        // todo: should I acquire the flusherLock too to prevent writes during the switch?
-        // or should there be a per/keyspace table modification lock?
-        openLock.lock();
-        try
-        {
-            instances.remove(table);
-            open(table);
-        }
-        finally
-        {
-            openLock.unlock();
-        }
-    }
-
+    
     public static Table open(String table) throws IOException
     {
         Table tableInstance = instances.get(table);
@@ -126,7 +111,16 @@ public class Table 
         }
         return tableInstance;
     }
-        
+    
+    // prepares a table to be replaced
+    public static void close(String table) throws IOException
+    {
+        // yes, I see the irony.
+        Table t = open(table);
+        if (t != null)
+            open(table).release();
+    }
+    
     public Set<String> getColumnFamilies()
     {
         return DatabaseDescriptor.getTableDefinition(name).cfMetaData().keySet();
@@ -280,6 +274,40 @@ public class Table 
             }
         }, checkMs, checkMs);
     }
+    
+    // undoes the constructor.
+    private void release() throws IOException
+    {
+        openLock.lock();
+        try
+        {
+            instances.remove(name);
+            for (String cfName : getColumnFamilies())
+            {
+                // clear out memtables.
+                ColumnFamilyStore cfs = columnFamilyStores.remove(cfName);
+                if (cfs != null)
+                {
+                    try
+                    {
+                        cfs.forceBlockingFlush();
+                    }
+                    catch (ExecutionException e)
+                    {
+                        throw new IOException(e);
+                    }
+                    catch (InterruptedException e)
+                    {
+                        throw new IOException(e);
+                    }
+                }
+            }
+        }
+        finally 
+        {
+            openLock.unlock();
+        }
+    }
 
     /**
      * Selects the specified column family for the specified key.

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLog.java?rev=921962&r1=921961&r2=921962&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLog.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLog.java Thu
Mar 11 17:53:22 2010
@@ -239,21 +239,28 @@ public class CommitLog
                     public void runMayThrow() throws IOException
                     {
                         KSMetaData ksm = DatabaseDescriptor.getTableDefinition(table.name);
+                        RowMutation newRm = new RowMutation(rm.getTable(), rm.key());
                         
-                        /* remove a) column families that have already been flushed before
applying the rest, and
-                        *  b) column families that have been dropped. */
+                        // Rebuild the row mutation, omitting column families that a) have
already been flushed,
+                        // b) are part of a cf that was dropped. Keep in mind that a cf might
have been renamed. (this
+                        // is why the old RM is not used in the actual transaction.
                         for (ColumnFamily columnFamily : columnFamilies)
                         {
                             Pair<String, String> key = new Pair<String, String>(table.name,
columnFamily.name()); 
                             int id = cfIdMap.get(key);
-                            if (!clHeader.isDirty(id) || entryLocation < clHeader.getPosition(id))
-                            {
-                                rm.removeColumnFamily(columnFamily);
-                            }
+                            // make sure to use the current name of the cf (null means its
been dropped).
+                            String currentName = CFMetaData.getCurrentName(id);
+                            if (currentName == null)
+                                continue;
+                            else if (!currentName.equals(columnFamily.name()))
+                                columnFamily.rename(currentName);
+                            
+                            if (clHeader.isDirty(id) && entryLocation >= clHeader.getPosition(id))
+                                newRm.add(columnFamily);
                         }
-                        if (!rm.isEmpty())
+                        if (!newRm.isEmpty())
                         {
-                            Table.open(rm.getTable()).apply(rm, null, false);
+                            Table.open(newRm.getTable()).apply(newRm, null, false);
                         }
                     }
                 };

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/FileUtils.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/FileUtils.java?rev=921962&r1=921961&r2=921962&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/FileUtils.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/FileUtils.java Thu Mar
11 17:53:22 2010
@@ -47,6 +47,15 @@ public class FileUtils
             throw new IOException("Failed to delete " + file.getAbsolutePath());
         }
     }
+    
+    public static void renameWithConfirm(File from, File to) throws IOException
+    {
+        assert from.exists();
+        if (logger_.isDebugEnabled())
+            logger_.debug((String.format("Renaming %s to %s", from.getPath(), to.getPath())));
+        if (!from.renameTo(to))
+            throw new IOException(String.format("Failed to rename %s to %s", from.getPath(),
to.getPath()));
+    }
 
     public static class FileComparator implements Comparator<File>
     {

Modified: incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/DefsTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/DefsTest.java?rev=921962&r1=921961&r2=921962&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/DefsTest.java (original)
+++ incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/DefsTest.java Thu Mar 11 17:53:22
2010
@@ -26,19 +26,16 @@ import org.apache.cassandra.config.KSMet
 import org.apache.cassandra.db.commitlog.CommitLog;
 import org.apache.cassandra.db.filter.NamesQueryFilter;
 import org.apache.cassandra.db.filter.QueryPath;
-import org.apache.cassandra.db.marshal.TimeUUIDType;
+import org.apache.cassandra.db.filter.SliceQueryFilter;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.db.marshal.UTF8Type;
 import org.apache.cassandra.utils.UUIDGen;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.io.File;
-import java.io.FileFilter;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.List;
 import java.util.UUID;
 import java.util.concurrent.ExecutionException;
@@ -92,6 +89,7 @@ public class DefsTest extends CleanupHel
         ColumnFamilyStore store = Table.open(ks).getColumnFamilyStore(cf);
         assert store != null;
         store.forceBlockingFlush();
+        
         ColumnFamily cfam = store.getColumnFamily(new NamesQueryFilter("key0", new QueryPath(cf),
"col0".getBytes()));
         assert cfam.getColumn("col0".getBytes()) != null;
         IColumn col = cfam.getColumn("col0".getBytes());
@@ -116,7 +114,7 @@ public class DefsTest extends CleanupHel
         assert store != null;
         store.forceBlockingFlush();
         store.getFlushPath();
-        assert getFiles(cfm.tableName, cfm.cfName).size() > 0;
+        assert DefsTable.getFiles(cfm.tableName, cfm.cfName).size() > 0;
         
         DefsTable.drop(cfm, true);
         
@@ -136,25 +134,51 @@ public class DefsTest extends CleanupHel
         }
         
         // verify that the files are gone.
-        assert getFiles(cfm.tableName, cfm.cfName).size() == 0;
-    }
+        assert DefsTable.getFiles(cfm.tableName, cfm.cfName).size() == 0;
+    }    
     
-    private static Collection<File> getFiles(String table, final String cf)
+    @Test
+    public void renameCf() throws IOException, ConfigurationException, ExecutionException,
InterruptedException
     {
-        List<File> found = new ArrayList<File>();
-        for (String path : DatabaseDescriptor.getAllDataFileLocationsForTable(table))
-        {
-            File[] dbFiles = new File(path).listFiles(new FileFilter()
-            {
-                public boolean accept(File pathname)
-                {
-                    return pathname.getName().startsWith(cf + "-") && pathname.getName().endsWith(".db")
&& pathname.exists();
-                            
-                }
-            });
-            for (File f : dbFiles)
-                found.add(f);
-        }
-        return found;
+        final KSMetaData ks = DatabaseDescriptor.getTableDefinition("Keyspace2");
+        assert ks != null;
+        final CFMetaData oldCfm = ks.cfMetaData().get("Standard1");
+        assert oldCfm != null;
+        
+        // write some data, force a flush, then verify that files exist on disk.
+        RowMutation rm = new RowMutation(ks.name, "key0");
+        for (int i = 0; i < 100; i++)
+            rm.add(new QueryPath(oldCfm.cfName, null, ("col" + i).getBytes()), "anyvalue".getBytes(),
1L);
+        rm.apply();
+        ColumnFamilyStore store = Table.open(oldCfm.tableName).getColumnFamilyStore(oldCfm.cfName);
+        assert store != null;
+        store.forceBlockingFlush();
+        int fileCount = DefsTable.getFiles(oldCfm.tableName, oldCfm.cfName).size();
+        assert fileCount > 0;
+        
+        final String newCfmName = "St4ndard1Replacement";
+        DefsTable.rename(oldCfm, newCfmName);
+        
+        assert !DatabaseDescriptor.getTableDefinition(ks.name).cfMetaData().containsKey(oldCfm.cfName);
+        assert DatabaseDescriptor.getTableDefinition(ks.name).cfMetaData().containsKey(newCfmName);
+        
+        // verify that new files are there.
+        assert DefsTable.getFiles(oldCfm.tableName, newCfmName).size() == fileCount;
+        
+        // do some reads.
+        store = Table.open(oldCfm.tableName).getColumnFamilyStore(newCfmName);
+        assert store != null;
+        ColumnFamily cfam = store.getColumnFamily(new SliceQueryFilter("key0", new QueryPath(newCfmName),
"".getBytes(), "".getBytes(), false, 1000));
+        assert cfam.getSortedColumns().size() == 100; // should be good enough?
+        
+        // do some writes
+        rm = new RowMutation(ks.name, "key0");
+        rm.add(new QueryPath(newCfmName, null, "col5".getBytes()), "updated".getBytes(),
2L);
+        rm.apply();
+        store.forceBlockingFlush();
+        
+        cfam = store.getColumnFamily(new NamesQueryFilter("key0", new QueryPath(newCfmName),
"col5".getBytes()));
+        assert cfam.getColumnCount() == 1;
+        assert Arrays.equals(cfam.getColumn("col5".getBytes()).value(), "updated".getBytes());
     }
 }



Mime
View raw message