Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 一致性级别ALL used while语句定义了一致性级别2_Java_Cassandra_Datastax Java Driver_Cassandra 2.1 - Fatal编程技术网

Java 一致性级别ALL used while语句定义了一致性级别2

Java 一致性级别ALL used while语句定义了一致性级别2,java,cassandra,datastax-java-driver,cassandra-2.1,Java,Cassandra,Datastax Java Driver,Cassandra 2.1,我们使用java datastax cassandra驱动程序2.1.2。我们使用的卡桑德拉版本是2.0.9 我们有一个用QueryBuilder构建的语句,我们正在显式地将TWO上的语句设置为一致性级别 Select selectStatement = QueryBuilder.select().from(ARTICLES); selectStatement.where(eq(ORGANIZATION_ID, organizationId)); selectStatement.setCons

我们使用java datastax cassandra驱动程序
2.1.2
。我们使用的卡桑德拉版本是
2.0.9

我们有一个用
QueryBuilder
构建的语句,我们正在显式地将
TWO
上的语句设置为一致性级别

Select selectStatement =  QueryBuilder.select().from(ARTICLES);
selectStatement.where(eq(ORGANIZATION_ID, organizationId));
selectStatement.setConsistencyLevel(ConsistencyLevel.TWO);

final ResultSet rs = session.execute(selectStatement);
//call to all() will be removed since it is enough to iterate over result set 
//and then you get pagination for free instead of loading everything in 
//memory
List<Row> rows = rs.all();  
for (final Row row : rows) {
   //do something with Row, convert to POJO
}
我知道在
ResultSet
上调用
all()
会使它加载内存中组织的所有文章,并使用它,并在cassandra上创建加载。如注释中所述,这将被删除。这可能导致读取超时,但我仍然不明白为什么在异常消息中有
ALL


问题是为什么异常告诉我们,当我们将原始语句的一致性级别设置为
TWO
时,会使用一致性级别
ALL
。默认情况下,
all()
是否在内部处理查询并使用CL
all
。您看到一条错误消息,原因是无法执行读取修复。它与您的原始一致性级别无关。这在2.1.3+中已修复。

您正在运行哪个版本的o c*?我们正在使用Cassandra 2.0.9感谢您的回答和解释,我将增加驱动程序版本并尝试。您必须升级Cassandra,而不是驱动程序。查看jira ptnapoleon张贴的^^
com.datastax.driver.core.exceptions.ReadTimeoutException: Cassandra timeout during read query at consistency ALL (3 responses were required but only 2 replica responded)
com.datastax.driver.core.exceptions.ReadTimeoutException.copy (ReadTimeoutException.java:69)
com.datastax.driver.core.DefaultResultSetFuture.extractCauseFromExecutionException (DefaultResultSetFuture.java:259)
com.datastax.driver.core.ArrayBackedResultSet$MultiPage.prepareNextRow (ArrayBackedResultSet.java:279)
com.datastax.driver.core.ArrayBackedResultSet$MultiPage.isExhausted (ArrayBackedResultSet.java:239)
com.datastax.driver.core.ArrayBackedResultSet$1.hasNext (ArrayBackedResultSet.java:122)
com.datastax.driver.core.ArrayBackedResultSet.all (ArrayBackedResultSet.java:111)