简体   繁体   English

Assanax中的Cassandra CQL3支持

[英]Cassandra CQL3 support in Astyanax

Does Astyanax support "insert into" via prepared statement with CQL3? Astyanax是否通过CQL3准备好的声明支持“插入”? I use the latest Astyanax library 1.56.24 and Cassandra 1.2.1. 我使用最新的Astyanax库1.56.24和Cassandra 1.2.1。 When I try to execute a prepared statement with CQL3: 当我尝试使用CQL3执行预准备语句时:

keyspace.prepareQuery(conn.CF_CONTACTS)
  .withCql("INSERT INTO contacts (a, b) VALUES (?, ?);")
  .asPreparedStatement()
  .withStringValue("123")
  .withStringValue("456")
  .execute();;

I get the following exception: 我得到以下异常:

Caused by: InvalidRequestException(why:Cannot execute/prepare CQL2 statement since the CQL has been set to CQL3(This might mean your client hasn't been upgraded correctly to use the new CQL3 methods introduced in Cassandra 1.2+).)
at org.apache.cassandra.thrift.Cassandra$prepare_cql_query_result.read(Cassandra.java:38738)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
at org.apache.cassandra.thrift.Cassandra$Client.recv_prepare_cql_query(Cassandra.java:1598)
at org.apache.cassandra.thrift.Cassandra$Client.prepare_cql_query(Cassandra.java:1584)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$6$3$1.internalExecute(ThriftColumnFamilyQueryImpl.java:747)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$6$3$1.internalExecute(ThriftColumnFamilyQueryImpl.java:742)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:56)

I got this working using Astyanax 1.56.31 . 我使用Astyanax 1.56.31了这项工作。 You need to set the following in your AstyanaxConfigurationImpl instance: 您需要在AstyanaxConfigurationImpl实例中设置以下内容:

.setTargetCassandraVersion("1.2")
.setCqlVersion("3.0.0")

This is because a change in cassandra client to notifies high-level client apps that are using CQL3 implementation improperly. 这是因为cassandra客户端的更改通知不正确地使用CQL3实现的高级客户端应用程序。 See https://issues.apache.org/jira/browse/CASSANDRA-5172 请参阅https://issues.apache.org/jira/browse/CASSANDRA-5172

It seems that Astyanax either did not upgrade to this version of the cassandra client or they did not document the I'm currently looking myself for a solution at this moment. 似乎Astyanax没有升级到这个版本的cassandra客户端,或者他们没有记录我目前正在寻找自己的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM