This is an automated email from the ASF dual-hosted git repository.

smiklosovic pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 33ff36c  Add a system property to set hostId if not yet initialized
33ff36c is described below

commit 33ff36cc42a083311065dee56adc1d72d6866f2d
Author: fibersel <[email protected]>
AuthorDate: Wed May 26 23:04:57 2021 +0300

    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
---
 CHANGES.txt                                          | 1 +
 conf/jvm-server.options                              | 3 +++
 src/java/org/apache/cassandra/db/SystemKeyspace.java | 6 ++++--
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 185ec72..71018a6 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -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)
diff --git a/conf/jvm-server.options b/conf/jvm-server.options
index 46967f4..f7845d4 100644
--- a/conf/jvm-server.options
+++ b/conf/jvm-server.options
@@ -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
 
diff --git a/src/java/org/apache/cassandra/db/SystemKeyspace.java 
b/src/java/org/apache/cassandra/db/SystemKeyspace.java
index cbb7084..4d2a567 100644
--- a/src/java/org/apache/cassandra/db/SystemKeyspace.java
+++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java
@@ -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)
     {

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to