Skip to content

Commit

Permalink
Add replace_address_first_boot to yaml config
Browse files Browse the repository at this point in the history
It's more convenient to set it there in Astacus. Option semantics is
preserved, the value specified in Java properties has priority.
  • Loading branch information
meatlink committed Oct 12, 2023
1 parent d9b7a8c commit 2d95192
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/java/org/apache/cassandra/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public static Set<String> splitCommaDelimited(String src)
public Integer allocate_tokens_for_local_replication_factor = null;

public boolean skip_bootstrap_streaming = false;
public String replace_address_first_boot = null;

@Replaces(oldName = "native_transport_idle_timeout_in_ms", converter = Converters.MILLIS_DURATION_LONG, deprecated = true)
public DurationSpec.LongMillisecondsBound native_transport_idle_timeout = new DurationSpec.LongMillisecondsBound("0ms");
Expand Down
7 changes: 7 additions & 0 deletions src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,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)
Expand All @@ -1745,6 +1747,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<String> getReplaceTokens()
{
return tokensFromString(System.getProperty(Config.PROPERTY_PREFIX + "replace_token", null));
Expand Down
2 changes: 1 addition & 1 deletion src/java/org/apache/cassandra/service/StorageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ public boolean isReplacing()
if (replacing)
return true;

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;
Expand Down

0 comments on commit 2d95192

Please sign in to comment.