driftx commented on code in PR #2333:
URL: https://github.com/apache/cassandra/pull/2333#discussion_r1196732260
##########
src/java/org/apache/cassandra/tools/nodetool/CompactionStats.java:
##########
@@ -53,29 +60,81 @@ 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.getCompactionThroughputBytes(), humanReadable, vtableOutput, out);
+ }
+
+ private static String pendingTasksAndConcurrentCompactorsStats(NodeProbe
probe)
+ {
Map<String, Map<String, Integer>> pendingTaskNumberByTable =
(Map<String, Map<String, Integer>>)
probe.getCompactionMetric("PendingTasksByTableName");
- int numTotalPendingTask = 0;
+ StringBuffer toPrint = new StringBuffer();
+ toPrint.append(String.format("%s concurrent compactors, %s pending
tasks", numConcurrentCompactorsConfigured(probe)
+ , 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());
+ toPrint.append(LINE_SEPARATOR);
+ }
}
- out.println("pending tasks: " + numTotalPendingTask);
+
+ return toPrint.toString();
+ }
+
+ private static int numPendingTasks(Map<String, Map<String, Integer>>
pendingTaskNumberByTable)
+ {
+ int numTotalPendingTasks = 0;
for (Entry<String, Map<String, Integer>> ksEntry :
pendingTaskNumberByTable.entrySet())
{
- String ksName = ksEntry.getKey();
for (Entry<String, Integer> tableEntry :
ksEntry.getValue().entrySet())
- {
- String tableName = tableEntry.getKey();
- int pendingTaskCount = tableEntry.getValue();
-
- out.println("- " + ksName + '.' + tableName + ": " +
pendingTaskCount);
- }
+ numTotalPendingTasks += tableEntry.getValue();
}
- out.println();
- reportCompactionTable(cm.getCompactions(),
probe.getCompactionThroughputBytes(), humanReadable, vtableOutput, out);
+
+ return numTotalPendingTasks;
+ }
+
+ private static int numConcurrentCompactorsConfigured(NodeProbe probe)
Review Comment:
We don't really need this method, we can call probe directly in the single
usage there is of it.
##########
src/java/org/apache/cassandra/tools/nodetool/CompactionStats.java:
##########
@@ -53,29 +60,81 @@ 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.getCompactionThroughputBytes(), humanReadable, vtableOutput, out);
+ }
+
+ private static String pendingTasksAndConcurrentCompactorsStats(NodeProbe
probe)
+ {
Map<String, Map<String, Integer>> pendingTaskNumberByTable =
(Map<String, Map<String, Integer>>)
probe.getCompactionMetric("PendingTasksByTableName");
- int numTotalPendingTask = 0;
+ StringBuffer toPrint = new StringBuffer();
+ toPrint.append(String.format("%s concurrent compactors, %s pending
tasks", numConcurrentCompactorsConfigured(probe)
+ , 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());
+ toPrint.append(LINE_SEPARATOR);
+ }
}
- out.println("pending tasks: " + numTotalPendingTask);
+
+ return toPrint.toString();
+ }
+
+ private static int numPendingTasks(Map<String, Map<String, Integer>>
pendingTaskNumberByTable)
+ {
+ int numTotalPendingTasks = 0;
for (Entry<String, Map<String, Integer>> ksEntry :
pendingTaskNumberByTable.entrySet())
{
- String ksName = ksEntry.getKey();
for (Entry<String, Integer> tableEntry :
ksEntry.getValue().entrySet())
- {
- String tableName = tableEntry.getKey();
- int pendingTaskCount = tableEntry.getValue();
-
- out.println("- " + ksName + '.' + tableName + ": " +
pendingTaskCount);
- }
+ numTotalPendingTasks += tableEntry.getValue();
}
- out.println();
- reportCompactionTable(cm.getCompactions(),
probe.getCompactionThroughputBytes(), humanReadable, vtableOutput, out);
+
+ return numTotalPendingTasks;
+ }
+
+ private static int numConcurrentCompactorsConfigured(NodeProbe probe)
+ {
+ return probe.getConcurrentCompactors();
+ }
+
+ private static String compactionsCompletedStats(NodeProbe probe)
+ {
+ Long completedTasks =
(Long)probe.getCompactionMetric("CompletedTasks");
+ CassandraMetricsRegistry.JmxMeterMBean
totalCompactionsCompletedMetrics =
+
(CassandraMetricsRegistry.JmxMeterMBean)probe.getCompactionMetric("TotalCompactionsCompleted");
+ NumberFormat formatter = new DecimalFormat("##.00");
+ StringBuffer toPrint = new StringBuffer();
+ toPrint.append(String.format("compactions completed: %s",
completedTasks));
+ toPrint.append(LINE_SEPARATOR);
+ toPrint.append(String.format("\tminute rate: %s/second",
formatter.format(totalCompactionsCompletedMetrics.getOneMinuteRate())));
+ toPrint.append(LINE_SEPARATOR);
+ toPrint.append(String.format("\t5 minute rate: %s/second",
formatter.format(totalCompactionsCompletedMetrics.getFiveMinuteRate())));
+ toPrint.append(LINE_SEPARATOR);
+ toPrint.append(String.format("\t15 minute rate: %s/second",
formatter.format(totalCompactionsCompletedMetrics.getFifteenMinuteRate())));
+ toPrint.append(LINE_SEPARATOR);
+ toPrint.append(String.format("\tMean rate: %s/second",
formatter.format(totalCompactionsCompletedMetrics.getMeanRate())));
+ toPrint.append(LINE_SEPARATOR);
+
+ return toPrint.toString();
+ }
+
+ private static String compactionThroughPutStats(NodeProbe probe)
+ {
+ Config conf = DatabaseDescriptor.loadConfig();
+ double compactionTPConfigured =
conf.compaction_throughput.toMebibytesPerSecond();
+ double compactionTPActual =
probe.getCompactionThroughputMebibytesAsDouble();
+ double percentage = (compactionTPActual / compactionTPConfigured) *
100;
Review Comment:
Need the handle the case when the configured throughput is zero.
##########
src/java/org/apache/cassandra/tools/nodetool/CompactionStats.java:
##########
@@ -53,29 +60,81 @@ 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.getCompactionThroughputBytes(), humanReadable, vtableOutput, out);
+ }
+
+ private static String pendingTasksAndConcurrentCompactorsStats(NodeProbe
probe)
+ {
Map<String, Map<String, Integer>> pendingTaskNumberByTable =
(Map<String, Map<String, Integer>>)
probe.getCompactionMetric("PendingTasksByTableName");
- int numTotalPendingTask = 0;
+ StringBuffer toPrint = new StringBuffer();
+ toPrint.append(String.format("%s concurrent compactors, %s pending
tasks", numConcurrentCompactorsConfigured(probe)
+ , 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());
+ toPrint.append(LINE_SEPARATOR);
+ }
}
- out.println("pending tasks: " + numTotalPendingTask);
+
+ return toPrint.toString();
+ }
+
+ private static int numPendingTasks(Map<String, Map<String, Integer>>
pendingTaskNumberByTable)
+ {
+ int numTotalPendingTasks = 0;
for (Entry<String, Map<String, Integer>> ksEntry :
pendingTaskNumberByTable.entrySet())
{
- String ksName = ksEntry.getKey();
for (Entry<String, Integer> tableEntry :
ksEntry.getValue().entrySet())
- {
- String tableName = tableEntry.getKey();
- int pendingTaskCount = tableEntry.getValue();
-
- out.println("- " + ksName + '.' + tableName + ": " +
pendingTaskCount);
- }
+ numTotalPendingTasks += tableEntry.getValue();
}
- out.println();
- reportCompactionTable(cm.getCompactions(),
probe.getCompactionThroughputBytes(), humanReadable, vtableOutput, out);
+
+ return numTotalPendingTasks;
+ }
+
+ private static int numConcurrentCompactorsConfigured(NodeProbe probe)
+ {
+ return probe.getConcurrentCompactors();
+ }
+
+ private static String compactionsCompletedStats(NodeProbe probe)
+ {
+ Long completedTasks =
(Long)probe.getCompactionMetric("CompletedTasks");
+ CassandraMetricsRegistry.JmxMeterMBean
totalCompactionsCompletedMetrics =
+
(CassandraMetricsRegistry.JmxMeterMBean)probe.getCompactionMetric("TotalCompactionsCompleted");
+ NumberFormat formatter = new DecimalFormat("##.00");
+ StringBuffer toPrint = new StringBuffer();
+ toPrint.append(String.format("compactions completed: %s",
completedTasks));
+ toPrint.append(LINE_SEPARATOR);
+ toPrint.append(String.format("\tminute rate: %s/second",
formatter.format(totalCompactionsCompletedMetrics.getOneMinuteRate())));
+ toPrint.append(LINE_SEPARATOR);
+ toPrint.append(String.format("\t5 minute rate: %s/second",
formatter.format(totalCompactionsCompletedMetrics.getFiveMinuteRate())));
+ toPrint.append(LINE_SEPARATOR);
+ toPrint.append(String.format("\t15 minute rate: %s/second",
formatter.format(totalCompactionsCompletedMetrics.getFifteenMinuteRate())));
+ toPrint.append(LINE_SEPARATOR);
+ toPrint.append(String.format("\tMean rate: %s/second",
formatter.format(totalCompactionsCompletedMetrics.getMeanRate())));
+ toPrint.append(LINE_SEPARATOR);
+
+ return toPrint.toString();
+ }
+
+ private static String compactionThroughPutStats(NodeProbe probe)
+ {
+ Config conf = DatabaseDescriptor.loadConfig();
Review Comment:
Nodetool should work against any node; we shouldn't import DD at all and
instead get this information from the probe.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]