cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject svn commit: r980983 - in /cassandra/trunk/src/java/org/apache/cassandra/locator: DatacenterShardStrategy.java RackAwareStrategy.java RackUnawareStrategy.java
Date Fri, 30 Jul 2010 22:16:03 GMT
Author: brandonwilliams
Date: Fri Jul 30 22:16:02 2010
New Revision: 980983

URL: http://svn.apache.org/viewvc?rev=980983&view=rev
Log:
Use LinkedHashSet in location strategies to maintain order.  Patch by Jignesh Dhruv reviewed
by brandonwilliams for CASSANDRA-1291

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/locator/DatacenterShardStrategy.java
    cassandra/trunk/src/java/org/apache/cassandra/locator/RackAwareStrategy.java
    cassandra/trunk/src/java/org/apache/cassandra/locator/RackUnawareStrategy.java

Modified: cassandra/trunk/src/java/org/apache/cassandra/locator/DatacenterShardStrategy.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/locator/DatacenterShardStrategy.java?rev=980983&r1=980982&r2=980983&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/locator/DatacenterShardStrategy.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/locator/DatacenterShardStrategy.java Fri
Jul 30 22:16:02 2010
@@ -97,7 +97,7 @@ public class DatacenterShardStrategy ext
         int totalReplicas = getReplicationFactor(table);
         Map<String, Integer> remainingReplicas = new HashMap<String, Integer>(datacenters.get(table));
         Map<String, Set<String>> dcUsedRacks = new HashMap<String, Set<String>>();
-        Set<InetAddress> endpoints = new HashSet<InetAddress>(totalReplicas);
+        Set<InetAddress> endpoints = new LinkedHashSet<InetAddress>(totalReplicas);
 
         // first pass: only collect replicas on unique racks
         for (Iterator<Token> iter = TokenMetadata.ringIterator(tokenMetadata.sortedTokens(),
searchToken);

Modified: cassandra/trunk/src/java/org/apache/cassandra/locator/RackAwareStrategy.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/locator/RackAwareStrategy.java?rev=980983&r1=980982&r2=980983&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/locator/RackAwareStrategy.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/locator/RackAwareStrategy.java Fri Jul 30
22:16:02 2010
@@ -21,7 +21,7 @@ package org.apache.cassandra.locator;
 
 import java.net.InetAddress;
 import java.util.ArrayList;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.Iterator;
 import java.util.Set;
 
@@ -47,7 +47,7 @@ public class RackAwareStrategy extends A
     public Set<InetAddress> calculateNaturalEndpoints(Token token, TokenMetadata metadata,
String table)
     {
         int replicas = getReplicationFactor(table);
-        Set<InetAddress> endpoints = new HashSet<InetAddress>(replicas);
+        Set<InetAddress> endpoints = new LinkedHashSet<InetAddress>(replicas);
         ArrayList<Token> tokens = metadata.sortedTokens();
 
         if (tokens.isEmpty())

Modified: cassandra/trunk/src/java/org/apache/cassandra/locator/RackUnawareStrategy.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/locator/RackUnawareStrategy.java?rev=980983&r1=980982&r2=980983&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/locator/RackUnawareStrategy.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/locator/RackUnawareStrategy.java Fri Jul
30 22:16:02 2010
@@ -21,7 +21,7 @@ package org.apache.cassandra.locator;
 
 import java.net.InetAddress;
 import java.util.ArrayList;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.Iterator;
 import java.util.Set;
 
@@ -45,7 +45,7 @@ public class RackUnawareStrategy extends
     {
         int replicas = getReplicationFactor(table);
         ArrayList<Token> tokens = metadata.sortedTokens();
-        Set<InetAddress> endpoints = new HashSet<InetAddress>(replicas);
+        Set<InetAddress> endpoints = new LinkedHashSet<InetAddress>(replicas);
 
         if (tokens.isEmpty())
             return endpoints;



Mime
View raw message