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 <amnon@scylladb.com>
This commit is contained in:
Amnon Heiman 2019-08-05 14:12:48 +03:00 committed by Pekka Enberg
parent ff0723abc6
commit 71170f5713

View File

@ -55,7 +55,7 @@ public class CompactionMetrics implements Metrics {
registry.register(() -> registry.gauge((client) -> { registry.register(() -> registry.gauge((client) -> {
Map<String, Map<String, Integer>> result = new HashMap<>(); Map<String, Map<String, Integer>> 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++) { for (int i = 0; i < compactions.size(); i++) {
JsonObject c = compactions.getJsonObject(i); JsonObject c = compactions.getJsonObject(i);
@ -68,7 +68,7 @@ public class CompactionMetrics implements Metrics {
} }
Map<String, Integer> map = result.get(ks); Map<String, Integer> 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; return result;
}), factory.createMetricName("PendingTasksByTableName")); }), factory.createMetricName("PendingTasksByTableName"));