private String getCreateKeyspaceStatement() { return SchemaBuilder.createKeyspace(config.getCassandraKeyspace()) .ifNotExists() .with() .replication(ImmutableMap.of("class", config.getReplicationStrategy(), config.getReplicationFactorKey(), config.getReplicationFactorValue())) .durableWrites(true) .getQueryString(); }
@Test(groups = "unit") public void should_alter_keyspace_with_options() throws Exception { Map<String, Object> replicationOptions = new HashMap<String, Object>(); replicationOptions.put("class", "SimpleStrategy"); replicationOptions.put("replication_factor", 1); // When SchemaStatement statement = alterKeyspace("test").with().durableWrites(true).replication(replicationOptions); // Then assertThat(statement.getQueryString()) .isEqualTo( "\n\tALTER KEYSPACE test" + "\n\tWITH\n\t\t" + "REPLICATION = {'replication_factor': 1, 'class': 'SimpleStrategy'}\n\t\t" + "AND DURABLE_WRITES = true"); }
@Test(groups = "unit") public void should_create_keyspace_with_options() throws Exception { Map<String, Object> replicationOptions = new HashMap<String, Object>(); replicationOptions.put("class", "SimpleStrategy"); replicationOptions.put("replication_factor", 1); // When SchemaStatement statement = createKeyspace("test").with().durableWrites(true).replication(replicationOptions); // Then assertThat(statement.getQueryString()) .isEqualTo( "\n\tCREATE KEYSPACE test" + "\n\tWITH\n\t\t" + "REPLICATION = {'replication_factor': 1, 'class': 'SimpleStrategy'}\n\t\t" + "AND DURABLE_WRITES = true"); }
public void initKeyspace() { // TODO consider exposing important keyspace options through commandline // such as understanding how to properly enable cassandra in production // - with data centers and snitch, for now because this is only creating // a keyspace "if not exists" a user can create a keyspace matching // their geowave namespace with any settings they want manually session.execute( SchemaBuilder.createKeyspace(gwNamespace).ifNotExists().with().replication( ImmutableMap.of( "class", "SimpleStrategy", "replication_factor", options.getReplicationFactor())).durableWrites(options.isDurableWrites())); }
@Test(groups = "unit") public void should_create_keyspace_with_options() throws Exception { Map<String, Object> replicationOptions = new HashMap<String, Object>(); replicationOptions.put("class", "SimpleStrategy"); replicationOptions.put("replication_factor", 1); // When SchemaStatement statement = createKeyspace("test").with().durableWrites(true).replication(replicationOptions); // Then assertThat(statement.getQueryString()) .isEqualTo( "\n\tCREATE KEYSPACE test" + "\n\tWITH\n\t\t" + "REPLICATION = {'replication_factor': 1, 'class': 'SimpleStrategy'}\n\t\t" + "AND DURABLE_WRITES = true"); }
@Test(groups = "unit") public void should_alter_keyspace_with_options() throws Exception { Map<String, Object> replicationOptions = new HashMap<String, Object>(); replicationOptions.put("class", "SimpleStrategy"); replicationOptions.put("replication_factor", 1); // When SchemaStatement statement = alterKeyspace("test").with().durableWrites(true).replication(replicationOptions); // Then assertThat(statement.getQueryString()) .isEqualTo( "\n\tALTER KEYSPACE test" + "\n\tWITH\n\t\t" + "REPLICATION = {'replication_factor': 1, 'class': 'SimpleStrategy'}\n\t\t" + "AND DURABLE_WRITES = true"); }