diff --git a/src/java/org/apache/cassandra/config/Config.java b/src/java/org/apache/cassandra/config/Config.java index 1efcb9ea66..4f96c5dfd8 100644 --- a/src/java/org/apache/cassandra/config/Config.java +++ b/src/java/org/apache/cassandra/config/Config.java @@ -92,6 +92,7 @@ public class Config public Integer allocate_tokens_for_local_replication_factor = null; public boolean skip_bootstrap_streaming = false; + public String replace_address_first_boot = null; public long native_transport_idle_timeout_in_ms = 0L; diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java index 34cdaece46..32e6998a49 100644 --- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java +++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java @@ -1571,6 +1571,8 @@ public static InetAddressAndPort getReplaceAddress() return InetAddressAndPort.getByName(System.getProperty(Config.PROPERTY_PREFIX + "replace_address", null)); else if (System.getProperty(Config.PROPERTY_PREFIX + "replace_address_first_boot", null) != null) return InetAddressAndPort.getByName(System.getProperty(Config.PROPERTY_PREFIX + "replace_address_first_boot", null)); + else if (conf.replace_address_first_boot != null) + return InetAddressAndPort.getByName(conf.replace_address_first_boot); return null; } catch (UnknownHostException e) @@ -1584,6 +1586,11 @@ public static boolean skipBootstrapStreaming() return conf.skip_bootstrap_streaming; } + public static boolean replaceOnFirstBootRequested() + { + return System.getProperty("cassandra.replace_address_first_boot", null) != null || conf.replace_address_first_boot != null; + } + public static Collection getReplaceTokens() { return tokensFromString(System.getProperty(Config.PROPERTY_PREFIX + "replace_token", null)); diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java index 997ee4a143..62182adcb4 100644 --- a/src/java/org/apache/cassandra/service/StorageService.java +++ b/src/java/org/apache/cassandra/service/StorageService.java @@ -931,7 +931,7 @@ private void populatePeerTokenMetadata() private boolean isReplacing() { - if (System.getProperty("cassandra.replace_address_first_boot", null) != null && SystemKeyspace.bootstrapComplete()) + if (DatabaseDescriptor.replaceOnFirstBootRequested() && SystemKeyspace.bootstrapComplete()) { logger.info("Replace address on first boot requested; this node is already bootstrapped"); return false;