Skip to content

Commit

Permalink
Revert "Remove self from seeds, add self to seeds if seeds is em… (#125)
Browse files Browse the repository at this point in the history
This reverts commit 92153fb.
  • Loading branch information
amandachow authored and Mattheo committed Sep 10, 2020
1 parent 5c7de03 commit 5cfd768
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions src/java/org/apache/cassandra/locator/SimpleSeedProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import org.apache.cassandra.config.Config;
import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.utils.FBUtilities;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -50,35 +47,19 @@ public List<InetAddress> getSeeds()
throw new AssertionError(e);
}
String[] hosts = conf.seed_provider.parameters.get("seeds").split(",", -1);
return getSeedsFromHosts(hosts, FBUtilities.getBroadcastAddress());
}

private ImmutableList<InetAddress> getSeedsFromHosts(String[] hosts, InetAddress self)
{
ImmutableList.Builder<InetAddress> seedsBuilder = ImmutableList.builder();
boolean seenSelf = false;
List<InetAddress> seeds = new ArrayList<InetAddress>(hosts.length);
for (String host : hosts)
{
try
{
InetAddress seed = InetAddress.getByName(host.trim());
if (seed.equals(self))
{
seenSelf = true;
continue;
}
seedsBuilder.add(seed);
seeds.add(InetAddress.getByName(host.trim()));
}
catch (UnknownHostException ex)
{
// not fatal... DD will bark if there end up being zero seeds.
logger.warn("Seed provider couldn't lookup host {}", host);
}
}
if (seedsBuilder.build().isEmpty() && seenSelf)
{
seedsBuilder.add(self);
}
return seedsBuilder.build();
return Collections.unmodifiableList(seeds);
}
}

0 comments on commit 5cfd768

Please sign in to comment.