private static void checkOneDatacenter(CassandraKeyValueServiceConfig config, Set<String> datacenters) { if (datacenters.size() > 1) { logErrorOrThrow(SIMPLE_PARTITIONING_ERROR_MSG, config.ignoreNodeTopologyChecks()); } }
private static KsDef setNetworkStrategyIfCheckedTopology(KsDef ksDef, CassandraKeyValueServiceConfig config, Set<String> datacenters) { if (!config.ignoreNodeTopologyChecks()) { ksDef.setStrategy_class(CassandraConstants.NETWORK_STRATEGY); ksDef.setStrategy_options(ImmutableMap.of(Iterables.getOnlyElement(datacenters), "1")); } return ksDef; }
private static void checkNodeTopologyIsSet(CassandraKeyValueServiceConfig config, Multimap<String, String> dcRack) { if (clusterHasExactlyOneRack(dcRack)) { String datacenter = Iterables.getOnlyElement(dcRack.keySet()); String rack = Iterables.getOnlyElement(dcRack.values()); if (datacenter.equals(CassandraConstants.DEFAULT_DC) && rack.equals(CassandraConstants.DEFAULT_RACK)) { logErrorOrThrow("The cassandra cluster is not set up to be datacenter and rack aware. Please set up " + "Cassandra to use NetworkTopology and add corresponding snitch information " + "before running with a replication factor higher than 1. " + "If you're running in some sort of environment where nodes have no known correlated " + "failure patterns, you can set the 'ignoreNodeTopologyChecks' KVS config option.", config.ignoreNodeTopologyChecks()); } } }
private static void checkKsDefRfEqualsOne(KsDef ks, CassandraKeyValueServiceConfig config) { int currentRf = Integer.parseInt(ks.getStrategy_options().get(CassandraConstants.REPLICATION_FACTOR_OPTION)); if (currentRf != 1) { logErrorOrThrow(SIMPLE_PARTITIONING_ERROR_MSG, config.ignoreNodeTopologyChecks()); } }
private static void checkMoreRacksThanRfOrFewerHostsThanRf(CassandraKeyValueServiceConfig config, Set<String> hosts, Multimap<String, String> dcRack) { if (dcRack.values().size() < config.replicationFactor() && hosts.size() > config.replicationFactor()) { logErrorOrThrow("The cassandra cluster only has one DC, " + "and is set up with less racks than the desired number of replicas, " + "and there are more hosts than the replication factor. " + "It is very likely that your rack configuration is incorrect and replicas " + "would not be placed correctly for the failure tolerance you want. " + "If you fully understand how NetworkTopology replica placement strategy will be placing " + "your replicas, feel free to set the 'ignoreNodeTopologyChecks' KVS config option.", config.ignoreNodeTopologyChecks()); } }
@Test public void returnSameKsDefIfNodeTopologyChecksIgnored() throws TException { setTopology(createDetails(DC_1, RACK_1, HOST_1)); when(config.replicationFactor()).thenReturn(7); when(config.ignoreNodeTopologyChecks()).thenReturn(true); KsDef ksDef = new KsDef("test", CassandraConstants.SIMPLE_STRATEGY, ImmutableList.of()); ImmutableMap<String, String> strategyOptions = ImmutableMap .of(CassandraConstants.REPLICATION_FACTOR_OPTION, "1", DC_1, "7"); ksDef.setStrategy_options(strategyOptions); ksDef = CassandraVerifier.checkAndSetReplicationFactor(client, ksDef, config); assertThat(ksDef.strategy_class).isEqualTo(CassandraConstants.SIMPLE_STRATEGY); assertThat(ksDef.strategy_options).isEqualTo(strategyOptions); }
private static void checkOneDatacenter(CassandraKeyValueServiceConfig config, Set<String> datacenters) { if (datacenters.size() > 1) { logErrorOrThrow(SIMPLE_PARTITIONING_ERROR_MSG, config.ignoreNodeTopologyChecks()); } }
private static void checkNodeTopologyIsSet(CassandraKeyValueServiceConfig config, Multimap<String, String> dcRack) { if (clusterHasExactlyOneRack(dcRack)) { String datacenter = Iterables.getOnlyElement(dcRack.keySet()); String rack = Iterables.getOnlyElement(dcRack.values()); if (datacenter.equals(CassandraConstants.DEFAULT_DC) && rack.equals(CassandraConstants.DEFAULT_RACK)) { logErrorOrThrow("The cassandra cluster is not set up to be datacenter and rack aware. Please set up " + "Cassandra to use NetworkTopology and add corresponding snitch information " + "before running with a replication factor higher than 1. " + "If you're running in some sort of environment where nodes have no known correlated " + "failure patterns, you can set the 'ignoreNodeTopologyChecks' KVS config option.", config.ignoreNodeTopologyChecks()); } } }
private static KsDef setNetworkStrategyIfCheckedTopology(KsDef ksDef, CassandraKeyValueServiceConfig config, Set<String> datacenters) { if (!config.ignoreNodeTopologyChecks()) { ksDef.setStrategy_class(CassandraConstants.NETWORK_STRATEGY); ksDef.setStrategy_options(ImmutableMap.of(Iterables.getOnlyElement(datacenters), "1")); } return ksDef; }
private static void checkKsDefRfEqualsOne(KsDef ks, CassandraKeyValueServiceConfig config) { int currentRf = Integer.parseInt(ks.getStrategy_options().get(CassandraConstants.REPLICATION_FACTOR_OPTION)); if (currentRf != 1) { logErrorOrThrow(SIMPLE_PARTITIONING_ERROR_MSG, config.ignoreNodeTopologyChecks()); } }
private static void checkMoreRacksThanRfOrFewerHostsThanRf(CassandraKeyValueServiceConfig config, Set<String> hosts, Multimap<String, String> dcRack) { if (dcRack.values().size() < config.replicationFactor() && hosts.size() > config.replicationFactor()) { logErrorOrThrow("The cassandra cluster only has one DC, " + "and is set up with less racks than the desired number of replicas, " + "and there are more hosts than the replication factor. " + "It is very likely that your rack configuration is incorrect and replicas " + "would not be placed correctly for the failure tolerance you want. " + "If you fully understand how NetworkTopology replica placement strategy will be placing " + "your replicas, feel free to set the 'ignoreNodeTopologyChecks' KVS config option.", config.ignoreNodeTopologyChecks()); } }