From f84afa7982530db6fa7da8eeecf840d7fc3bb181 Mon Sep 17 00:00:00 2001 From: john-mcpeek Date: Mon, 3 Feb 2014 22:32:06 -0500 Subject: [PATCH] Updated the CreateKeyspaceCqlGenerator to add a default simple replication with a replication factor of 1. Also add the durable_write default. --- .../cql/generator/CreateKeyspaceCqlGenerator.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spring-cassandra/src/main/java/org/springframework/cassandra/core/cql/generator/CreateKeyspaceCqlGenerator.java b/spring-cassandra/src/main/java/org/springframework/cassandra/core/cql/generator/CreateKeyspaceCqlGenerator.java index d0aa5c22b..27543b8cc 100644 --- a/spring-cassandra/src/main/java/org/springframework/cassandra/core/cql/generator/CreateKeyspaceCqlGenerator.java +++ b/spring-cassandra/src/main/java/org/springframework/cassandra/core/cql/generator/CreateKeyspaceCqlGenerator.java @@ -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 options = spec().getOptions(); + Object replicationOption = options.get(KeyspaceOption.REPLICATION.getName()); + if (replicationOption == null) { + Map 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