cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdusba...@apache.org
Subject svn commit: r1030047 - in /cassandra/trunk: CHANGES.txt src/java/org/apache/cassandra/service/StorageProxy.java
Date Tue, 02 Nov 2010 14:04:36 GMT
Author: gdusbabek
Date: Tue Nov  2 14:04:35 2010
New Revision: 1030047

URL: http://svn.apache.org/viewvc?rev=1030047&view=rev
Log:
include dead hosts in unreachable. patch by gdusbabek, reviewed by jbellis. CASSANDRA-1678

Modified:
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1030047&r1=1030046&r2=1030047&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Tue Nov  2 14:04:35 2010
@@ -6,10 +6,10 @@ dev
  * fix IntegerType.getString (CASSANDRA-1681)
  * log tpstats when dropping messages (CASSANDRA-1660)
  * make -Djava.net.preferIPv4Stack=true the default (CASSANDRA-628)
- * make -Djava.net.preferIPv4Stack=true the default (CASSANDRA-628)
  * add INTERNAL_RESPONSE verb to differentiate from responses related
    to client requests (CASSANDRA-1685)
  * log tpstats when dropping messages (CASSANDRA-1660)
+ * include unreachable nodes in describeSchemaVersions (CASSANDRA-1678)
 
 
 0.7.0-beta3

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java?rev=1030047&r1=1030046&r2=1030047&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java Tue Nov  2 14:04:35
2010
@@ -27,6 +27,7 @@ import java.util.concurrent.*;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
+import com.google.common.collect.Iterables;
 import com.google.common.collect.Multimap;
 import static com.google.common.base.Charsets.UTF_8;
 import org.apache.commons.lang.ArrayUtils;
@@ -65,6 +66,7 @@ public class StorageProxy implements Sto
     private static final LatencyTracker rangeStats = new LatencyTracker();
     private static final LatencyTracker writeStats = new LatencyTracker();
     private static boolean hintedHandoffEnabled = DatabaseDescriptor.hintedHandoffEnabled();
+    private static final String UNREACHABLE = "UNREACHABLE";
 
     private StorageProxy() {}
     static
@@ -491,8 +493,6 @@ public class StorageProxy implements Sto
      */
     public static Map<String, List<String>> describeSchemaVersions()
     {
-        final Map<String, List<String>> results = new HashMap<String, List<String>>();
-        
         final String myVersion = DatabaseDescriptor.getDefsVersion().toString();
         final Map<InetAddress, UUID> versions = new ConcurrentHashMap<InetAddress,
UUID>();
         final Set<InetAddress> liveHosts = Gossiper.instance.getLiveMembers();
@@ -523,30 +523,32 @@ public class StorageProxy implements Sto
         
         logger.debug("My version is " + myVersion);
         
-        // first, indicate any hosts that did not respond.
-        final Set<InetAddress> ackedHosts = versions.keySet();
-        if (ackedHosts.size() < liveHosts.size())
-        {
-            Set<InetAddress> missingHosts = new HashSet<InetAddress>(liveHosts);
-            missingHosts.removeAll(ackedHosts);
-            assert missingHosts.size() > 0;
-            List<String> missingHostNames = new ArrayList<String>(missingHosts.size());
-            for (InetAddress host : missingHosts)
-                missingHostNames.add(host.getHostAddress());
-            results.put(DatabaseDescriptor.INITIAL_VERSION.toString(), missingHostNames);
-            logger.debug("Hosts not in agreement. Didn't get a response from everybody: "
+ StringUtils.join(missingHostNames, ","));
+        // maps versions to hosts that are on that version.
+        Map<String, List<String>> results = new HashMap<String, List<String>>();
+        Iterable<InetAddress> allHosts = Iterables.concat(Gossiper.instance.getLiveMembers(),
Gossiper.instance.getUnreachableMembers());
+        for (InetAddress host : allHosts)
+        {
+            UUID version = versions.get(host);
+            String stringVersion = version == null ? UNREACHABLE : version.toString();
+            List<String> hosts = results.get(stringVersion);
+            if (hosts == null)
+            {
+                hosts = new ArrayList<String>();
+                results.put(stringVersion, hosts);
+            }
+            hosts.add(host.getHostAddress());
         }
-        
+        if (results.get(UNREACHABLE) != null)
+            logger.debug("Hosts not in agreement. Didn't get a response from everybody: "
+ StringUtils.join(results.get(UNREACHABLE), ","));
         // check for version disagreement. log the hosts that don't agree.
-        for (InetAddress host : ackedHosts)
+        for (Map.Entry<String, List<String>> entry : results.entrySet())
         {
-            String uuid = versions.get(host).toString();
-            if (!results.containsKey(uuid))
-                results.put(uuid, new ArrayList<String>());
-            results.get(uuid).add(host.getHostAddress());
-            if (!uuid.equals(myVersion))
-                logger.debug("%s disagrees (%s)", host.getHostAddress(), uuid);
+            if (entry.getKey().equals(UNREACHABLE) || entry.getKey().equals(myVersion))
+                continue;
+            for (String host : entry.getValue())
+                logger.debug("%s disagrees (%s)", host, entry.getKey());
         }
+        
         if (results.size() == 1)
             logger.debug("Schemas are in agreement.");
         



Mime
View raw message