You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2011/10/01 07:41:09 UTC

svn commit: r1177922 - in /cassandra/branches/cassandra-1.0.0: CHANGES.txt src/java/org/apache/cassandra/db/SystemTable.java

Author: jbellis
Date: Sat Oct  1 05:41:09 2011
New Revision: 1177922

URL: http://svn.apache.org/viewvc?rev=1177922&view=rev
Log:
remove obsolete hints on first startup
patch by jbellis; reviewed by Patricio Echague for CASSANDRA-3291

Modified:
    cassandra/branches/cassandra-1.0.0/CHANGES.txt
    cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/db/SystemTable.java

Modified: cassandra/branches/cassandra-1.0.0/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0.0/CHANGES.txt?rev=1177922&r1=1177921&r2=1177922&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0.0/CHANGES.txt (original)
+++ cassandra/branches/cassandra-1.0.0/CHANGES.txt Sat Oct  1 05:41:09 2011
@@ -1,5 +1,6 @@
 1.0.0-final
  * ignore any CF ids sent by client for adding CF/KS (CASSANDRA-3288)
+ * remove obsolete hints on first startup (CASSANDRA-3291)
 
 
 1.0.0-rc2

Modified: cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/db/SystemTable.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/db/SystemTable.java?rev=1177922&r1=1177921&r2=1177922&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/db/SystemTable.java (original)
+++ cassandra/branches/cassandra-1.0.0/src/java/org/apache/cassandra/db/SystemTable.java Sat Oct  1 05:41:09 2011
@@ -18,8 +18,6 @@
 
 package org.apache.cassandra.db;
 
-import java.io.File;
-import java.io.FilenameFilter;
 import java.io.IOError;
 import java.io.IOException;
 import java.net.InetAddress;
@@ -30,7 +28,6 @@ import java.util.List;
 import java.util.ArrayList;
 import java.util.SortedSet;
 import java.util.TreeSet;
-import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.ExecutionException;
 
 import org.slf4j.Logger;
@@ -74,25 +71,24 @@ public class SystemTable
     /* if hints become incompatible across versions of cassandra, that logic (and associated purging) is managed here. */
     public static void purgeIncompatibleHints() throws IOException
     {
-        // 0.6->0.7
-        final ByteBuffer hintsPurged6to7 = ByteBufferUtil.bytes("Hints purged as part of upgrading from 0.6.x to 0.7");
+        ByteBuffer upgradeMarker = ByteBufferUtil.bytes("Pre-1.0 hints purged");
         Table table = Table.open(Table.SYSTEM_TABLE);
-        QueryFilter dotSeven = QueryFilter.getNamesFilter(decorate(COOKIE_KEY), new QueryPath(STATUS_CF), hintsPurged6to7);
-        ColumnFamily cf = table.getColumnFamilyStore(STATUS_CF).getColumnFamily(dotSeven);
-        if (cf == null)
-        {
-            // 0.7+ marker not found.  Remove hints and add the marker.
-            ColumnFamilyStore hintsCfs = Table.open(Table.SYSTEM_TABLE).getColumnFamilyStore(HintedHandOffManager.HINTS_CF);
-            if (hintsCfs.getSSTables().size() > 0)
-            {
-                logger.info("Possible 0.6-format hints found. Snapshotting as 'old-hints' and purging");
-                hintsCfs.snapshot("old-hints");
-                hintsCfs.removeAllSSTables();
-            }
-            RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, COOKIE_KEY);
-            rm.add(new QueryPath(STATUS_CF, null, hintsPurged6to7), ByteBufferUtil.bytes("oh yes, it they were purged."), System.currentTimeMillis());
-            rm.apply();
+        QueryFilter filter = QueryFilter.getNamesFilter(decorate(COOKIE_KEY), new QueryPath(STATUS_CF), upgradeMarker);
+        ColumnFamily cf = table.getColumnFamilyStore(STATUS_CF).getColumnFamily(filter);
+        if (cf != null)
+            return;
+
+        // marker not found.  Snapshot + remove hints and add the marker
+        ColumnFamilyStore hintsCfs = Table.open(Table.SYSTEM_TABLE).getColumnFamilyStore(HintedHandOffManager.HINTS_CF);
+        if (hintsCfs.getSSTables().size() > 0)
+        {
+            logger.info("Possible old-format hints found. Snapshotting as 'old-hints' and purging");
+            hintsCfs.snapshot("old-hints");
+            hintsCfs.removeAllSSTables();
         }
+        RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, COOKIE_KEY);
+        rm.add(new QueryPath(STATUS_CF, null, upgradeMarker), ByteBufferUtil.bytes("oh yes, they were purged"), System.currentTimeMillis());
+        rm.apply();
     }
 
     /**