@Test public void nonDefaultDcAndHighRfSucceeds() throws TException { setTopology(createDetails(DC_1, RACK_1, HOST_1)); when(config.replicationFactor()).thenReturn(3); assertThat(CassandraVerifier.sanityCheckDatacenters(client, config)) .containsExactly(DC_1); }
static Set<String> sanityCheckDatacenters(CassandraClient client, CassandraKeyValueServiceConfig config) throws TException { createSimpleRfTestKeyspaceIfNotExists(client); Multimap<String, String> datacenterToRack = HashMultimap.create(); Set<String> hosts = Sets.newHashSet(); for (TokenRange tokenRange : client.describe_ring(CassandraConstants.SIMPLE_RF_TEST_KEYSPACE)) { for (EndpointDetails details : tokenRange.getEndpoint_details()) { datacenterToRack.put(details.datacenter, details.rack); hosts.add(details.host); } } if (clusterHasExactlyOneDatacenter(datacenterToRack) && config.replicationFactor() > 1) { checkNodeTopologyIsSet(config, datacenterToRack); checkMoreRacksThanRfOrFewerHostsThanRf(config, hosts, datacenterToRack); } return datacenterToRack.keySet(); }
CassandraVerifier { static Set<String> sanityCheckDatacenters(CassandraClient client, CassandraKeyValueServiceConfig config) throws TException { createSimpleRfTestKeyspaceIfNotExists(client); Multimap<String, String> datacenterToRack = HashMultimap.create(); Set<String> hosts = Sets.newHashSet(); for (TokenRange tokenRange : client.describe_ring(CassandraConstants.SIMPLE_RF_TEST_KEYSPACE)) { for (EndpointDetails details : tokenRange.getEndpoint_details()) { datacenterToRack.put(details.datacenter, details.rack); hosts.add(details.host); } } if (clusterHasExactlyOneDatacenter(datacenterToRack) && config.replicationFactor() > 1) { checkNodeTopologyIsSet(config, datacenterToRack); checkMoreRacksThanRfOrFewerHostsThanRf(config, hosts, datacenterToRack); } return datacenterToRack.keySet(); } }
CassandraVerifier { static Set<String> sanityCheckDatacenters(CassandraClient client, CassandraKeyValueServiceConfig config) throws TException { createSimpleRfTestKeyspaceIfNotExists(client); Multimap<String, String> datacenterToRack = HashMultimap.create(); Set<String> hosts = Sets.newHashSet(); for (TokenRange tokenRange : client.describe_ring(CassandraConstants.SIMPLE_RF_TEST_KEYSPACE)) { for (EndpointDetails details : tokenRange.getEndpoint_details()) { datacenterToRack.put(details.datacenter, details.rack); hosts.add(details.host); } } if (clusterHasExactlyOneDatacenter(datacenterToRack) && config.replicationFactor() > 1) { checkNodeTopologyIsSet(config, datacenterToRack); checkMoreRacksThanRfOrFewerHostsThanRf(config, hosts, datacenterToRack); } return datacenterToRack.keySet(); } private  CassandraVerifier(); }
CassandraVerifier { static Set<String> sanityCheckDatacenters(CassandraClient client, CassandraKeyValueServiceConfig config) throws TException { createSimpleRfTestKeyspaceIfNotExists(client); Multimap<String, String> datacenterToRack = HashMultimap.create(); Set<String> hosts = Sets.newHashSet(); for (TokenRange tokenRange : client.describe_ring(CassandraConstants.SIMPLE_RF_TEST_KEYSPACE)) { for (EndpointDetails details : tokenRange.getEndpoint_details()) { datacenterToRack.put(details.datacenter, details.rack); hosts.add(details.host); } } if (clusterHasExactlyOneDatacenter(datacenterToRack) && config.replicationFactor() > 1) { checkNodeTopologyIsSet(config, datacenterToRack); checkMoreRacksThanRfOrFewerHostsThanRf(config, hosts, datacenterToRack); } return datacenterToRack.keySet(); } private  CassandraVerifier();  }
CassandraVerifier { static Set<String> sanityCheckDatacenters(CassandraClient client, CassandraKeyValueServiceConfig config) throws TException { createSimpleRfTestKeyspaceIfNotExists(client); Multimap<String, String> datacenterToRack = HashMultimap.create(); Set<String> hosts = Sets.newHashSet(); for (TokenRange tokenRange : client.describe_ring(CassandraConstants.SIMPLE_RF_TEST_KEYSPACE)) { for (EndpointDetails details : tokenRange.getEndpoint_details()) { datacenterToRack.put(details.datacenter, details.rack); hosts.add(details.host); } } if (clusterHasExactlyOneDatacenter(datacenterToRack) && config.replicationFactor() > 1) { checkNodeTopologyIsSet(config, datacenterToRack); checkMoreRacksThanRfOrFewerHostsThanRf(config, hosts, datacenterToRack); } return datacenterToRack.keySet(); } private  CassandraVerifier();   }