我将 Cassandra 1.2.6 与 Astyanax 一起使用。我使用 Java 创建了一个名为 DummyKeyspace 的键空间。我可以从cassandra-cli
但不能从cqlsh
. 为什么?
这是我的Java代码:
public void createKeyspace(Cluster cluster,String KEYSPACE_NAME,String STRATEGY, String REPLICA_FACTOR) throws ConnectionException
{
if(cluster.describeKeyspace(KEYSPACE_NAME) == null)
{
KeyspaceDefinition ksDef = cluster.makeKeyspaceDefinition();
Map<String,String> stratOptions = new HashMap<String,String>();
stratOptions.put("replication_factor", REPLICA_FACTOR);
ksDef.setName(KEYSPACE_NAME)
.setStrategyOptions(stratOptions)
.setStrategyClass(STRATEGY);
cluster.addKeyspace(ksDef);
System.out.println("Keyspace " + KEYSPACE_NAME + " created and added to cluster.");
}
else
{
System.out.println("Keyspace " + KEYSPACE_NAME + " already existed.");
}
}
这是我尝试到达它时的错误:
cqlsh> USE DummyKeyspace;
Bad Request: Keyspace 'dummykeyspace' does not exist