cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [1/6] git commit: Prevent SSP from erroring out when the yaml is yanked from it.
Date Wed, 06 Aug 2014 10:13:29 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1.0 cd84cc9ec -> a7d950e36


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/73eb68c5
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/73eb68c5
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/73eb68c5

Branch: refs/heads/cassandra-2.1.0
Commit: 73eb68c516a291e2f8a816abab20b67999eb851b
Parents: 244f234
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 13:53:01 2014 -0500

----------------------------------------------------------------------
 .../cassandra/locator/SimpleSeedProvider.java   | 30 ++++++++++++++++----
 1 file changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/73eb68c5/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 9f491f3..6c426bd 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,20 +41,36 @@ 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()
     {
-        InputStream input;
         try
         {
-            URL url = DatabaseDescriptor.getStorageConfigURL();
-            input = url.openStream();
+            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
+    {
+        InputStream input;
+        URL url = DatabaseDescriptor.getStorageConfigURL();
+        input = url.openStream();
         org.yaml.snakeyaml.constructor.Constructor constructor = new org.yaml.snakeyaml.constructor.Constructor(Config.class);
         TypeDescription seedDesc = new TypeDescription(SeedProviderDef.class);
         seedDesc.putMapPropertyType("parameters", String.class, String.class);
@@ -73,6 +91,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