cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1198830 - in /cassandra/branches/cassandra-1.0: ./ src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/db/index/ src/java/org/apache/cassandra/db/index/keys/ test/unit/org/apache/cassandra/db/ test/unit/org/apache/cassandra/db/...
Date Mon, 07 Nov 2011 17:34:05 GMT
Author: jbellis
Date: Mon Nov  7 17:34:04 2011
New Revision: 1198830

URL: http://svn.apache.org/viewvc?rev=1198830&view=rev
Log:
fix invalidate-related test failures
patch by jbellis; reviewed by slebresne for CASSANDRA-3437

Modified:
    cassandra/branches/cassandra-1.0/CHANGES.txt
    cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/Table.java
    cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
    cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
    cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java
    cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/db/KeyCacheTest.java
    cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java
    cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java

Modified: cassandra/branches/cassandra-1.0/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/CHANGES.txt?rev=1198830&r1=1198829&r2=1198830&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/CHANGES.txt (original)
+++ cassandra/branches/cassandra-1.0/CHANGES.txt Mon Nov  7 17:34:04 2011
@@ -1,5 +1,6 @@
 1.0.3
  * (Hadoop) Fix empty row filtering (CASSANDRA-3450)
+ * fix invalidate-related test failures (CASSANDRA-3437)
 Merged from 0.8:
  * Make counter shard merging thread safe (CASSANDRA-3178)
 

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=1198830&r1=1198829&r2=1198830&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
(original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
Mon Nov  7 17:34:04 2011
@@ -28,8 +28,7 @@ import java.util.concurrent.atomic.Atomi
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 import java.util.regex.Pattern;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
+import javax.management.*;
 
 import com.google.common.collect.Iterables;
 import org.apache.cassandra.db.compaction.LeveledManifest;
@@ -54,6 +53,7 @@ import org.apache.cassandra.db.index.Sec
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.dht.*;
 import org.apache.cassandra.io.sstable.*;
+import org.apache.cassandra.io.sstable.Descriptor;
 import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.thrift.IndexClause;
@@ -257,18 +257,15 @@ public class ColumnFamilyStore implement
         }
     }
 
-    // called when dropping or renaming a CF. Performs mbean housekeeping and invalidates
CFS to other operations.
-    public void unregisterMBean()
+    /** call when dropping or renaming a CF. Performs mbean housekeeping and invalidates
CFS to other operations */
+    public void invalidate()
     {
         try
         {
             valid = false;
-            MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-            ObjectName nameObj = new ObjectName(mbeanName);
-            if (mbs.isRegistered(nameObj))
-                mbs.unregisterMBean(nameObj);
-           
-            indexManager.unregisterMBeans();
+            unregisterMBean();
+            data.removeAllSSTables();
+            indexManager.invalidate();
         }
         catch (Exception e)
         {
@@ -277,6 +274,14 @@ public class ColumnFamilyStore implement
         }
     }
 
+    void unregisterMBean() throws MalformedObjectNameException, InstanceNotFoundException,
MBeanRegistrationException
+    {
+        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+        ObjectName nameObj = new ObjectName(mbeanName);
+        if (mbs.isRegistered(nameObj))
+            mbs.unregisterMBean(nameObj);
+    }
+
     public long getMinRowSize()
     {
         return data.getMinRowSize();
@@ -987,12 +992,6 @@ public class ColumnFamilyStore implement
         return valid;
     }
 
