Search in sources :

Example 41 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project sling by apache.

the class HealthCheckMBean method logData.

private TabularData logData(final Result er) throws OpenDataException {
    final TabularDataSupport result = new TabularDataSupport(LOG_TABLE_TYPE);
    int i = 1;
    for (final ResultLog.Entry e : er) {
        final Map<String, Object> data = new HashMap<String, Object>();
        data.put(INDEX_COLUMN, i++);
        data.put(LEVEL_COLUMN, e.getStatus().toString());
        data.put(MESSAGE_COLUMN, e.getMessage());
        result.put(new CompositeDataSupport(LOG_ROW_TYPE, data));
    }
    return result;
}
Also used : HashMap(java.util.HashMap) TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) ResultLog(org.apache.sling.hc.api.ResultLog)

Example 42 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project cassandra by apache.

the class StorageService method getSnapshotDetails.

public Map<String, TabularData> getSnapshotDetails() {
    Map<String, TabularData> snapshotMap = new HashMap<>();
    for (Keyspace keyspace : Keyspace.all()) {
        if (SchemaConstants.isSystemKeyspace(keyspace.getName()))
            continue;
        for (ColumnFamilyStore cfStore : keyspace.getColumnFamilyStores()) {
            for (Map.Entry<String, Pair<Long, Long>> snapshotDetail : cfStore.getSnapshotDetails().entrySet()) {
                TabularDataSupport data = (TabularDataSupport) snapshotMap.get(snapshotDetail.getKey());
                if (data == null) {
                    data = new TabularDataSupport(SnapshotDetailsTabularData.TABULAR_TYPE);
                    snapshotMap.put(snapshotDetail.getKey(), data);
                }
                SnapshotDetailsTabularData.from(snapshotDetail.getKey(), keyspace.getName(), cfStore.getTableName(), snapshotDetail, data);
            }
        }
    }
    return snapshotMap;
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) TraceKeyspace(org.apache.cassandra.tracing.TraceKeyspace) AuthKeyspace(org.apache.cassandra.auth.AuthKeyspace) TabularData(javax.management.openmbean.TabularData)

Example 43 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project jmxtrans by jmxtrans.

the class JmxResultProcessor method getResult.

/**
	 * Used when the object is effectively a java type
	 */
private void getResult(Builder<Result> accumulator, Attribute attribute) {
    Object value = attribute.getValue();
    if (value == null) {
        return;
    }
    if (value instanceof CompositeData) {
        getResult(accumulator, attribute.getName(), (CompositeData) value);
    } else if (value instanceof CompositeData[]) {
        for (CompositeData cd : (CompositeData[]) value) {
            getResult(accumulator, attribute.getName(), cd);
        }
    } else if (value instanceof ObjectName[]) {
        Map<String, Object> values = newHashMap();
        for (ObjectName obj : (ObjectName[]) value) {
            values.put(obj.getCanonicalName(), obj.getKeyPropertyListString());
        }
        Result r = getNewResultObject(attribute.getName(), values);
        accumulator.add(r);
    } else if (value.getClass().isArray()) {
        // OMFG: this is nutty. some of the items in the array can be
        // primitive! great interview question!
        Map<String, Object> values = newHashMap();
        for (int i = 0; i < Array.getLength(value); i++) {
            Object val = Array.get(value, i);
            values.put(attribute.getName() + "." + i, val);
        }
        accumulator.add(getNewResultObject(attribute.getName(), values));
    } else if (value instanceof TabularDataSupport) {
        TabularDataSupport tds = (TabularDataSupport) value;
        Map<String, Object> values = Collections.emptyMap();
        Result r = getNewResultObject(attribute.getName(), values);
        processTabularDataSupport(accumulator, attribute.getName(), tds);
        accumulator.add(r);
    } else if (value instanceof Map) {
        Result r = getNewResultObject(attribute.getName(), convertKeysToString((Map<Object, Object>) value));
        accumulator.add(r);
    } else {
        Map<String, Object> values = newHashMap();
        values.put(attribute.getName(), value);
        Result r = getNewResultObject(attribute.getName(), values);
        accumulator.add(r);
    }
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) ImmutableMap(com.google.common.collect.ImmutableMap) Maps.newHashMap(com.google.common.collect.Maps.newHashMap) Map(java.util.Map) ObjectName(javax.management.ObjectName)

Example 44 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project camel by apache.

the class ManagedAsyncProcessorAwaitManager method browse.

@Override
public TabularData browse() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listAwaitThreadsTabularType());
        Collection<AsyncProcessorAwaitManager.AwaitThread> threads = manager.browse();
        for (AsyncProcessorAwaitManager.AwaitThread entry : threads) {
            CompositeType ct = CamelOpenMBeanTypes.listAwaitThreadsCompositeType();
            String id = "" + entry.getBlockedThread().getId();
            String name = entry.getBlockedThread().getName();
            String exchangeId = entry.getExchange().getExchangeId();
            String routeId = entry.getRouteId();
            String nodeId = entry.getNodeId();
            String duration = "" + entry.getWaitDuration();
            CompositeData data = new CompositeDataSupport(ct, new String[] { "id", "name", "exchangeId", "routeId", "nodeId", "duration" }, new Object[] { id, name, exchangeId, routeId, nodeId, duration });
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) AsyncProcessorAwaitManager(org.apache.camel.spi.AsyncProcessorAwaitManager) TabularData(javax.management.openmbean.TabularData) CompositeType(javax.management.openmbean.CompositeType)

Example 45 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project camel by apache.

the class ManagedCamelContext method listEips.

public TabularData listEips() throws Exception {
    try {
        // find all EIPs
        Map<String, Properties> eips = context.findEips();
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listEipsTabularType());
        // gather EIP detail for each eip
        for (Map.Entry<String, Properties> entry : eips.entrySet()) {
            String name = entry.getKey();
            String title = (String) entry.getValue().get("title");
            String description = (String) entry.getValue().get("description");
            String label = (String) entry.getValue().get("label");
            String type = (String) entry.getValue().get("class");
            String status = CamelContextHelper.isEipInUse(context, name) ? "in use" : "on classpath";
            CompositeType ct = CamelOpenMBeanTypes.listEipsCompositeType();
            CompositeData data = new CompositeDataSupport(ct, new String[] { "name", "title", "description", "label", "status", "type" }, new Object[] { name, title, description, label, status, type });
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) Properties(java.util.Properties) Map(java.util.Map) IOException(java.io.IOException) TabularData(javax.management.openmbean.TabularData) CompositeType(javax.management.openmbean.CompositeType)

Aggregations

TabularDataSupport (javax.management.openmbean.TabularDataSupport)103 TabularData (javax.management.openmbean.TabularData)67 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)60 CompositeData (javax.management.openmbean.CompositeData)51 CompositeType (javax.management.openmbean.CompositeType)50 TabularType (javax.management.openmbean.TabularType)36 Map (java.util.Map)27 OpenDataException (javax.management.openmbean.OpenDataException)24 HashMap (java.util.HashMap)11 Bundle (org.osgi.framework.Bundle)10 IOException (java.io.IOException)7 ObjectName (javax.management.ObjectName)7 OpenType (javax.management.openmbean.OpenType)7 EndpointUtilizationStatistics (org.apache.camel.spi.EndpointUtilizationStatistics)7 Test (org.junit.Test)6 ConcurrentMap (java.util.concurrent.ConcurrentMap)5 MBeanException (javax.management.MBeanException)5 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)5 ArrayList (java.util.ArrayList)4 Dictionary (java.util.Dictionary)4