Question

I'm not managing to execute a cql statement that should update the replication factor of a SimpleStrategy keyspace. It's annoying because this works fine with all three versions of CQLSH.

The keyspace context i'm using is set to use cqlv3 .setCqlVersion("3.0.0")

The cql:

"ALTER KEYSPACE \"" + ksContext.getKeyspaceName() + "\" WITH REPLICATION = { " + 
            "'class' : 'SimpleStrategy', 'replication_factor' : 3 };";

Stack trace:

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)
Was it helpful?

Solution

Astyanax does have some problems with cql3 but its making great progress. Create a new keyspace and use CQLv2 (by setting it in the context) and try it without the " quotes:

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

Note* in this query you are updating the rep factor to be 2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top