From 9e5937d24afa45228bb180b6d3d98e15a7c7bbf9 Mon Sep 17 00:00:00 2001 From: Amanda Chow Date: Wed, 4 Dec 2019 16:43:19 +0100 Subject: [PATCH] Revert "Remove self from seeds, add self to seeds if seeds is empty (#97)" This reverts commit 92153fb1a5a351d23418504ce5dbeda26398592d. --- .../cassandra/locator/SimpleSeedProvider.java | 29 ++++--------------- 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/src/java/org/apache/cassandra/locator/SimpleSeedProvider.java b/src/java/org/apache/cassandra/locator/SimpleSeedProvider.java index d4ef091f17..665261d47a 100644 --- a/src/java/org/apache/cassandra/locator/SimpleSeedProvider.java +++ b/src/java/org/apache/cassandra/locator/SimpleSeedProvider.java @@ -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; @@ -50,24 +47,12 @@ public List getSeeds() throw new AssertionError(e); } String[] hosts = conf.seed_provider.parameters.get("seeds").split(",", -1); - return getSeedsFromHosts(hosts, FBUtilities.getBroadcastAddress()); - } - - private ImmutableList getSeedsFromHosts(String[] hosts, InetAddress self) - { - ImmutableList.Builder seedsBuilder = ImmutableList.builder(); - boolean seenSelf = false; + List seeds = new ArrayList(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) { @@ -75,10 +60,6 @@ private ImmutableList getSeedsFromHosts(String[] hosts, InetAddress logger.warn("Seed provider couldn't lookup host {}", host); } } - if (seedsBuilder.build().isEmpty() && seenSelf) - { - seedsBuilder.add(self); - } - return seedsBuilder.build(); + return Collections.unmodifiableList(seeds); } }