use of javax.json.JsonArray in project scylla-jmx by scylladb.
the class APIClient method getMapStringListStrValue.
public Map<String, List<String>> getMapStringListStrValue(String string, MultivaluedMap<String, String> queryParams) {
if (string.equals("")) {
return null;
}
JsonReader reader = getReader(string, queryParams);
JsonArray arr = reader.readArray();
Map<String, List<String>> map = new HashMap<String, List<String>>();
for (int i = 0; i < arr.size(); i++) {
JsonObject obj = arr.getJsonObject(i);
if (obj.containsKey("key") && obj.containsKey("value")) {
map.put(obj.getString("key"), listStrFromJArr(obj.getJsonArray("value")));
}
}
reader.close();
return map;
}
use of javax.json.JsonArray in project scylla-jmx by scylladb.
the class CompactionHistoryTabularData method from.
public static TabularData from(JsonArray resultSet) throws OpenDataException {
TabularDataSupport result = new TabularDataSupport(TABULAR_TYPE);
for (int i = 0; i < resultSet.size(); i++) {
JsonObject row = resultSet.getJsonObject(i);
String id = row.getString("id");
String ksName = row.getString("ks");
String cfName = row.getString("cf");
long compactedAt = row.getJsonNumber("compacted_at").longValue();
long bytesIn = row.getJsonNumber("bytes_in").longValue();
long bytesOut = row.getJsonNumber("bytes_out").longValue();
JsonArray merged = row.getJsonArray("rows_merged");
StringBuilder sb = new StringBuilder();
if (merged != null) {
sb.append('{');
for (int m = 0; m < merged.size(); m++) {
JsonObject entry = merged.getJsonObject(m);
if (m > 0) {
sb.append(',');
}
sb.append(entry.getString("key")).append(':').append(entry.getString("value"));
}
sb.append('}');
}
result.put(new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES, new Object[] { id, ksName, cfName, compactedAt, bytesIn, bytesOut, sb.toString() }));
}
return result;
}
use of javax.json.JsonArray in project scylla-jmx by scylladb.
the class FailureDetector method getPhiValues.
@Override
public TabularData getPhiValues() throws OpenDataException {
final CompositeType ct = new CompositeType("Node", "Node", new String[] { "Endpoint", "PHI" }, new String[] { "IP of the endpoint", "PHI value" }, new OpenType[] { SimpleType.STRING, SimpleType.DOUBLE });
final TabularDataSupport results = new TabularDataSupport(new TabularType("PhiList", "PhiList", ct, new String[] { "Endpoint" }));
final JsonArray arr = client.getJsonArray("/failure_detector/endpoint_phi_values");
for (JsonValue v : arr) {
JsonObject o = (JsonObject) v;
String endpoint = o.getString("endpoint");
double phi = Double.parseDouble(o.getString("phi"));
if (phi != Double.MIN_VALUE) {
// returned values are scaled by PHI_FACTOR so that the are on
// the same scale as PhiConvictThreshold
final CompositeData data = new CompositeDataSupport(ct, new String[] { "Endpoint", "PHI" }, new Object[] { endpoint, phi * PHI_FACTOR });
results.put(data);
}
}
return results;
}
use of javax.json.JsonArray in project scylla-jmx by scylladb.
the class MessagingService method getDroppedMessages.
/**
* dropped message counts for server lifetime
*/
@Override
public Map<String, Integer> getDroppedMessages() {
log(" getDroppedMessages()");
Map<String, Integer> res = new HashMap<String, Integer>();
JsonArray arr = client.getJsonArray("/messaging_service/messages/dropped_by_ver");
for (int i = 0; i < arr.size(); i++) {
JsonObject obj = arr.getJsonObject(i);
res.put(obj.getString("verb"), obj.getInt("count"));
}
return res;
}
use of javax.json.JsonArray in project scylla-jmx by scylladb.
the class StorageService method getColumnFamilyPerKeyspace.
public Map<String, Set<String>> getColumnFamilyPerKeyspace() {
Map<String, Set<String>> res = new HashMap<String, Set<String>>();
JsonArray mbeans = client.getJsonArray("/column_family/");
for (int i = 0; i < mbeans.size(); i++) {
JsonObject mbean = mbeans.getJsonObject(i);
String ks = mbean.getString("ks");
String cf = mbean.getString("cf");
if (!res.containsKey(ks)) {
res.put(ks, new HashSet<String>());
}
res.get(ks).add(cf);
}
return res;
}
Aggregations