You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2021/04/06 01:09:43 UTC

[GitHub] [cassandra] pauloricardomg commented on a change in pull request #952: [CASSANDRA-14582] Add a system property to set the cassandra hostId if not yet initialized

pauloricardomg commented on a change in pull request #952:
URL: https://github.com/apache/cassandra/pull/952#discussion_r607415877



##########
File path: src/java/org/apache/cassandra/db/SystemKeyspace.java
##########
@@ -1114,7 +1114,8 @@ public static UUID getLocalHostId()
             return result.one().getUUID("host_id");
 
         // ID not found, generate a new one, persist, and then return it.
-        UUID hostId = UUID.randomUUID();
+        UUID hostId = UUID.fromString(System.getProperty("cassandra.cassandra.host_id_first_boot", UUID.randomUUID().toString()));

Review comment:
       should be `cassandra.host_id_first_boot`

##########
File path: test/distributed/org/apache/cassandra/distributed/test/ring/BootstrapTest.java
##########
@@ -95,6 +97,38 @@ public void autoBootstrapTest() throws Throwable
                 Assert.assertEquals("Node " + e.getKey() + " has incorrect row state", e.getValue().longValue(), 100L);
         }
     }
+    
+    @Test
+    public void hostIdOverrideTest() throws Throwable
+    {
+    	int nodeCount = 3;
+    	try (Cluster cluster = builder().withNodes(nodeCount).start()) {
+    		for (int i = 1; i <= cluster.size(); ++i) {
+    			IInvokableInstance instance = cluster.get(i);
+    			instance.config().set("cassandra.cassandra.host_id_first_boot", String.valueOf(i));
+    		} 		
+    		
+    		for (int i = 1; i <= cluster.size(); ++i) {
+    			IInvokableInstance instance = cluster.get(i);
+    			Assert.assertEquals(instance.config().getString("cassandra.cassandra.host_id_first_boot"), String.valueOf(i));
+    		}
+    	
+    		for (int i = 1; i <= cluster.size(); ++i) {
+    			IInvokableInstance instance = cluster.get(i);
+    			instance.shutdown().wait();
+    		}
+    		
+    		
+    		cluster.startup();
+    		
+    		for (int i = 1; i <= cluster.size(); ++i) {
+    			IInvokableInstance instance = cluster.get(i);
+    			Assert.assertEquals(instance.config().getString("cassandra.cassandra.host_id_first_boot"), String.valueOf(i));

Review comment:
       The test looks good, but this only checks that the `cassandra.host_id_first_boot` property was defined, but does not verify that the node actually picked the provided ID to use as host identifier. How is this value being used? Is there any other way you can check that the cassandra node is using the property?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org