From f6deca3db2ec173c8d0b2cd33ef2660012ae3f69 Mon Sep 17 00:00:00 2001 From: Marcus Olsson Date: Fri, 4 Dec 2015 14:21:15 -0500 Subject: [PATCH] Disable reloading of GossipingPropertyFileSnitch Patch by molsson; reviewed by pmotta for CASSANDRA-9474 --- CHANGES.txt | 1 + NEWS.txt | 16 +++++++------- .../apache/cassandra/db/SystemKeyspace.java | 21 ++++++++++++++++--- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 1a2887a796..46cda65a98 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.1.13 + * Disable reloading of GossipingPropertyFileSnitch (CASSANDRA-9474) * Fix Stress profile parsing on Windows (CASSANDRA-10808) diff --git a/NEWS.txt b/NEWS.txt index cae8dfb387..7a15d0245e 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -24,20 +24,18 @@ New features - DTCS option max_sstable_age_days is now deprecated and defaults to 1000 days. - Native protocol server now allows both SSL and non-SSL connections on the same port. - - Switching racks is no longer an allowed operation on a node which has - data. Instead, the node will need to be decommissioned and rebootstrapped. - If moving from the SimpleSnitch, make sure the rack containing all current - nodes is named "rack1". To override this behavior when manually wiping - the node and bootstrapping, use -Dcassandra.ignore_rack=true. - a new validate(key, cf) method is added to PerRowSecondaryIndex. A default implementation is provided, so no changes are required to custom implementations. Operations ------------ - - Changing rack or dc of live nodes is no longer possible for PropertyFileSnitch - and YamlFileNetworkTopologySnitch. Reloading the configuration file of - GossipingPropertyFileSnitch has been disabled, CASSANDRA-10243. - + - Switching data center or racks is no longer an allowed operation on a node + which has data. Instead, the node will need to be decommissioned and + rebootstrapped. If moving from the SimpleSnitch, make sure that the data + center and rack containing all current nodes is named "datacenter1" and + "rack1". To override this behaviour use -Dcassandra.ignore_rack=true and/or + -Dcassandra.ignore_dc=true. + - Reloading the configuration file of GossipingPropertyFileSnitch has been disabled. 2.1.11 ===== diff --git a/src/java/org/apache/cassandra/db/SystemKeyspace.java b/src/java/org/apache/cassandra/db/SystemKeyspace.java index c600652105..1f66b1b7b3 100644 --- a/src/java/org/apache/cassandra/db/SystemKeyspace.java +++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java @@ -614,11 +614,26 @@ public class SystemKeyspace } } + String req = "SELECT rack, data_center FROM system.%s WHERE key='%s'"; + UntypedResultSet result = executeInternal(String.format(req, LOCAL_CF, LOCAL_KEY)); + + if (!Boolean.getBoolean("cassandra.ignore_dc")) + { + // Look up the dc (return it if found) + if (!result.isEmpty() && result.one().has("data_center")) + { + String storedDc = result.one().getString("data_center"); + String currentDc = DatabaseDescriptor.getEndpointSnitch().getDatacenter(FBUtilities.getBroadcastAddress()); + if (!storedDc.equals(currentDc)) + { + throw new ConfigurationException("Cannot start node if snitch's data center (" + currentDc + ") differs from previous data center (" + storedDc + "). " + + "Please fix the snitch configuration, decommission and rebootstrap this node or use the flag -Dcassandra.ignore_dc=true."); + } + } + } + if (!Boolean.getBoolean("cassandra.ignore_rack")) { - String req = "SELECT rack FROM system.%s WHERE key='%s'"; - UntypedResultSet result = executeInternal(String.format(req, LOCAL_CF, LOCAL_KEY)); - // Look up the Rack (return it if found) if (!result.isEmpty() && result.one().has("rack")) {