2

我无法执行应该更新 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)
4

1 回答 1

2

Astyanax 在 cql3 方面确实存在一些问题,但它取得了很大进展。创建一个新的键空间并使用 CQLv2(通过在上下文中设置它)并尝试不带"引号:

String query = "ALTER KEYSPACE " + keyspaceName + " WITH REPLICATION = { 
               'class' : 'SimpleStrategy', 'replication_factor' : 2 };";

注意*在此查询中,您将 rep 因子更新为2

于 2013-03-02T17:30:58.637 回答