cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject svn commit: r1189831 - in /cassandra/branches/cassandra-1.0: CHANGES.txt src/java/org/apache/cassandra/db/ColumnFamilyStore.java src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
Date Thu, 27 Oct 2011 16:20:59 GMT
Author: slebresne
Date: Thu Oct 27 16:20:58 2011
New Revision: 1189831

URL: http://svn.apache.org/viewvc?rev=1189831&view=rev
Log:
Make reloading the compaction strategy safe
patch by slebresne; reviewed by jbellis for CASSANDRA-3409

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/compaction/AbstractCompactionStrategy.java

Modified: cassandra/branches/cassandra-1.0/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/CHANGES.txt?rev=1189831&r1=1189830&r2=1189831&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/CHANGES.txt (original)
+++ cassandra/branches/cassandra-1.0/CHANGES.txt Thu Oct 27 16:20:58 2011
@@ -27,6 +27,7 @@
  * Break bloom filters up to avoid heap fragmentation (CASSANDRA-2466)
  * fix cassandra hanging on jsvc stop (CASSANDRA-3302)
  * Avoid leveled compaction getting blocked on errors (CASSANDRA-3408)
+ * Make reloading the compaction strategy safe (CASSANDRA-3409)
 Merged from 0.8:
  * (CQL) update grammar to require key clause in DELETE statement
    (CASSANDRA-3349)

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=1189831&r1=1189830&r2=1189831&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
Thu Oct 27 16:20:58 2011
@@ -178,8 +178,7 @@ public class ColumnFamilyStore implement
         if (!rowCacheKeysToSave.isModified())
             rowCacheKeysToSave = new DefaultInteger(metadata.getRowCacheKeysToSave());
 
-        compactionStrategy.shutdown();
-        compactionStrategy = metadata.createCompactionStrategyInstance(this);
+        maybeReloadCompactionStrategy();
 
         updateCacheSizes();
         scheduleCacheSaving(rowCacheSaveInSeconds.value(), keyCacheSaveInSeconds.value(),
rowCacheKeysToSave.value());
@@ -187,6 +186,24 @@ public class ColumnFamilyStore implement
         indexManager.reload();
     }
 
+    private void maybeReloadCompactionStrategy()
+    {
+        // Check if there is a need for reloading
+        if (metadata.compactionStrategyClass.equals(compactionStrategy.getClass()) &&
metadata.compactionStrategyOptions.equals(compactionStrategy.getOptions()))
+            return;
+
+        CompactionManager.instance.getCompactionLock().lock();
+        try
+        {
+            compactionStrategy.shutdown();
+            compactionStrategy = metadata.createCompactionStrategyInstance(this);
+        }
+        finally
+        {
+            CompactionManager.instance.getCompactionLock().unlock();
+        }
+    }
+
     private ColumnFamilyStore(Table table, String columnFamilyName, IPartitioner partitioner,
int generation, CFMetaData metadata)
     {
         assert metadata != null : "null metadata for " + table + ":" + columnFamilyName;

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java?rev=1189831&r1=1189830&r2=1189831&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
(original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
Thu Oct 27 16:20:58 2011
@@ -63,6 +63,11 @@ public abstract class AbstractCompaction
         StorageService.optionalTasks.schedule(runnable, 5 * 60, TimeUnit.SECONDS);
     }
 
+    public Map<String, String> getOptions()
+    {
+        return options;
+    }
+
     /**
      * Releases any resources if this strategy is shutdown (when the CFS is reloaded after
a schema change).
      * Default is to do nothing.



Mime
View raw message