cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject svn commit: r1170184 - in /cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra: db/CollationController.java io/sstable/SSTableReader.java streaming/StreamInSession.java
Date Tue, 13 Sep 2011 13:58:41 GMT
Author: slebresne
Date: Tue Sep 13 13:58:41 2011
New Revision: 1170184

URL: http://svn.apache.org/viewvc?rev=1170184&view=rev
Log:
minor cleanups related to reference counting

Modified:
    cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/db/CollationController.java
    cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
    cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/streaming/StreamInSession.java

Modified: cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/db/CollationController.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/db/CollationController.java?rev=1170184&r1=1170183&r2=1170184&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/db/CollationController.java
(original)
+++ cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/db/CollationController.java
Tue Sep 13 13:58:41 2011
@@ -151,9 +151,9 @@ public class CollationController
         }
         finally
         {
-            SSTableReader.releaseReferences(view.sstables);
             for (IColumnIterator iter : iterators)
                 FileUtils.closeQuietly(iter);
+            SSTableReader.releaseReferences(view.sstables);
         }
     }
 
@@ -223,9 +223,9 @@ public class CollationController
         }
         finally
         {
-            SSTableReader.releaseReferences(view.sstables);
             for (IColumnIterator iter : iterators)
                 FileUtils.closeQuietly(iter);
+            SSTableReader.releaseReferences(view.sstables);
         }
     }
 

Modified: cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/io/sstable/SSTableReader.java?rev=1170184&r1=1170183&r2=1170184&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
(original)
+++ cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
Tue Sep 13 13:58:41 2011
@@ -647,14 +647,8 @@ public class SSTableReader extends SSTab
 
     /**
      * Mark the sstable as compacted.
-     * When calling this function, the caller must ensure two things:
-     *  - He must have acquired a reference with acquireReference()
-     *  - He must ensure that the SSTableReader is not referenced anywhere except for threads
holding a reference.
-     *
-     * The reason we ask caller to acquire a reference is because this greatly simplify the
logic here.
-     * If that wasn't the case, markCompacted would have to deal with both the case where
some thread still
-     * have references and the case where no thread have any reference. Making this logic
thread-safe is a
-     * bit hard, so we make sure that at least the caller thread has a reference and delegate
the rest to releaseRefence()
+     * When calling this function, the caller must ensure that the SSTableReader is not referenced
anywhere
+     * except for threads holding a reference.
      */
     public void markCompacted()
     {

Modified: cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/streaming/StreamInSession.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/streaming/StreamInSession.java?rev=1170184&r1=1170183&r2=1170184&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/streaming/StreamInSession.java
(original)
+++ cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/streaming/StreamInSession.java
Tue Sep 13 13:58:41 2011
@@ -134,7 +134,9 @@ public class StreamInSession
                     assert sstable.getTableName().equals(table);
 
                     // Acquiring the reference (for secondary index building) before adding
it makes sure we don't have to care about races
-                    sstable.acquireReference();
+                    if (!sstable.acquireReference())
+                        throw new RuntimeException("We shouldn't fail acquiring a reference
on a sstable that has just been transfered");
+
                     referenced.add(sstable);
 
                     ColumnFamilyStore cfs = Table.open(sstable.getTableName()).getColumnFamilyStore(sstable.getColumnFamilyName());



Mime
View raw message