cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1069211 - in /cassandra/branches/cassandra-0.7: CHANGES.txt src/java/org/apache/cassandra/db/ColumnFamilyStore.java src/java/org/apache/cassandra/io/sstable/CacheWriter.java
Date Thu, 10 Feb 2011 03:20:08 GMT
Author: jbellis
Date: Thu Feb 10 03:20:08 2011
New Revision: 1069211

URL: http://svn.apache.org/viewvc?rev=1069211&view=rev
Log:
continue starting when invalid savedcache entries are encountered
patch by mdennis and jbellis for CASSANDRA-2076

Modified:
    cassandra/branches/cassandra-0.7/CHANGES.txt
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/CacheWriter.java

Modified: cassandra/branches/cassandra-0.7/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1069211&r1=1069210&r2=1069211&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.7/CHANGES.txt Thu Feb 10 03:20:08 2011
@@ -61,6 +61,8 @@
  * add -D option to Stress.java to allow reading hosts from a file 
    (CASSANDRA-2149)
  * bound hints CF throughput between 32M and 256M (CASSANDRA-2148)
+ * continue starting when invalid saved cache entries are encountered
+   (CASSANDRA-2076)
 
 
 0.7.0-final

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=1069211&r1=1069210&r2=1069211&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
Thu Feb 10 03:20:08 2011
@@ -258,7 +258,19 @@ public class ColumnFamilyStore implement
                     int size = in.readInt();
                     byte[] bytes = new byte[size];
                     in.readFully(bytes);
-                    keys.add(StorageService.getPartitioner().decorateKey(ByteBuffer.wrap(bytes)));
+                    ByteBuffer buffer = ByteBuffer.wrap(bytes);
+                    DecoratedKey key;
+                    try
+                    {
+                        key = StorageService.getPartitioner().decorateKey(buffer);
+                    }
+                    catch (Exception e)
+                    {
+                        logger.info(String.format("unable to read entry #%s from saved cache
%s; skipping remaining entries",
+                                                  keys.size(), path.getAbsolutePath()), e);
+                        break;
+                    }
+                    keys.add(key);
                 }
                 if (logger.isDebugEnabled())
                     logger.debug(String.format("completed reading (%d ms; %d keys) saved
cache %s",

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/CacheWriter.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/CacheWriter.java?rev=1069211&r1=1069210&r2=1069211&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/CacheWriter.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/CacheWriter.java
Thu Feb 10 03:20:08 2011
@@ -6,7 +6,6 @@ import java.nio.ByteBuffer;
 import java.util.Set;
 
 import com.google.common.base.Function;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -23,7 +22,7 @@ public class CacheWriter<K, V> implement
     private final Function<K, ByteBuffer> converter;
     private final Set<K> keys;
     private final String columnFamily;
-    private final long totalBytes;
+    private final long estimatedTotalBytes;
     private long bytesWritten;
 
     public CacheWriter(String columnFamily, JMXInstrumentedCache<K, V> cache, File
path, Function<K, ByteBuffer> converter)
@@ -36,7 +35,9 @@ public class CacheWriter<K, V> implement
         long bytes = 0;
         for (K key : keys)
             bytes += converter.apply(key).remaining();
-        totalBytes = bytes;
+
+        // an approximation -- the keyset can change while saving
+        estimatedTotalBytes = bytes;
     }
 
     public void saveCache() throws IOException
@@ -67,7 +68,8 @@ public class CacheWriter<K, V> implement
 
     public long getTotalBytes()
     {
-        return totalBytes;
+        // keyset can change in size, thus totalBytes can too
+        return Math.max(estimatedTotalBytes, getBytesComplete());
     }
 
     public long getBytesComplete()



Mime
View raw message