From 71170f5713cdd9436936f539234c27c4511de3ce Mon Sep 17 00:00:00 2001 From: Amnon Heiman Date: Mon, 5 Aug 2019 14:12:48 +0300 Subject: [PATCH] CompactionMetrics: use the pending compaction API (#75) The PendingTasksByTableName metric should use the pending_tasks_by_table API to get the real value of the pending compaction. Fixes #74 Signed-off-by: Amnon Heiman --- .../java/org/apache/cassandra/metrics/CompactionMetrics.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/cassandra/metrics/CompactionMetrics.java b/src/main/java/org/apache/cassandra/metrics/CompactionMetrics.java index b25ad37..62f6b54 100644 --- a/src/main/java/org/apache/cassandra/metrics/CompactionMetrics.java +++ b/src/main/java/org/apache/cassandra/metrics/CompactionMetrics.java @@ -55,7 +55,7 @@ public class CompactionMetrics implements Metrics { registry.register(() -> registry.gauge((client) -> { Map> result = new HashMap<>(); - JsonArray compactions = client.getJsonArray("compaction_manager/compactions"); + JsonArray compactions = client.getJsonArray("compaction_manager/metrics/pending_tasks_by_table"); for (int i = 0; i < compactions.size(); i++) { JsonObject c = compactions.getJsonObject(i); @@ -68,7 +68,7 @@ public class CompactionMetrics implements Metrics { } Map map = result.get(ks); - map.put(cf, (int)(c.getJsonNumber("total").longValue() - c.getJsonNumber("completed").longValue())); + map.put(cf, (int)(c.getJsonNumber("task").longValue())); } return result; }), factory.createMetricName("PendingTasksByTableName"));