cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r951245 - in /cassandra/branches/cassandra-0.6: CHANGES.txt src/java/org/apache/cassandra/db/HintedHandOffManager.java src/java/org/apache/cassandra/service/StorageService.java src/java/org/apache/cassandra/service/StorageServiceMBean.java
Date Fri, 04 Jun 2010 02:47:45 GMT
Author: jbellis
Date: Fri Jun  4 02:47:45 2010
New Revision: 951245

URL: http://svn.apache.org/viewvc?rev=951245&view=rev
Log:
remove hourly hints scan.  patch by Brandon Williams; reviewed by jbellis for CASSANDRA-1141

Modified:
    cassandra/branches/cassandra-0.6/CHANGES.txt
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/HintedHandOffManager.java
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageService.java
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageServiceMBean.java

Modified: cassandra/branches/cassandra-0.6/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/CHANGES.txt?rev=951245&r1=951244&r2=951245&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.6/CHANGES.txt Fri Jun  4 02:47:45 2010
@@ -4,6 +4,9 @@
  * reject describe_ring() calls on invalid keyspaces (CASSANDRA-1111)
  * fix cache size calculation for size of 100% (CASSANDRA-1129)
  * fix cache capacity only being recalculated once (CASSANDRA-1129)
+ * remove hourly scan of all hints on the off chance that the gossiper
+   missed a status change; instead, expose deliverHintsToEndpoint to JMX
+   so it can be done manually, if necessary (CASSANDRA-1141)
  * don't reject reads at CL.ALL (CASSANDRA-1152)
 
 

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/HintedHandOffManager.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/HintedHandOffManager.java?rev=951245&r1=951244&r2=951245&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/HintedHandOffManager.java
(original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/HintedHandOffManager.java
Fri Jun  4 02:47:45 2010
@@ -18,6 +18,7 @@
 
 package org.apache.cassandra.db;
 
+import java.net.UnknownHostException;
 import java.util.Collection;
 import java.util.Arrays;
 import java.util.concurrent.TimeoutException;
@@ -82,27 +83,11 @@ public class HintedHandOffManager
     public static final HintedHandOffManager instance = new HintedHandOffManager();
 
     private static final Logger logger_ = Logger.getLogger(HintedHandOffManager.class);
-    final static long INTERVAL_IN_MS = 3600 * 1000; // check for ability to deliver hints
this often
     public static final String HINTS_CF = "HintsColumnFamily";
     private static final int PAGE_SIZE = 10000;
 
     private final ExecutorService executor_ = new JMXEnabledThreadPoolExecutor("HINTED-HANDOFF-POOL");
 
-    protected HintedHandOffManager()
-    {
-        new Thread(new WrappedRunnable()
-        {
-            public void runMayThrow() throws Exception
-            {
-                while (true)
-                {
-                    Thread.sleep(INTERVAL_IN_MS);
-                    deliverAllHints();
-                }
-            }
-        }, "Hint delivery").start();
-    }
-
     private static boolean sendMessage(InetAddress endPoint, String tableName, String key)
throws IOException
     {
         if (!Gossiper.instance.isKnownEndpoint(endPoint))
@@ -152,67 +137,6 @@ public class HintedHandOffManager
         rm.apply();
     }
 
-    /** hintStore must be the hints columnfamily from the system table */
-    private static void deliverAllHints() throws DigestMismatchException, IOException, InvalidRequestException,
TimeoutException
-    {
-        if (logger_.isDebugEnabled())
-          logger_.debug("Started deliverAllHints");
-
-        // 1. Scan through all the keys that we need to handoff
-        // 2. For each key read the list of recipients and send
-        // 3. Delete that recipient from the key if write was successful
-        // 4. If all writes were success for a given key we can even delete the key .
-        // 5. Now force a flush
-        // 6. Do major compaction to clean up all deletes etc.
-        // 7. I guess we are done
-        ColumnFamilyStore hintStore = Table.open(Table.SYSTEM_TABLE).getColumnFamilyStore(HINTS_CF);
-        for (String tableName : DatabaseDescriptor.getTables())
-        {
-            byte[] startColumn = ArrayUtils.EMPTY_BYTE_ARRAY;
-            while (true)
-            {
-                QueryFilter filter = new SliceQueryFilter(tableName, new QueryPath(HINTS_CF),
startColumn, ArrayUtils.EMPTY_BYTE_ARRAY, false, PAGE_SIZE);
-                ColumnFamily hintColumnFamily = ColumnFamilyStore.removeDeleted(hintStore.getColumnFamily(filter),
Integer.MAX_VALUE);
-                if (pagingFinished(hintColumnFamily, startColumn))
-                    break;
-                Collection<IColumn> keys = hintColumnFamily.getSortedColumns();
-
-                for (IColumn keyColumn : keys)
-                {
-                    Collection<IColumn> endpoints = keyColumn.getSubColumns();
-                    String keyStr = new String(keyColumn.name(), "UTF-8");
-                    int deleted = 0;
-                    for (IColumn endpoint : endpoints)
-                    {
-                        if (sendMessage(InetAddress.getByAddress(endpoint.name()), tableName,
keyStr))
-                        {
-                            deleteEndPoint(endpoint.name(), tableName, keyColumn.name(),
System.currentTimeMillis());
-                            deleted++;
-                        }
-                    }
-                    if (deleted == endpoints.size())
-                    {
-                        deleteHintKey(tableName, keyColumn.name());
-                    }
-
-                    startColumn = keyColumn.name();
-                }
-            }
-        }
-        hintStore.forceFlush();
-        try
-        {
-            CompactionManager.instance.submitMajor(hintStore).get();
-        }
-        catch (Exception e)
-        {
-            throw new RuntimeException(e);
-        }
-
-        if (logger_.isDebugEnabled())
-          logger_.debug("Finished deliverAllHints");
-    }
-
     private static boolean pagingFinished(ColumnFamily hintColumnFamily, byte[] startColumn)
     {
         // done if no hints found or the start column (same as last column processed in previous
iteration) is the only one
@@ -229,6 +153,8 @@ public class HintedHandOffManager
         // 1. Scan through all the keys that we need to handoff
         // 2. For each key read the list of recipients if the endpoint matches send
         // 3. Delete that recipient from the key if write was successful
+        // 4. Now force a flush
+        // 5. Do major compaction to clean up all deletes etc.
         ColumnFamilyStore hintStore = Table.open(Table.SYSTEM_TABLE).getColumnFamilyStore(HINTS_CF);
         for (String tableName : DatabaseDescriptor.getTables())
         {
@@ -261,6 +187,15 @@ public class HintedHandOffManager
                 }
             }
         }
