allNodes_ = new HashSet<EndPoint>(allNodes);
}
public void assignReplicas()
{
IEndPointSnitch snitch = new EndPointSnitch();
Set<EndPoint> allNodes = new HashSet<EndPoint>(allNodes_);
Map<EndPoint, Integer> nOccurences = new HashMap<EndPoint, Integer>();
for ( EndPoint node : allNodes_ )
{
nOccurences.put(node, 1);
}
for ( EndPoint node : allNodes_ )
{
allNodes.remove(node);
for ( EndPoint choice : allNodes )
{
List<EndPoint> replicasChosen = nodeToReplicaMap_.get(node);
if ( replicasChosen == null || replicasChosen.size() < DatabaseDescriptor.getReplicationFactor() - 1 )
{
try
{
if ( !snitch.isInSameDataCenter(node, choice) )
{
if ( replicasChosen == null )
{
replicasChosen = new ArrayList<EndPoint>();
nodeToReplicaMap_.put(node, replicasChosen);