Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Remove self from seeds, add self to seeds if seeds is empty" #125

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}