CompactionManager: Fix JSON conversion in getCompactions()
This makes 'nodetool compactionstats' work: [penberg@nero cassandra]$ ./bin/nodetool compactionstats pending tasks: 0 compaction type keyspace table completed total unit progress compaction keyspace1 standard1 170719 500096 keys 34.14% compaction keyspace1 standard1 174781 441600 keys 39.58% Active compaction remaining time : 0h00m00s Fixes scylladb/scylla#745.
This commit is contained in:
parent
10caab8590
commit
d0757c4505
@ -18,8 +18,13 @@
|
|||||||
package org.apache.cassandra.db.compaction;
|
package org.apache.cassandra.db.compaction;
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.json.JsonArray;
|
||||||
|
import javax.json.JsonObject;
|
||||||
import javax.management.MBeanServer;
|
import javax.management.MBeanServer;
|
||||||
import javax.management.ObjectName;
|
import javax.management.ObjectName;
|
||||||
import javax.management.openmbean.OpenDataException;
|
import javax.management.openmbean.OpenDataException;
|
||||||
@ -73,7 +78,20 @@ public class CompactionManager implements CompactionManagerMBean {
|
|||||||
/** List of running compaction objects. */
|
/** List of running compaction objects. */
|
||||||
public List<Map<String, String>> getCompactions() {
|
public List<Map<String, String>> getCompactions() {
|
||||||
log(" getCompactions()");
|
log(" getCompactions()");
|
||||||
return c.getListMapStrValue("compaction_manager/compactions");
|
List<Map<String, String>> results = new ArrayList<Map<String, String>>();
|
||||||
|
JsonArray compactions = c.getJsonArray("compaction_manager/compactions");
|
||||||
|
for (int i = 0; i < compactions.size(); i++) {
|
||||||
|
JsonObject compaction = compactions.getJsonObject(i);
|
||||||
|
Map<String, String> result = new HashMap<String, String>();
|
||||||
|
result.put("total", Long.toString(compaction.getJsonNumber("total").longValue()));
|
||||||
|
result.put("completed", Long.toString(compaction.getJsonNumber("completed").longValue()));
|
||||||
|
result.put("taskType", compaction.getString("task_type"));
|
||||||
|
result.put("keyspace", compaction.getString("ks"));
|
||||||
|
result.put("columnfamily", compaction.getString("cf"));
|
||||||
|
result.put("unit", compaction.getString("unit"));
|
||||||
|
results.add(result);
|
||||||
|
}
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** List of running compaction summary strings. */
|
/** List of running compaction summary strings. */
|
||||||
|
Loading…
Reference in New Issue
Block a user