cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Stupp (JIRA)" <>
Subject [jira] [Commented] (CASSANDRA-7299) Cluster.Builder throws UnknownHostException when adding not existing host
Date Fri, 20 Jun 2014 18:43:24 GMT


Robert Stupp commented on CASSANDRA-7299:

[~alexander_radzin] You're posting in the wrong JIRA. What you describe belongs to the Java
driver (client) and not Cassandra (server). The JIRA you're looking for is at

> Cluster.Builder throws UnknownHostException when adding not existing host
> -------------------------------------------------------------------------
>                 Key: CASSANDRA-7299
>                 URL:
>             Project: Cassandra
>          Issue Type: Bug
>          Components: API
>            Reporter: Alexander Radzin
>            Priority: Trivial
> Connection to Cassandra cluster from client side is typically done using {{Cluster.Builder}}
class that allows to configure the connection and then build cluster by invocation of method
{{build()}}. Not all contact points must be available at creation time. If some of them start
after the connection has been established they client continue its work using the newly connected
> However if specific hostname is not available at the moment when builder is being created
 {{UnknownHostException}} is thrown. 
> IMHO Typically applications tend to create builder on start-up when reading configuration
parameters and then connect to Cassandra. For example in Spring based applications this happens
during context creation.
> This issue prevents the application to start. 
> This does not happen when using IP address even if it is not available at the moment.

> The problem is that {{Builder.addContactPoint()}} invokes {{InetAddress.getByName()}}
when creating the builder. 
> {noformat}
>         public Builder addContactPoint(String address) {
>             try {
>                 this.addresses.add(InetAddress.getByName(address));
>                 return this;
>             } catch (UnknownHostException e) {
>                 throw new IllegalArgumentException(e.getMessage());
>             }
>         }
> {noformat}
> IMHO it should do this only when building the cluster.
> My current work around is to extend {{Cluster.Builder}} (fortunately it is public and
not final) and store addresses in their textual for transforming the to instances of {{InetAddress}}
only when {{build()}} is called. This is however not full solution because the {{Cluster}}
itself also requires list of {{InetAddress}}.
> The point here is  that we can create builder and cluster with unavailable contact points
if string representation of IP address is supplied but cannot use symbolic computer name.
This is because {{InetAddress.getByName()}} throws {{UnknownHostException}} only if host identified
by name is not available:
> {quote}
> If a literal IP address is supplied, only the validity of the address format is checked.
> {quote}
> (from Javadoc of {{InetAddress.getByName()}}.

This message was sent by Atlassian JIRA

View raw message