Add a system property to set hostId if not yet initialized

patch by Abi Palagashvili; reviewed by Stefan Miklosovic and Paulo Motta for CASSANDRA-14582
This commit is contained in:
fibersel 2021-05-26 23:04:57 +03:00 committed by Stefan Miklosovic
parent 4fd2124572
commit 33ff36cc42
3 changed files with 8 additions and 2 deletions

View File

@ -1,4 +1,5 @@
4.1
* Add a system property to set hostId if not yet initialized (CASSANDRA-14582)
* GossiperTest.testHasVersion3Nodes didn't take into account trunk version changes, fixed to rely on latest version (CASSANDRA-16651)
Merged from 4.0:
* Make JmxHistogram#getRecentValues() and JmxTimer#getRecentValues() thread-safe (CASSANDRA-16707)

View File

@ -22,6 +22,9 @@
# and perhaps have affinity.
#-Dcassandra.available_processors=number_of_processors
# Specify host id for the first boot and persist it
#-Dcassandra.host_id_first_boot=host_id
# The directory location of the cassandra.yaml file.
#-Dcassandra.config=directory

View File

@ -1126,13 +1126,15 @@ public final class SystemKeyspace
return hostId;
// ID not found, generate a new one, persist, and then return it.
hostId = UUID.randomUUID();
String hostString = System.getProperty("cassandra.host_id_first_boot", UUID.randomUUID().toString());
hostId = UUID.fromString(hostString);
logger.warn("No host ID found, created {} (Note: This should happen exactly once per node).", hostId);
return setLocalHostId(hostId);
}
/**
* Sets the local host ID explicitly. Should only be called outside of SystemTable when replacing a node.
* Sets the local host ID explicitly. Should only be called outside of SystemTable when replacing a node.
* Used also in CASSANDRA-14582.
*/
public static synchronized UUID setLocalHostId(UUID hostId)
{