Search in sources :

Example 76 with CompositeDataSupport

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;
}
Also used : HashMap(java.util.HashMap) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) FiltrableSystemView(org.apache.ignite.spi.systemview.view.FiltrableSystemView) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) IgniteException(org.apache.ignite.IgniteException)

Example 77 with CompositeDataSupport

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);
    }
}
Also used : HashMap(java.util.HashMap) OpenDataException(javax.management.openmbean.OpenDataException) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) SessionInfo(org.apache.cassandra.streaming.SessionInfo)

Example 78 with CompositeDataSupport

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;
}
Also used : HashMap(java.util.HashMap) MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) JsonObject(javax.json.JsonObject) MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) JsonArray(javax.json.JsonArray) TabularDataSupport(javax.management.openmbean.TabularDataSupport) JsonObject(javax.json.JsonObject)

Example 79 with CompositeDataSupport

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;
}
Also used : JsonArray(javax.json.JsonArray) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) JsonValue(javax.json.JsonValue) JsonObject(javax.json.JsonObject) CompositeType(javax.management.openmbean.CompositeType)

Example 80 with CompositeDataSupport

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);
    }
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport)

Aggregations

CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)166 CompositeData (javax.management.openmbean.CompositeData)107 CompositeType (javax.management.openmbean.CompositeType)105 TabularDataSupport (javax.management.openmbean.TabularDataSupport)78 OpenDataException (javax.management.openmbean.OpenDataException)66 TabularData (javax.management.openmbean.TabularData)46 HashMap (java.util.HashMap)36 TabularType (javax.management.openmbean.TabularType)30 Map (java.util.Map)26 OpenType (javax.management.openmbean.OpenType)15 ObjectName (javax.management.ObjectName)12 MBeanServer (javax.management.MBeanServer)8 Test (org.junit.Test)8 IOException (java.io.IOException)7 EndpointUtilizationStatistics (org.apache.camel.spi.EndpointUtilizationStatistics)7 MBeanException (javax.management.MBeanException)6 JsonArray (javax.json.JsonArray)5 JsonObject (javax.json.JsonObject)5 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)5 ArrayList (java.util.ArrayList)4