}
}
log.info("your keyspace="+keyspaceName+" keyspaces="+keyspaceNames+" exists="+exists);
if(!exists) {
KeyspaceDefinition def = cluster.makeKeyspaceDefinition();
def.setName(keyspaceName);
def.setStrategyClass("org.apache.cassandra.locator.SimpleStrategy");
Map<String, String> map = new HashMap<String, String>();
map.put("replication_factor", "3");
def.setStrategyOptions(map);
if(callback != null)
def = (KeyspaceDefinition) callback.configureKeySpace(keyspaceName, def);
cluster.addKeyspace(def);
log.info("added keyspace="+keyspaceName+" so it now exists");
}
context = builder.buildKeyspace(ThriftFamilyFactory.getInstance());
context.start();
keyspace = context.getClient();
//for some reason, the keyspace is not always created fast enough so sleep 3 seconds and try again
KeyspaceDefinition keySpaceMeta = null;
BadRequestException holdExc = null;
for(int i = 0; i < 3; i++) {
try {
keySpaceMeta = keyspace.describeKeyspace();
} catch(BadRequestException e) {