+        hintStore.forceFlush();
+        try
+        {
+            CompactionManager.instance.submitMajor(hintStore, 0, Integer.MAX_VALUE).get();
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException(e);
+        }
 
         if (logger_.isDebugEnabled())
           logger_.debug("Finished hinted handoff for endpoint " + endPoint);
@@ -282,4 +217,9 @@ public class HintedHandOffManager
         };
     	executor_.submit(r);
     }
+
+    public void deliverHints(String to) throws UnknownHostException
+    {
+        deliverHints(InetAddress.getByName(to));
+    }
 }

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageService.java?rev=951245&r1=951244&r2=951245&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageService.java
(original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageService.java
Fri Jun  4 02:47:45 2010
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.IOError;
 import java.lang.management.ManagementFactory;
 import java.lang.reflect.Constructor;
+import java.net.UnknownHostException;
 import java.util.*;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
@@ -919,6 +920,11 @@ public class StorageService implements I
         HintedHandOffManager.instance.deliverHints(endpoint);
     }
 
+    public final void deliverHints(String host) throws UnknownHostException
+    {
+        HintedHandOffManager.instance.deliverHints(host);
+    }
+
     public Token getLocalToken()
     {
         return storageMetadata_.getToken();

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageServiceMBean.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageServiceMBean.java?rev=951245&r1=951244&r2=951245&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageServiceMBean.java
(original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageServiceMBean.java
Fri Jun  4 02:47:45 2010
@@ -170,4 +170,6 @@ public interface StorageServiceMBean
     /** makes node unavailable for writes, flushes memtables and replays commitlog. */
     public void drain() throws IOException, InterruptedException, ExecutionException;
     
+    /** force hint delivery to an endpoint **/
+    public void deliverHints(String host) throws UnknownHostException;
 }



Mime
View raw message