String createKeyspace = CQLTranslator.CREATE_KEYSPACE;
String placement_strategy = csmd.getPlacement_strategy(databaseName);
String replication_conf = CQLTranslator.SIMPLE_REPLICATION;
createKeyspace = createKeyspace.replace("$KEYSPACE", "\"" + databaseName + "\"");
Schema schema = CassandraPropertyReader.csmd.getSchema(databaseName);
if (schema != null && schema.getName() != null && schema.getName().equalsIgnoreCase(databaseName)
&& schema.getSchemaProperties() != null)
{
Properties schemaProperties = schema.getSchemaProperties();
if (placement_strategy.equalsIgnoreCase(SimpleStrategy.class.getSimpleName())
|| placement_strategy.equalsIgnoreCase(SimpleStrategy.class.getName()))
{
String replicationFactor = schemaProperties.getProperty(CassandraConstants.REPLICATION_FACTOR,
CassandraConstants.DEFAULT_REPLICATION_FACTOR);
replication_conf = replication_conf.replace("$REPLICATION_FACTOR", replicationFactor);
createKeyspace = createKeyspace.replace("$CLASS", placement_strategy);
}
else if (placement_strategy.equalsIgnoreCase(NetworkTopologyStrategy.class.getSimpleName())
|| placement_strategy.equalsIgnoreCase(NetworkTopologyStrategy.class.getName()))
{
if (schema.getDataCenters() != null && !schema.getDataCenters().isEmpty())
{
StringBuilder builder = new StringBuilder();
for (DataCenter dc : schema.getDataCenters())
{
builder.append(CQLTranslator.QUOTE_STR);
builder.append(dc.getName());
builder.append(":");
builder.append(dc.getValue());