static void currentRfOnKeyspaceMatchesDesiredRf(CassandraClient client, CassandraKeyValueServiceConfig config) throws TException { KsDef ks = client.describe_keyspace(config.getKeyspaceOrThrow()); Set<String> dcs = sanityCheckDatacenters(client, config); sanityCheckReplicationFactor(ks, config, dcs); }
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; }
@Test public void noStrategyForDcThrows() { KsDef ksDef = new KsDef("test", CassandraConstants.SIMPLE_STRATEGY, ImmutableList.of()); ksDef.setStrategy_options(ImmutableMap.of(DC_1, "1")); assertThatThrownBy(() -> CassandraVerifier.sanityCheckReplicationFactor(ksDef, config, ImmutableSet.of(DC_1, DC_2))) .isInstanceOf(IllegalStateException.class); }
@Test public void differentRfThanConfigThrows() { KsDef ksDef = new KsDef("test", CassandraConstants.SIMPLE_STRATEGY, ImmutableList.of()); ksDef.setStrategy_options(ImmutableMap.of(DC_1, "1", DC_2, "2")); when(config.replicationFactor()).thenReturn(1); assertThatThrownBy(() -> CassandraVerifier.sanityCheckReplicationFactor(ksDef, config, ImmutableSortedSet.of(DC_1, DC_2))) .isInstanceOf(UnsupportedOperationException.class); }
static void currentRfOnKeyspaceMatchesDesiredRf(CassandraClient client, CassandraKeyValueServiceConfig config) throws TException { KsDef ks = client.describe_keyspace(config.getKeyspaceOrThrow()); Set<String> dcs = sanityCheckDatacenters(client, config); sanityCheckReplicationFactor(ks, config, dcs); }
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; }