You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "Maxwell-Guo (via GitHub)" <gi...@apache.org> on 2023/06/05 02:39:54 UTC

[GitHub] [cassandra] Maxwell-Guo commented on a diff in pull request #2375: CASSANDRA-18305: Enhance nodetool compactionstats for cassandra 4.0

Maxwell-Guo commented on code in PR #2375:
URL: https://github.com/apache/cassandra/pull/2375#discussion_r1217376774


##########
src/java/org/apache/cassandra/tools/nodetool/CompactionStats.java:
##########
@@ -48,29 +53,82 @@ public class CompactionStats extends NodeToolCmd
     public void execute(NodeProbe probe)
     {
         PrintStream out = probe.output().out;
+        out.print(pendingTasksAndConcurrentCompactorsStats(probe));
+        out.print(compactionsCompletedStats(probe));
+        out.print(compactionThroughputStats(probe));
+        out.println();
         CompactionManagerMBean cm = probe.getCompactionManagerProxy();
+        reportCompactionTable(cm.getCompactions(), probe.getCompactionThroughput(), humanReadable, out);
+    }
+
+    private static String pendingTasksAndConcurrentCompactorsStats(NodeProbe probe)
+    {
         Map<String, Map<String, Integer>> pendingTaskNumberByTable =
-            (Map<String, Map<String, Integer>>) probe.getCompactionMetric("PendingTasksByTableName");
-        int numTotalPendingTask = 0;
+                (Map<String, Map<String, Integer>>) probe.getCompactionMetric("PendingTasksByTableName");
+        StringBuffer toPrint = new StringBuffer();
+        toPrint.append(String.format("%s concurrent compactors, %s pending tasks", probe.getConcurrentCompactors()
+                , numPendingTasks(pendingTaskNumberByTable)));

Review Comment:
   we should make ',' aligned with %s



##########
src/java/org/apache/cassandra/tools/nodetool/CompactionStats.java:
##########
@@ -48,29 +53,82 @@ public class CompactionStats extends NodeToolCmd
     public void execute(NodeProbe probe)
     {
         PrintStream out = probe.output().out;
+        out.print(pendingTasksAndConcurrentCompactorsStats(probe));
+        out.print(compactionsCompletedStats(probe));
+        out.print(compactionThroughputStats(probe));
+        out.println();
         CompactionManagerMBean cm = probe.getCompactionManagerProxy();
+        reportCompactionTable(cm.getCompactions(), probe.getCompactionThroughput(), humanReadable, out);
+    }
+
+    private static String pendingTasksAndConcurrentCompactorsStats(NodeProbe probe)
+    {
         Map<String, Map<String, Integer>> pendingTaskNumberByTable =
-            (Map<String, Map<String, Integer>>) probe.getCompactionMetric("PendingTasksByTableName");
-        int numTotalPendingTask = 0;
+                (Map<String, Map<String, Integer>>) probe.getCompactionMetric("PendingTasksByTableName");
+        StringBuffer toPrint = new StringBuffer();
+        toPrint.append(String.format("%s concurrent compactors, %s pending tasks", probe.getConcurrentCompactors()
+                , numPendingTasks(pendingTaskNumberByTable)));
+        toPrint.append(LINE_SEPARATOR);
         for (Entry<String, Map<String, Integer>> ksEntry : pendingTaskNumberByTable.entrySet())
         {
+            String ksName = ksEntry.getKey();
             for (Entry<String, Integer> tableEntry : ksEntry.getValue().entrySet())
-                numTotalPendingTask += tableEntry.getValue();
+            {
+                toPrint.append("- " + ksName + '.' + tableEntry.getKey() + ": " + tableEntry.getValue());

Review Comment:
   should we use String format?



-- 
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-unsubscribe@cassandra.apache.org

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