ifesdjeen commented on code in PR #4182:
URL: https://github.com/apache/cassandra/pull/4182#discussion_r2121517331


##########
src/java/org/apache/cassandra/service/accord/AccordJournalTable.java:
##########
@@ -149,6 +154,38 @@ public RangeSearcher rangeSearcher()
         return new TableRangeSearcher();
     }
 
+    public void start()
+    {
+        if (index == null) return;
+        Index tableIndex = 
cfs.indexManager.getIndexByName(AccordKeyspace.JOURNAL_INDEX_NAME);
+        RetryStrategy retry = 
DatabaseDescriptor.getAccord().retry_journal_index_ready.retry();

Review Comment:
   Are there scenarios under which we do not want to wait for journals 
readiness? Maybe we should just log where we are stuck but I'd say we should 
always wait for it.



##########
test/distributed/org/apache/cassandra/distributed/shared/ClusterUtils.java:
##########
@@ -1302,11 +1320,7 @@ public static List<File> getDataDirectories(IInstance 
instance)
      */
     public static File getCommitLogDirectory(IInstance instance)
     {
-        IInstanceConfig conf = instance.config();
-        // this isn't safe as it assumes the implementation of InstanceConfig
-        // might need to get smarter... some day...
-        String d = (String) conf.get("commitlog_directory");
-        return new File(d);
+        return getDirecotry(instance, "commitlog_directory");

Review Comment:
   type in word `getDirecotry`



##########
test/distributed/org/apache/cassandra/distributed/shared/ClusterUtils.java:
##########
@@ -187,6 +187,24 @@ public static <I extends IInstance> void 
stopAll(ICluster<I> cluster)
         cluster.stream().forEach(ClusterUtils::stopUnchecked);
     }
 
+    /**
+     * Restart an instance in a blocking manner.
+     * <p>
+     * This method stops the instance using {@link #stopUnchecked(IInstance)} 
and then

Review Comment:
   I feel like this comment takes more time to read than the code. I do not 
mind the short "Restart an instance in a blocking manner" part though.



##########
test/distributed/org/apache/cassandra/distributed/shared/ClusterUtils.java:
##########
@@ -1352,9 +1384,56 @@ public static List<File> getDirectories(IInstance 
instance)
         out.add(getCommitLogDirectory(instance));
         out.add(getHintsDirectory(instance));
         out.add(getSavedCachesDirectory(instance));
+        out.add(getJournalDirectory(instance));
+        out.add(getCdcRawDirectory(instance));
         return out;
     }
 
+    /**
+     * Clean up a cluster by stopping all instances, deleting all directories,
+     * and restarting all instances.
+     * <p>
+     * This effectively resets the cluster to a clean state without having to 
create
+     * a new cluster instance, which is useful for tests that need to start 
with a 
+     * fresh state between test phases.
+     *
+     * @param cluster the cluster to clean up
+     */
+    public static void cleanup(Cluster cluster)
+    {
+        stopAll(cluster);
+        for (var inst : cluster)
+        {
+            for (var f : getDirectories(inst))
+            {
+                if (f.exists())
+                    f.deleteRecursive();
+            }
+        }
+        for (var inst : cluster)
+            inst.startup();
+    }
+
+    /**
+     * Clean up a single instance by stopping it, deleting all its directories,
+     * and restarting it.
+     * <p>
+     * This effectively resets the instance to a clean state without having to 
create
+     * a new instance, which is useful for tests that need to start with a 
fresh state.
+     *
+     * @param inst the instance to clean up
+     */
+    public static void cleanup(IInvokableInstance inst)

Review Comment:
   I would personally shorten both comments. I think most our codebase is dense 
and hard to navigate, plus we have NL before brackets, which makes it hard to 
fit things on screen. Having longer comments that that do not add on top of the 
method content makes it harder to navigate. 



-- 
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.

To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org

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


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

Reply via email to