Updated the CreateKeyspaceCqlGenerator to add a default simple

replication with a replication factor of 1. Also add the durable_write
default.
This commit is contained in:
john-mcpeek
2014-02-03 22:32:06 -05:00
parent df990d2c14
commit f84afa7982

View File

@@ -19,7 +19,9 @@ import static org.springframework.cassandra.core.cql.CqlStringUtils.noNull;
import java.util.Map;
import org.springframework.cassandra.config.KeyspaceAttributes;
import org.springframework.cassandra.core.keyspace.CreateKeyspaceSpecification;
import org.springframework.cassandra.core.keyspace.KeyspaceOption;
import org.springframework.cassandra.core.keyspace.Option;
/**
@@ -60,6 +62,17 @@ public class CreateKeyspaceCqlGenerator extends KeyspaceCqlGenerator<CreateKeysp
// begin options clause
Map<String, Object> options = spec().getOptions();
Object replicationOption = options.get(KeyspaceOption.REPLICATION.getName());
if (replicationOption == null) {
Map<Option, Object> simpleReplicationMap = KeyspaceAttributes.newSimpleReplication();
spec().with(KeyspaceOption.REPLICATION, simpleReplicationMap);
}
Object durableWrites = options.get(KeyspaceOption.DURABLE_WRITES.getName());
if (durableWrites == null) {
spec().with(KeyspaceOption.DURABLE_WRITES, Boolean.TRUE);
}
if (!options.isEmpty()) {
// option preamble