Use LinkedHashSet in location strategies to maintain order. Patch by Jignesh Dhruv reviewed by brandonwilliams for CASSANDRA-1291

git-svn-id: https://svn.apache.org/repos/asf/cassandra/trunk@980983 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brandon Williams 2010-07-30 22:16:02 +00:00
parent 2673caf5de
commit e0d4419a2e
3 changed files with 5 additions and 5 deletions

View File

@ -97,7 +97,7 @@ public class DatacenterShardStrategy extends AbstractReplicationStrategy
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);

View File

@ -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 AbstractReplicationStrategy
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())

View File

@ -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 AbstractReplicationStrategy
{
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;