66997

Astyanax Cassandra driver removes host unexpectedly during batch inserting

Question:

<strong>Astyanax 1.56.37 connecting to Cassandra 1.2.6 running on Debian:</strong>

When performing a number of inserts in quick succession to a Cassandra cluster containing only one node located at 10.10.1.141, at seemingly random points, I will see the following in the console:

- AddHost: 127.0.0.1 - RemoveHost: 10.10.1.141

Every attempt to connect to this keyspace after I get this fails with the same message.

Here is my configuration:

AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder() .forCluster("Titan Cluster") .forKeyspace(keyspaceName) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setConnectionPoolType(ConnectionPoolType.TOKEN_AWARE) .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE) .setTargetCassandraVersion("1.2") ) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") .setPort(9160) .setMaxConnsPerHost(50) .setSeeds("10.10.1.141:9160") .setConnectTimeout(2000) .setSocketTimeout(30000) .setMaxTimeoutWhenExhausted(10000) .setMaxTimeoutCount(3) .setTimeoutWindow(10000) .setLatencyAwareBadnessThreshold(10) .setLatencyAwareUpdateInterval(1000) .setLatencyAwareResetInterval(10000) .setLatencyAwareWindowSize(100) ) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); context.start();

The connection fails on subsequent attempts at context.start()

Answer1:

I too faced the same issue where I had my Cassandra and application (Cassandra client) running on different machines.

AddHost: 10.10.1.141 AddHost: 127.0.0.1 RemoveHost: 10.10.1.141

When I checked my Cassandra ring status, I noticed that the Cassandra was running with the address 127.0.0.1, instead of 10.10.1.141

root@10.10.1.141:/opt/dsc-cassandra$ **bin/nodetool ring** Address Rack Status State Load Owns Token 127.0.0.1 rack1 Up Normal 169.87 KB 100.00% -9217929600007243236 127.0.0.1 rack1 Up Normal 169.87 KB 100.00% -9140762708880451456 127.0.0.1 rack1 Up Normal 169.87 KB 100.00% -8952943573583903866 127.0.0.1 rack1 Up Normal 169.87 KB 100.00% -8891950316930533160*

In conf/cassandra.yaml, I had specified the hostname instead of IP address for listen_address. The cassandra resoved the hostname to localhost (127.0.0.1) instead of the actual IP (10.10.1.141). After changing the listen_address to the actual IP, the client established connection successfully.

<strong>listen_address: 10.10.1.141</strong>

Answer2:

I was running Cassandra on VirtualBox on Windows, so the IP was something like 168.192.0.14, and for me, using NodeDiscoveryType.NONE prevented disconnections:

AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder() .forCluster(clusterName) .forKeyspace(keyspaceName) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setDiscoveryType(NodeDiscoveryType.NONE) ) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") .setPort(9160) .setMaxConnsPerHost(3) .setSeeds("192.168.0.14:9160") ) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); context.start(); Keyspace keyspace = context.getClient();

Recommend

  • How to insert rows into cassandra if they don't exist using spark- cassandra driver?
  • Why to avoid dynamic SQL queries ? any suggestion to remove there bad part and to use these?
  • Unable to increase heap size for JMeter on Mac OSX
  • mac java 9 gradle ClassNotFoundException: javax.xml.bind.JAXBElement when building
  • preg_split is case insensitive with special characters
  • How to package an Android Library for Android Studio
  • Java 9 migration javax.annotation
  • Exceptions: Is this a good practice?
  • Error while uploading a new version of an Android app [duplicate]
  • Installing Mathics under Mac Os X
  • Get a list of orders in magento extension that have a certain product
  • error when inserting dataframe into MS-SQL with Python
  • Lock a window position to another window?
  • SSRS Show Textbox on last page separately
  • Java applet not working in firefox
  • Get Image uint8 data without canvas
  • how to implement Step definitios from gherkin feature files
  • Is libpq more like a JDBC driver or JavaSE's java.sql package?
  • cannot use raw_input if monkeyrunner is included in python script
  • Three.js - how can I update an arrowHelper?
  • adding a legend to a scatterplot with fitted line and prediction interval
  • TinyXML - any way to skip problematic DOCTYPE tag?
  • Can someone explain how Postgresql roles, Postgresql users and Linux users relate to each other?
  • Problem with sockets and OutOfMemory error
  • draw9patch just hangs on Mac 10.7.5
  • Android SAXParser, parse into array and get child nodes
  • No server chosen by WritableServerSelector from cluster
  • In PostgreSQL, how can we tell if each index of a table is clustered or not? [duplicate]
  • spark-ec2 not recognized when lauching cluster on windows 8.1
  • Difference between File>Close and :close in Vim
  • How can i create a big file in google drive with google app script?
  • How to add header and Footer to each activity in android
  • jQuery & CSS - Cut text by height, no truncate
  • How do I retrieve table names in Cassandra using Java?
  • Cluster markers with osmdroid
  • Is storing an OAuth token in cookies bad practise?
  • Qt - Cannot get lambda to work [duplicate]
  • How can I encode a filename according to RFC 2231?
  • Underlying type for Tuple in Swift
  • How gzip file gets stored in HDFS