cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1144380 - in /cassandra/branches/cassandra-0.7: CHANGES.txt src/java/org/apache/cassandra/service/DatacenterReadCallback.java src/java/org/apache/cassandra/service/ReadCallback.java
Date Fri, 08 Jul 2011 16:37:37 GMT
Author: jbellis
Date: Fri Jul  8 16:37:37 2011
New Revision: 1144380

URL: http://svn.apache.org/viewvc?rev=1144380&view=rev
Log:
fix possibility of spuriousUnavailableException for LOCAL_QUORUM reads with dynamic snitch
and read repair disabled
patch by jbellis; reviewed by slebresne for CASSANDRA-2870

Modified:
    cassandra/branches/cassandra-0.7/CHANGES.txt
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/DatacenterReadCallback.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/ReadCallback.java

Modified: cassandra/branches/cassandra-0.7/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1144380&r1=1144379&r2=1144380&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.7/CHANGES.txt Fri Jul  8 16:37:37 2011
@@ -1,3 +1,8 @@
+0.7.8
+ * fix possibility of spurious UnavailableException for LOCAL_QUORUM
+   reads with dynamic snitch + read repair disabled (CASSANDRA-2870)
+
+
 0.7.7
  * adjust hinted handoff page size to avoid OOM with large columns 
    (CASSANDRA-2652)

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/DatacenterReadCallback.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/DatacenterReadCallback.java?rev=1144380&r1=1144379&r2=1144380&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/DatacenterReadCallback.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/DatacenterReadCallback.java
Fri Jul  8 16:37:37 2011
@@ -22,6 +22,7 @@ package org.apache.cassandra.service;
 
 
 import java.net.InetAddress;
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.cassandra.config.DatabaseDescriptor;
@@ -48,6 +49,20 @@ public class DatacenterReadCallback<T> e
     }
 
     @Override
+    protected List<InetAddress> preferredEndpoints(List<InetAddress> endpoints)
+    {
+        ArrayList<InetAddress> preferred = new ArrayList<InetAddress>(blockfor);
+        for (InetAddress endpoint : endpoints)
+        {
+            if (localdc.equals(snitch.getDatacenter(endpoint)))
+                preferred.add(endpoint);
+            if (preferred.size() == blockfor)
+                break;
+        }
+        return preferred;
+    }
+
+    @Override
     protected boolean waitingFor(Message message)
     {
         return localdc.equals(snitch.getDatacenter(message.getFrom()));
@@ -88,7 +103,7 @@ public class DatacenterReadCallback<T> e
                     if (localdc.equals(snitch.getDatacenter(endpoint)))
                         builder.append(endpoint).append(",");
                 }
-                builder.append("] are insufficient to satisfy LOCAL_QUORUM requirement of
").append(blockfor).append(" live nodes");
+                builder.append("] are insufficient to satisfy LOCAL_QUORUM requirement of
").append(blockfor).append(" live nodes in '").append(localdc).append("'");
                 logger.debug(builder.toString());
             }
 

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/ReadCallback.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/ReadCallback.java?rev=1144380&r1=1144379&r2=1144380&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/ReadCallback.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/ReadCallback.java
Fri Jul  8 16:37:37 2011
@@ -80,13 +80,18 @@ public class ReadCallback<T> implements 
         boolean repair = randomlyReadRepair();
         this.endpoints = repair || resolver instanceof RowRepairResolver
                        ? endpoints
-                       : endpoints.subList(0, Math.min(endpoints.size(), blockfor)); // min
so as to not throw exception until assureSufficient is called
+                       : preferredEndpoints(endpoints);
 
         if (logger.isDebugEnabled())
             logger.debug(String.format("Blockfor/repair is %s/%s; setting up requests to
%s",
                                        blockfor, repair, StringUtils.join(this.endpoints,
",")));
     }
-    
+
+    protected List<InetAddress> preferredEndpoints(List<InetAddress> endpoints)
+    {
+        return endpoints.subList(0, Math.min(endpoints.size(), blockfor)); // min so as to
not throw exception until assureSufficient is called
+    }
+
     private boolean randomlyReadRepair()
     {
         if (resolver instanceof RowDigestResolver)



Mime
View raw message