From 29a89d818a8befa95408e7c6c0a1347e107c3a26 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 12 Jun 2014 14:41:52 -0500 Subject: [PATCH] Add replace_address_first_boot flag to only replace if not bootstrapped. Patch by brandonwilliams, reviewed by thobbs for CASSANDRA-7356 --- CHANGES.txt | 1 + .../apache/cassandra/config/DatabaseDescriptor.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index dd58ff9dc9..f37eda4f11 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 1.2.17 + * Add replace_address_first_boot flag to only replace if not bootstrapped (CASSANDRA-7356) * Enable keepalive for native protocol (CASSANDRA-7380) * Check internal addresses for seeds (CASSANDRA-6523) * Fix potential / by 0 in HHOM page size calculation (CASSANDRA-7354) diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java index 3ed82f53fb..3c58b57780 100644 --- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java +++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java @@ -744,8 +744,9 @@ public class DatabaseDescriptor { if (System.getProperty("cassandra.replace_address", null) != null) return InetAddress.getByName(System.getProperty("cassandra.replace_address", null)); - else - return null; + else if (System.getProperty("cassandra.replace_address_first_boot", null) != null) + return InetAddress.getByName(System.getProperty("cassandra.replace_address_first_boot", null)); + return null; } catch (UnknownHostException e) { @@ -771,6 +772,13 @@ public class DatabaseDescriptor public static boolean isReplacing() { + if (System.getProperty("cassandra.replace_address_first_boot", null) != null && SystemTable.bootstrapComplete()) + { + logger.info("Replace address on first boot requested; this node is already bootstrapped"); + return false; + } + if (getReplaceAddress() != null && SystemTable.bootstrapComplete()) + throw new RuntimeException("Cannot replace address with a node that is already bootstrapped"); return getReplaceAddress() != null; }