I am using Hector version 0.7.0-20 with a Cassandra cluster running
0.7.0-rc4 on three nodes. I have a keyspace with replication_factor of
2 and populated a column family with a million keys. I wanted to make
sure failover works with the cluster, so I brought down one of the
cassandra nodes (128.242.246.62) and tried to execute a read query,
but I cannot connect. This is the relevant code (call to
getOrCreateCluster causes it):
CassandraHostConfigurator hostConfigurator = new
CassandraHostConfigurator("
128.242.246.60:9160,
128.242.246.61:9160,
128.242.246.62:9160");
Cluster cluster = HFactory.getOrCreateCluster("Test Cluster",
hostConfigurator);
This is the exception:
Exception in thread "main"
me.prettyprint.hector.api.exceptions.HectorTransportException: Unable
to open transport to 128.242.246.62(128.242.246.62):9160 ,
java.net.ConnectException: Connection refused
at
me.prettyprint.cassandra.connection.HThriftClient.open(HThriftClient.java:
91)
at
me.prettyprint.cassandra.connection.ConcurrentHClientPool.<init>(ConcurrentHClientPool.java:
44)
at
me.prettyprint.cassandra.connection.HConnectionManager.<init>(HConnectionManager.java:
54)
at
me.prettyprint.cassandra.service.AbstractCluster.<init>(AbstractCluster.java:
60)
at
me.prettyprint.cassandra.service.AbstractCluster.<init>(AbstractCluster.java:
56)
at
me.prettyprint.cassandra.service.ThriftCluster.<init>(ThriftCluster.java:
17)
at
me.prettyprint.hector.api.factory.HFactory.createCluster(HFactory.java:
107)
at
me.prettyprint.hector.api.factory.HFactory.getOrCreateCluster(HFactory.java:
99)
at HectorRetrieve.run(HectorRetrieve.java:47)
at HectorRetrieve.main(HectorRetrieve.java:35)
Caused by: org.apache.thrift.transport.TTransportException:
java.net.ConnectException: Connection refused
at org.apache.thrift.transport.TSocket.open(TSocket.java:185)
at
org.apache.thrift.transport.TFramedTransport.open(TFramedTransport.java:
81)
at
me.prettyprint.cassandra.connection.HThriftClient.open(HThriftClient.java:
85)
... 9 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:
333)
at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at org.apache.thrift.transport.TSocket.open(TSocket.java:180)
... 11 more
I had tried similar code with Hector 0.6.020 and Cassandra 0.6.8 and
took down one of the nodes, but it worked. Can you help me out?