cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yu...@apache.org
Subject git commit: change cache write progress check to cache type basis; patch by yukim, reviewed by jbellis for CASSANDRA-4533
Date Wed, 22 Aug 2012 14:00:49 GMT
Updated Branches:
  refs/heads/cassandra-1.1 5655d9722 -> aa81f84c3


change cache write progress check to cache type basis; patch by yukim,
reviewed by jbellis for CASSANDRA-4533


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/aa81f84c
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/aa81f84c
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/aa81f84c

Branch: refs/heads/cassandra-1.1
Commit: aa81f84c38f2c1fcad08eae955bec031341f8f75
Parents: 5655d97
Author: Yuki Morishita <yukim@apache.org>
Authored: Wed Aug 22 08:55:46 2012 -0500
Committer: Yuki Morishita <yukim@apache.org>
Committed: Wed Aug 22 08:55:58 2012 -0500

----------------------------------------------------------------------
 .../apache/cassandra/cache/AutoSavingCache.java    |    8 +++++++-
 .../cassandra/db/compaction/CompactionManager.java |    4 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/aa81f84c/src/java/org/apache/cassandra/cache/AutoSavingCache.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cache/AutoSavingCache.java b/src/java/org/apache/cassandra/cache/AutoSavingCache.java
index 004e46e..b4e77be 100644
--- a/src/java/org/apache/cassandra/cache/AutoSavingCache.java
+++ b/src/java/org/apache/cassandra/cache/AutoSavingCache.java
@@ -27,6 +27,7 @@ import java.util.concurrent.Future;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
+import org.cliffc.high_scale_lib.NonBlockingHashSet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,7 +50,7 @@ public class AutoSavingCache<K extends CacheKey, V> extends InstrumentingCache<K
     private static final Logger logger = LoggerFactory.getLogger(AutoSavingCache.class);
 
     /** True if a cache flush is currently executing: only one may execute at a time. */
-    public static final AtomicBoolean flushInProgress = new AtomicBoolean(false);
+    public static final Set<CacheService.CacheType> flushInProgress = new NonBlockingHashSet<CacheService.CacheType>();
 
     protected volatile ScheduledFuture<?> saveTask;
     protected final CacheService.CacheType cacheType;
@@ -200,6 +201,11 @@ public class AutoSavingCache<K extends CacheKey, V> extends InstrumentingCache<K
                                       estimatedTotalBytes);
         }
 
+        public CacheService.CacheType cacheType()
+        {
+            return cacheType;
+        }
+
         public CompactionInfo getCompactionInfo()
         {
             long bytesWritten = this.bytesWritten;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/aa81f84c/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
index 0f5be39..fcdf45b 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -773,7 +773,7 @@ public class CompactionManager implements CompactionManagerMBean
         {
             public void runMayThrow() throws IOException
             {
-                if (!AutoSavingCache.flushInProgress.compareAndSet(false, true))
+                if (!AutoSavingCache.flushInProgress.add(writer.cacheType()))
                 {
                     logger.debug("Cache flushing was already in progress: skipping {}", writer.getCompactionInfo());
                     return;
@@ -792,7 +792,7 @@ public class CompactionManager implements CompactionManagerMBean
                 }
                 finally
                 {
-                    AutoSavingCache.flushInProgress.set(false);
+                    AutoSavingCache.flushInProgress.remove(writer.cacheType());
                 }
             }
         };


Mime
View raw message