@Test public void simpleStrategyMultipleDcsThrows() throws TException { setTopology(createDetails(DC_1, RACK_1, HOST_1), createDetails(DC_1, RACK_1, HOST_2), createDetails(DC_1, RACK_1, HOST_3), createDetails(DC_2, RACK_1, HOST_4)); when(config.replicationFactor()).thenReturn(1); KsDef ksDef = new KsDef("test", CassandraConstants.SIMPLE_STRATEGY, ImmutableList.of()); ksDef.setStrategy_options(ImmutableMap.of(CassandraConstants.REPLICATION_FACTOR_OPTION, "1")); assertThatThrownBy(() -> CassandraVerifier.checkAndSetReplicationFactor(client, ksDef, config)) .isInstanceOf(IllegalStateException.class); }
static KsDef checkAndSetReplicationFactor(CassandraClient client, KsDef ksDef, CassandraKeyValueServiceConfig config) throws TException { KsDef result = ksDef; Set<String> datacenters; if (Objects.equals(result.getStrategy_class(), CassandraConstants.SIMPLE_STRATEGY)) { datacenters = getDcForSimpleStrategy(client, result, config); result = setNetworkStrategyIfCheckedTopology(result, config, datacenters); } else { datacenters = sanityCheckDatacenters(client, config); } sanityCheckReplicationFactor(result, config, datacenters); return result; }
CassandraVerifier { static KsDef checkAndSetReplicationFactor(CassandraClient client, KsDef ksDef, CassandraKeyValueServiceConfig config) throws TException { KsDef result = ksDef; Set<String> datacenters; if (Objects.equals(result.getStrategy_class(), CassandraConstants.SIMPLE_STRATEGY)) { datacenters = getDcForSimpleStrategy(client, result, config); result = setNetworkStrategyIfCheckedTopology(result, config, datacenters); } else { datacenters = sanityCheckDatacenters(client, config); } sanityCheckReplicationFactor(result, config, datacenters); return result; } }
CassandraVerifier { static KsDef checkAndSetReplicationFactor(CassandraClient client, KsDef ksDef, CassandraKeyValueServiceConfig config) throws TException { KsDef result = ksDef; Set<String> datacenters; if (Objects.equals(result.getStrategy_class(), CassandraConstants.SIMPLE_STRATEGY)) { datacenters = getDcForSimpleStrategy(client, result, config); result = setNetworkStrategyIfCheckedTopology(result, config, datacenters); } else { datacenters = sanityCheckDatacenters(client, config); } sanityCheckReplicationFactor(result, config, datacenters); return result; } private  CassandraVerifier(); }
CassandraVerifier { static KsDef checkAndSetReplicationFactor(CassandraClient client, KsDef ksDef, CassandraKeyValueServiceConfig config) throws TException { KsDef result = ksDef; Set<String> datacenters; if (Objects.equals(result.getStrategy_class(), CassandraConstants.SIMPLE_STRATEGY)) { datacenters = getDcForSimpleStrategy(client, result, config); result = setNetworkStrategyIfCheckedTopology(result, config, datacenters); } else { datacenters = sanityCheckDatacenters(client, config); } sanityCheckReplicationFactor(result, config, datacenters); return result; } private  CassandraVerifier();  }
CassandraVerifier { static KsDef checkAndSetReplicationFactor(CassandraClient client, KsDef ksDef, CassandraKeyValueServiceConfig config) throws TException { KsDef result = ksDef; Set<String> datacenters; if (Objects.equals(result.getStrategy_class(), CassandraConstants.SIMPLE_STRATEGY)) { datacenters = getDcForSimpleStrategy(client, result, config); result = setNetworkStrategyIfCheckedTopology(result, config, datacenters); } else { datacenters = sanityCheckDatacenters(client, config); } sanityCheckReplicationFactor(result, config, datacenters); return result; } private  CassandraVerifier();   }