-    public void removeAllSSTables() throws IOException
-    {
-        data.removeAllSSTables();
-        indexManager.removeAllIndexes();
-    }
-
     public long getMemtableColumnsCount()
     {
         return getMemtableThreadSafe().getOperations();

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/Table.java?rev=1198830&r1=1198829&r2=1198830&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/Table.java (original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/Table.java Mon Nov 
7 17:34:04 2011
@@ -29,7 +29,6 @@ import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
@@ -41,7 +40,6 @@ import org.apache.cassandra.config.*;
 import org.apache.cassandra.db.commitlog.CommitLog;
 import org.apache.cassandra.db.filter.QueryFilter;
 import org.apache.cassandra.db.filter.QueryPath;
-import org.apache.cassandra.db.index.SecondaryIndex;
 import org.apache.cassandra.io.sstable.SSTableDeletingTask;
 import org.apache.cassandra.io.sstable.SSTableReader;
 import org.apache.cassandra.io.util.FileUtils;
@@ -343,7 +341,6 @@ public class Table
             return;
         
         unloadCf(cfs);
-        cfs.removeAllSSTables();
     }
     
     // disassociate a cfs from this table instance.
@@ -361,7 +358,7 @@ public class Table
         {
             throw new IOException(e);
         }
-        cfs.unregisterMBean();
+        cfs.invalidate();
     }
     
     /** adds a cf to internal structures, ends up creating disk files). */

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/SecondaryIndex.java?rev=1198830&r1=1198829&r2=1198830&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
(original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
Mon Nov  7 17:34:04 2011
@@ -132,9 +132,9 @@ public abstract class SecondaryIndex
     public abstract void renameIndex(String newCfName) throws IOException;
     
     /**
-     * Unregisters this index's mbean if one exists
+     * Remove the index and unregisters this index's mbean if one exists
      */
-    public abstract void unregisterMbean();
+    public abstract void invalidate();
     
     
     /**

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java?rev=1198830&r1=1198829&r2=1198830&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
(original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
Mon Nov  7 17:34:04 2011
@@ -239,24 +239,14 @@ public class SecondaryIndexManager
     }
 
     /**
-     * Remove all index MBeans
+     * Remove the index
      */
-    public void unregisterMBeans()
+    public void invalidate()
     {
         for (Map.Entry<ByteBuffer, SecondaryIndex> entry : indexesByColumn.entrySet())
-            entry.getValue().unregisterMbean();
+            entry.getValue().invalidate();
     }
-    
-    /**
-     * Remove all underlying index data
-     * @throws IOException 
-     */
-    public void removeAllIndexes() throws IOException
-    {
-        for (Map.Entry<ByteBuffer, SecondaryIndex> entry : indexesByColumn.entrySet())
-            entry.getValue().removeIndex(entry.getKey());
-    }
-    
+        
     /**
      * Rename all underlying index files
      * @param newCfName the new index Name

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java?rev=1198830&r1=1198829&r2=1198830&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java
(original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java
Mon Nov  7 17:34:04 2011
@@ -109,8 +109,7 @@ public class KeysIndex extends PerColumn
 
     public void removeIndex(ByteBuffer columnName) throws IOException
     {        
-        indexCfs.removeAllSSTables();
-        indexCfs.unregisterMBean();
+        indexCfs.invalidate();
     }
 
     public void forceBlockingFlush() throws IOException
@@ -129,9 +128,9 @@ public class KeysIndex extends PerColumn
         }
     }
 
-    public void unregisterMbean()
+    public void invalidate()
     {
-        indexCfs.unregisterMBean();
+        indexCfs.invalidate();
     }
 
     public ColumnFamilyStore getIndexCfs()

Modified: cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/db/KeyCacheTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/db/KeyCacheTest.java?rev=1198830&r1=1198829&r2=1198830&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/db/KeyCacheTest.java (original)
+++ cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/db/KeyCacheTest.java Mon
Nov  7 17:34:04 2011
@@ -90,12 +90,13 @@ public class KeyCacheTest extends Cleanu
         store.invalidateKeyCache();
         assert store.getKeyCacheSize() == 0;
 
-        // load the cache from disk
+        // load the cache from disk.  unregister the old mbean so we can recreate a new CFS
object.
+        // but don't invalidate() the old CFS, which would nuke the data we want to try to
load
         store.unregisterMBean(); // unregistering old MBean to test how key cache will be
loaded
         ColumnFamilyStore newStore = ColumnFamilyStore.createColumnFamilyStore(Table.open(TABLE1),
COLUMN_FAMILY3);
-        assert newStore.getKeyCacheSize() == 100;
+        assertEquals(100, newStore.getKeyCacheSize());
 
-        assert savedMap.size() == 100;
+        assertEquals(100, savedMap.size());
         for (Map.Entry<Pair<Descriptor, DecoratedKey>, Long> entry : savedMap.entrySet())
         {
             assert newStore.getKeyCache().get(entry.getKey()).equals(entry.getValue());

Modified: cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java?rev=1198830&r1=1198829&r2=1198830&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java
(original)
+++ cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java
Mon Nov  7 17:34:04 2011
@@ -39,7 +39,6 @@ import org.apache.cassandra.db.filter.Qu
 import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.io.sstable.*;
 import org.apache.cassandra.utils.ByteBufferUtil;
-import org.apache.cassandra.utils.FBUtilities;
 
 public class CompactionsTest extends CleanupHelper
 {
@@ -231,7 +230,7 @@ public class CompactionsTest extends Cle
         ColumnFamilyStore store = table.getColumnFamilyStore(cfname);
 
         // disable compaction while flushing
-        store.removeAllSSTables();
+        store.clearUnsafe();
         store.disableAutoCompaction();
 
         // Add test row

Modified: cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java?rev=1198830&r1=1198829&r2=1198830&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
(original)
+++ cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
Mon Nov  7 17:34:04 2011
@@ -28,7 +28,6 @@ import java.net.InetAddress;
 import java.util.*;
 
 import org.apache.cassandra.CleanupHelper;
-import org.apache.cassandra.Util;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.columniterator.IdentityQueryFilter;
 import org.apache.cassandra.db.context.CounterContext;
@@ -80,9 +79,7 @@ public class StreamingTransferTest exten
         Util.compactAll(cfs).get();
         assertEquals(1, cfs.getSSTables().size());
         SSTableReader sstable = cfs.getSSTables().iterator().next();
-        // We acquire a reference now, because removeAllSSTables will mark the sstable compacted,
and we have work to do with it
-        sstable.acquireReference();
-        cfs.removeAllSSTables();
+        cfs.clearUnsafe();
 
         // transfer the first and last key
         logger.debug("Transferring " + cfs.columnFamily);



Mime
View raw message