cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [1/2] git commit: Prevent SSP from erroring out when the yaml is yanked from it.
Date Tue, 05 Aug 2014 19:02:26 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk f64a113e1 -> 7dd320c9e


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/trunk
Commit: 7e71d01a036fc0338b0f5ad1b9d61792ed190caa
Parents: fa8e515
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Tue Aug 5 13:53:01 2014 -0500
Committer: Brandon Williams <brandonwilliams@apache.org>
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<String, String> args) {}
+    List<InetAddress> seeds;
+    public SimpleSeedProvider(Map<String, String> args) {
+        try
+        {
+            seeds = loadSeeds();
+        }
+        catch (Exception e)
+        {
+            throw new AssertionError(e);
+        }
+    }
 
     public List<InetAddress> 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<InetAddress> loadSeeds() throws IOException, ConfigurationException
+    {
+        Config conf = DatabaseDescriptor.loadConfig();
         String[] hosts = conf.seed_provider.parameters.get("seeds").split(",", -1);
         List<InetAddress> seeds = new ArrayList<InetAddress>(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;
     }
 }


Mime
View raw message