Allow multiple comma-separated hosts in spark.cassandra.connection.host

I made that change, let me know if there's anything else you need.


On Thu, Aug 14, 2014 at 1:42 PM, Helena Edelson <notifications@github.com>
wrote:

> In
> spark-cassandra-connector/src/main/scala/com/datastax/spark/connector/cql/CassandraConnectorConf.scala:
>
> > @@ -34,11 +34,21 @@ object CassandraConnectorConf {
> >    }
> >
> >    def apply(conf: SparkConf): CassandraConnectorConf = {
> > -    val host = InetAddress.getByName(conf.get(CassandraConnectionHostProperty, InetAddress.getLocalHost.getHostAddress))
> > +    val hosts = conf.get(CassandraConnectionHostProperty, InetAddress.getLocalHost.getHostAddress).
> > +      split(",").
> > +      flatMap { host =>
> > +        try {
> > +          Some(InetAddress.getByName(host))
> > +        } catch {
> > +          case x: java.net.UnknownHostException =>
> > +            logError("Unknown host", x)
> > +            None
> > +        }
> > +      }.toSet
>
> Just looking still, not compiling but my emphasis here is try to keep the
> code cleaner:
>
> val hosts = conf.get(CassandraConnectionHostProperty, InetAddress.getLocalHost.getHostAddress).
>
>           split(",").flatMap { host =>
>              try Some(InetAddress.getByName(host)) catch {
>                  case NonFatal(e) => // or the exact exception if you must
>                     logError(s"Unknown host '$host'", e)
>                      None
>              }
>           }.toSet
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/datastax/spark-cassandra-connector/pull/163/files#r16257562>
> .
>