Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7EB0D1113B for ; Tue, 5 Aug 2014 19:02:09 +0000 (UTC) Received: (qmail 76853 invoked by uid 500); 5 Aug 2014 19:02:09 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 76818 invoked by uid 500); 5 Aug 2014 19:02:09 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 76803 invoked by uid 99); 5 Aug 2014 19:02:09 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Aug 2014 19:02:09 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id AB3809C0335; Tue, 5 Aug 2014 19:02:08 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: brandonwilliams@apache.org To: commits@cassandra.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: Prevent SSP from erroring out when the yaml is yanked from it. Date: Tue, 5 Aug 2014 19:02:08 +0000 (UTC) Repository: cassandra Updated Branches: refs/heads/cassandra-2.1 fa8e5158a -> 7e71d01a0 Prevent SSP from erroring out when the yaml is yanked from it. Patch by brandonwilliams, reviewed by Richard Low for CASSANDRA-7663 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/7e71d01a Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/7e71d01a Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/7e71d01a Branch: refs/heads/cassandra-2.1 Commit: 7e71d01a036fc0338b0f5ad1b9d61792ed190caa Parents: fa8e515 Author: Brandon Williams Authored: Tue Aug 5 13:53:01 2014 -0500 Committer: Brandon Williams Committed: Tue Aug 5 14:02:00 2014 -0500 ---------------------------------------------------------------------- .../cassandra/locator/SimpleSeedProvider.java | 27 ++++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/7e71d01a/src/java/org/apache/cassandra/locator/SimpleSeedProvider.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/locator/SimpleSeedProvider.java b/src/java/org/apache/cassandra/locator/SimpleSeedProvider.java index 6f36cd0..8e7d9fc 100644 --- a/src/java/org/apache/cassandra/locator/SimpleSeedProvider.java +++ b/src/java/org/apache/cassandra/locator/SimpleSeedProvider.java @@ -17,6 +17,7 @@ */ package org.apache.cassandra.locator; +import java.io.IOException; import java.io.InputStream; import java.net.InetAddress; import java.net.URL; @@ -29,6 +30,7 @@ import java.util.Map; import org.apache.cassandra.config.Config; import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.config.SeedProviderDef; +import org.apache.cassandra.exceptions.ConfigurationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.yaml.snakeyaml.Loader; @@ -39,19 +41,34 @@ public class SimpleSeedProvider implements SeedProvider { private static final Logger logger = LoggerFactory.getLogger(SimpleSeedProvider.class); - public SimpleSeedProvider(Map args) {} + List seeds; + public SimpleSeedProvider(Map args) { + try + { + seeds = loadSeeds(); + } + catch (Exception e) + { + throw new AssertionError(e); + } + } public List getSeeds() { - Config conf; try { - conf = DatabaseDescriptor.loadConfig(); + seeds = loadSeeds(); } catch (Exception e) { - throw new AssertionError(e); + logger.warn("Could not refresh seeds from configuration file: {}", e); } + return Collections.unmodifiableList(seeds); + } + + private List loadSeeds() throws IOException, ConfigurationException + { + Config conf = DatabaseDescriptor.loadConfig(); String[] hosts = conf.seed_provider.parameters.get("seeds").split(",", -1); List seeds = new ArrayList(hosts.length); for (String host : hosts) @@ -66,6 +83,6 @@ public class SimpleSeedProvider implements SeedProvider logger.warn("Seed provider couldn't lookup host {}", host); } } - return Collections.unmodifiableList(seeds); + return seeds; } }