StorageService: format the describering output
The describeRingJMX method, returns a formated output. The output should be similiar to origin as oppose to the current implementation that returns a json representation. After the change an example of nodetool describering: $ nodetool describering keyspace1 Schema Version:1074c31b-1f39-3df2-90ff-7f0b64bb3ea4 TokenRange: TokenRange(start_token:7485973865401664349, end_token:-338297331236877217, endpoints:[127.0.0.1], rpc_endpoints:[127.0.0.1], endpoint_details:[EndpointDetails(host:127.0.0.1, datacenter:datacenter1, rack:rack1)]) TokenRange(start_token:-338297331236877217, end_token:7485973865401664349, endpoints:[127.0.0.2], rpc_endpoints:[127.0.0.2], endpoint_details:[EndpointDetails(host:127.0.0.2, datacenter:datacenter1, rack:rack1)]) On sycall-jmx: Fixes #21 Signed-off-by: Amnon Heiman <amnon@scylladb.com>
This commit is contained in:
parent
9b03fa1074
commit
4f275cc44b
@ -262,12 +262,48 @@ public class StorageService extends NotificationBroadcasterSupport
|
||||
List<String> res = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
JsonWriter writer = Json.createWriter(stringWriter);
|
||||
JsonObject obj = arr.getJsonObject(i);
|
||||
writer.writeObject(obj);
|
||||
writer.close();
|
||||
res.add(stringWriter.getBuffer().toString());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("TokenRange(");
|
||||
sb.append("start_token:");
|
||||
sb.append(obj.getString("start_token"));
|
||||
sb.append(", end_token:");
|
||||
sb.append(obj.getString("end_token"));
|
||||
sb.append(", endpoints:[");
|
||||
JsonArray endpoints = obj.getJsonArray("endpoints");
|
||||
for (int j = 0; j < endpoints.size(); j++) {
|
||||
if (j > 0) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(endpoints.getString(j));
|
||||
}
|
||||
sb.append("], rpc_endpoints:[");
|
||||
JsonArray rpc_endpoints = obj.getJsonArray("rpc_endpoints");
|
||||
for (int j = 0; j < rpc_endpoints.size(); j++) {
|
||||
if (j > 0) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(rpc_endpoints.getString(j));
|
||||
}
|
||||
|
||||
sb.append("], endpoint_details:[");
|
||||
JsonArray endpoint_details = obj.getJsonArray("endpoint_details");
|
||||
for (int j = 0; j < endpoint_details.size(); j++) {
|
||||
JsonObject detail = endpoint_details.getJsonObject(j);
|
||||
if (j > 0) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append("EndpointDetails(");
|
||||
sb.append("host:");
|
||||
sb.append(detail.getString("host"));
|
||||
sb.append(", datacenter:");
|
||||
sb.append(detail.getString("datacenter"));
|
||||
sb.append(", rack:");
|
||||
sb.append(detail.getString("rack"));
|
||||
sb.append(')');
|
||||
}
|
||||
sb.append("])");
|
||||
res.add(sb.toString());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user