Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added check for NTS so as not to set strategy options when in use, ad…

…dressing #358
  • Loading branch information...
commit a8d8f97be1fe3bb398ca2297b27c385ef79f5df9 1 parent a2ba363
zznate authored
View
9 core/src/main/java/me/prettyprint/cassandra/service/ThriftKsDef.java
@@ -12,6 +12,7 @@
import org.apache.cassandra.thrift.CfDef;
import org.apache.cassandra.thrift.KsDef;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.apache.commons.lang.math.NumberUtils;
@@ -20,6 +21,7 @@
private static final String REPLICATION_FACTOR = "replication_factor";
public static final String DEF_STRATEGY_CLASS = "org.apache.cassandra.locator.SimpleStrategy";
+ public static final String NETWORK_TOPOLOGY_STRATEGY = "org.apache.cassandra.locator.NetworkTopologyStrategy";
private final String name;
private String strategyClass;
private Map<String, String> strategyOptions = new HashMap<String, String>();
@@ -47,8 +49,8 @@ public ThriftKsDef(String keyspaceName, String strategyClass, int replicationFac
public ThriftKsDef(String keyspaceName) {
this.name = keyspaceName;
this.cfDefs = new ArrayList<ColumnFamilyDefinition>();
- setReplicationFactor(1);
this.strategyClass = DEF_STRATEGY_CLASS;
+ setReplicationFactor(1);
}
public ThriftKsDef(KeyspaceDefinition keyspaceDefinition) {
@@ -119,8 +121,9 @@ public void setStrategyOptions(Map<String, String> strategyOptions) {
}
public void setReplicationFactor(int replicationFactor) {
- // Compensate for CASSANDRA-1263 (wasnt my idea)
- strategyOptions.put(REPLICATION_FACTOR,Integer.toString(replicationFactor));
+ if ( !StringUtils.equals(strategyClass, NETWORK_TOPOLOGY_STRATEGY) ) {
+ strategyOptions.put(REPLICATION_FACTOR,Integer.toString(replicationFactor));
+ }
}
@Override
View
17 core/src/test/java/me/prettyprint/cassandra/service/CassandraClusterTest.java
@@ -1,9 +1,5 @@
package me.prettyprint.cassandra.service;
-import static org.junit.Assert.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.List;
@@ -11,7 +7,7 @@
import me.prettyprint.cassandra.BaseEmbededServerSetupTest;
import me.prettyprint.cassandra.model.BasicColumnDefinition;
import me.prettyprint.cassandra.model.BasicColumnFamilyDefinition;
-import me.prettyprint.cassandra.model.BasicKeyspaceDefinition;
+import me.prettyprint.cassandra.model.BasicKeyspaceDefinition;
import me.prettyprint.cassandra.serializers.StringSerializer;
import me.prettyprint.hector.api.Keyspace;
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition;
@@ -21,14 +17,13 @@
import me.prettyprint.hector.api.factory.HFactory;
import me.prettyprint.hector.api.mutation.Mutator;
import me.prettyprint.hector.api.query.ColumnQuery;
-
import org.apache.cassandra.thrift.NotFoundException;
import org.apache.cassandra.thrift.TokenRange;
import org.apache.thrift.TException;
import org.apache.thrift.transport.TTransportException;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
+import static org.junit.Assert.*;
public class CassandraClusterTest extends BaseEmbededServerSetupTest {
@@ -127,6 +122,14 @@ public void testAddDropKeyspace() throws Exception {
assertNotNull(ksid2);
}
+ @Test
+ public void testAddKeyspaceNTS() throws Exception {
+ ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition("DynKeyspaceNTS", "DynCf");
+ cassandraCluster.addKeyspace(
+ new ThriftKsDef("DynKeyspaceNTS", "org.apache.cassandra.locator.NetworkTopologyStrategy", 1, Arrays.asList(cfDef)));
+
+ }
+
@Test
public void testEditKeyspace() throws Exception {
Please sign in to comment.
Something went wrong with that request. Please try again.