cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Radzin (JIRA)" <>
Subject [jira] [Created] (CASSANDRA-7299) Cluster.Builder throws UnknownHostException when adding not existing host
Date Sun, 25 May 2014 07:03:01 GMT
Alexander Radzin created CASSANDRA-7299:

             Summary: Cluster.Builder throws UnknownHostException when adding not existing
                 Key: CASSANDRA-7299
             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. 

        public Builder addContactPoint(String address) {
            try {
                return this;
            } catch (UnknownHostException e) {
                throw new IllegalArgumentException(e.getMessage());

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:

If a literal IP address is supplied, only the validity of the address format is checked.

(from Javadoc of {{InetAddress.getByName()}}.

This message was sent by Atlassian JIRA

View raw message