我没有设法执行应该更新SimpleStrategy密钥空间的复制因子的cql语句。这很麻烦,因为这适用于所有三个版本的CQLSH。
我正在使用的键空间上下文设置为使用cqlv3
.setCqlVersion("3.0.0")
cql:
"ALTER KEYSPACE \"" + ksContext.getKeyspaceName() + "\" WITH REPLICATION = { " +
"'class' : 'SimpleStrategy', 'replication_factor' : 3 };";
堆栈追踪:
InvalidRequestException(why:line 1:108 no viable alternative at character '}')
at com.netflix.astyanax.thrift.ThriftConverter.ToConnectionPoolException(ThriftConverter.java:159)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:60)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:27)
at com.netflix.astyanax.thrift.ThriftSyncConnectionFactoryImpl$1.execute(ThriftSyncConnectionFactoryImpl.java:140)
at com.netflix.astyanax.connectionpool.impl.AbstractExecuteWithFailoverImpl.tryOperation(AbstractExecuteWithFailoverImpl.java:69)
at com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool.executeWithFailover(AbstractHostPartitionConnectionPool.java:255)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$6.execute(ThriftColumnFamilyQueryImpl.java:694)
at smail.cli.astyanax.Astyanax.execCQL(Astyanax.java:75)
at smail.cli.astyanax.Astyanax.alterReplicationFactor(Astyanax.java:307)
at smail.cli.test.SchemaTest.alterReplicationFactor(SchemaTest.java:25)
at smail.cli.test.TestSuite.runTests(TestSuite.java:39)
at smail.cli.Main.main(Main.java:22)
答案 0 :(得分:2)
Astyanax确实在cql3方面遇到了一些问题,但它取得了很大进展。创建一个新的密钥空间并使用CQLv2(通过在上下文中设置它)并在没有"
引号的情况下尝试它:
String query = "ALTER KEYSPACE " + keyspaceName + " WITH REPLICATION = {
'class' : 'SimpleStrategy', 'replication_factor' : 2 };";
注意* 在此查询中,您要将重复因子更新为 2 。