0

I have a Cassandra process that was created and defined in early Cassandra versions. So far, we used an hector driver to connect to it. Im in a process of changing the driver to DataStax to enjoy the CQL new features and to allow asynchronous access.

I encounter some problems in the process of doing that transition. I've read this upgrade guide which shed some light though I still encounter some problems.

The biggest one is that I cant access the keyspace with a protocol version bigger than one. When I try the following python code:

cass4 = Cluster(['MyIp'])
cass4.protocol_version = 2
session = cass4.connect('myKeySpace')

This code yields the following errors and warnings:

ERROR:cassandra.connection:Closing connection <AsyncoreConnection(4849045328) IP:9042> due to protocol error: code=000a [Protocol error] message="Invalid or unsupported protocol version: 2"
WARNING:cassandra.cluster:Downgrading core protocol version from 2 to 1 for IP
WARNING:cassandra.metadata:Building table metadata with no column meta for keyspace

With the Java driver, I simply get a NoHostAvailableException: All host(s) tried for query failed connection error if im trying to connect with a protocol version bigger than 1.

This connection problem is causing me a lot of trouble building an appropriate Java DAO. for example, if Im trying to do batch update, e.g.:

BatchStatment batch = new BatchStatement()
batch.add(somePreparedStatement)
cqlSession.executeAsync(batch)

I get the following error:

com.datastax.driver.core.exceptions.UnsupportedFeatureException: Unsupported feature with the native protocol version 1 (which is currently in use): Protocol level batching is not supported

Running a "BEGIN BATCH.." operation directly on a cluster node using cqlsh works, So I know this CQL command can be executed, but I dont know how to prepare it in Java and execute it with protocol version 1. Also, the cassandra and CQL version an the cluster seems appropriate:

[cqlsh 3.1.7 | Cassandra 1.2.13.2 | CQL spec 3.0.0 | Thrift protocol 19.36.2]

So, questions are:

  1. Why is this happening?
  2. Can I connect to that keyspace with a protocol version greater than 1?
  3. If not, Can I somehow bypass this batch update problem?
2
  • Does this work on a brand new keyspace? What Cassandra version are you using?
    – phact
    Aug 9, 2015 at 15:56
  • Im using Cassandra 1.2.13.2. Ill try the code on a brad new keyspace and let you know..
    – idoda
    Aug 10, 2015 at 7:20

1 Answer 1

0

The answer for this issue was eventually found here:

Can I combine Batches and PreparedStatements?

Starting with Cassandra 2.0 and the corresponding versions of the C#, Java, and Python drivers, PreparedStatements can be used in batch operations (nb before that you could still prepare a complete batch operation, but you’d need to know apriori the number of statements that will be included).

Since my Cassandra version is 1.2xx, I cant use batch updates and prepared statements.

A work around is to create the query as a string (Ya, that's dirty) and than execute the string query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.