use of javax.management.openmbean.CompositeDataSupport in project ignite by apache.
the class SystemViewMBean method viewContent.
/**
* Gets tabular data with system view content.
*/
private TabularDataSupport viewContent(Map<String, Object> filter) {
TabularDataSupport rows = new TabularDataSupport(sysViewType);
AttributeToMapVisitor visitor = new AttributeToMapVisitor();
try {
int idx = 0;
Iterable<R> iter = filter != null && sysView instanceof FiltrableSystemView ? () -> ((FiltrableSystemView<R>) sysView).iterator(filter) : sysView;
for (R row : iter) {
Map<String, Object> data = new HashMap<>();
visitor.data(data);
sysView.walker().visitAll(row, visitor);
data.put(ID, idx++);
rows.put(new CompositeDataSupport(rowType, data));
}
} catch (OpenDataException e) {
throw new IgniteException(e);
}
return rows;
}
use of javax.management.openmbean.CompositeDataSupport in project scylla-jmx by scylladb.
the class StreamStateCompositeData method toCompositeData.
public static CompositeData toCompositeData(final StreamState streamState) {
Map<String, Object> valueMap = new HashMap<>();
valueMap.put(ITEM_NAMES[0], streamState.planId.toString());
valueMap.put(ITEM_NAMES[1], streamState.description);
CompositeData[] sessions = new CompositeData[streamState.sessions.size()];
Lists.newArrayList(Iterables.transform(streamState.sessions, input -> SessionInfoCompositeData.toCompositeData(streamState.planId, input))).toArray(sessions);
valueMap.put(ITEM_NAMES[2], sessions);
long currentRxBytes = 0;
long totalRxBytes = 0;
long currentTxBytes = 0;
long totalTxBytes = 0;
for (SessionInfo sessInfo : streamState.sessions) {
currentRxBytes += sessInfo.getTotalSizeReceived();
totalRxBytes += sessInfo.getTotalSizeToReceive();
currentTxBytes += sessInfo.getTotalSizeSent();
totalTxBytes += sessInfo.getTotalSizeToSend();
}
double rxPercentage = (totalRxBytes == 0 ? 100L : currentRxBytes * 100L / totalRxBytes);
double txPercentage = (totalTxBytes == 0 ? 100L : currentTxBytes * 100L / totalTxBytes);
valueMap.put(ITEM_NAMES[3], currentRxBytes);
valueMap.put(ITEM_NAMES[4], totalRxBytes);
valueMap.put(ITEM_NAMES[5], rxPercentage);
valueMap.put(ITEM_NAMES[6], currentTxBytes);
valueMap.put(ITEM_NAMES[7], totalTxBytes);
valueMap.put(ITEM_NAMES[8], txPercentage);
try {
return new CompositeDataSupport(COMPOSITE_TYPE, valueMap);
} catch (OpenDataException e) {
throw Throwables.propagate(e);
}
}
use of javax.management.openmbean.CompositeDataSupport in project scylla-jmx by scylladb.
the class StorageService method getToppartitions.
@Override
public Map<String, CompositeData> getToppartitions(List<String> samplers, List<String> keyspaceFilters, List<String> tableFilters, int duration, int capacity, int count) throws OpenDataException {
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
APIClient.set_query_param(queryParams, "duration", Integer.toString(duration));
APIClient.set_query_param(queryParams, "capacity", Integer.toString(capacity));
APIClient.set_query_param(queryParams, "keyspace_filters", keyspaceFilters != null ? APIClient.join(keyspaceFilters.toArray(new String[0])) : null);
APIClient.set_query_param(queryParams, "table_filters", tableFilters != null ? APIClient.join(tableFilters.toArray(new String[0])) : null);
JsonObject result = client.getJsonObj("/storage_service/toppartitions", queryParams);
Map<String, CompositeData> resultsMap = new HashMap<>();
for (String operation : OPERATION_NAMES) {
JsonArray counters = result.getJsonArray(operation);
long cardinality = result.getJsonNumber(operation + "_cardinality").longValue();
long size = 0;
TabularDataSupport tabularResult = new TabularDataSupport(COUNTER_TYPE);
if (counters != null) {
size = (count > counters.size()) ? counters.size() : count;
for (int i = 0; i < size; i++) {
JsonObject counter = counters.getJsonObject(i);
tabularResult.put(new CompositeDataSupport(COUNTER_COMPOSITE_TYPE, COUNTER_NAMES, new Object[] { // raw
counter.getString("partition"), // count
counter.getJsonNumber("count").longValue(), // error
counter.getJsonNumber("error").longValue(), // string
counter.getString("partition") }));
}
}
resultsMap.put(operation + "s", new CompositeDataSupport(SAMPLING_RESULT, SAMPLER_NAMES, new Object[] { cardinality, tabularResult }));
}
return resultsMap;
}
use of javax.management.openmbean.CompositeDataSupport 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.management.openmbean.CompositeDataSupport in project scylla-jmx by scylladb.
the class SnapshotDetailsTabularData method from.
public static void from(final String snapshot, final String ks, final String cf, Map.Entry<String, Pair<Long, Long>> snapshotDetail, TabularDataSupport result) {
try {
final String totalSize = FileUtils.stringifyFileSize(snapshotDetail.getValue().left);
final String liveSize = FileUtils.stringifyFileSize(snapshotDetail.getValue().right);
result.put(new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES, new Object[] { snapshot, ks, cf, liveSize, totalSize }));
} catch (OpenDataException e) {
throw new RuntimeException(e);
}
}
Aggregations