Search in sources :

Example 56 with TabularDataSupport

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

the class ManagedRuntimeEndpointRegistry method endpointStatistics.

@Override
public TabularData endpointStatistics() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listRuntimeEndpointsTabularType());
        EndpointRegistry staticRegistry = getContext().getEndpointRegistry();
        int index = 0;
        for (RuntimeEndpointRegistry.Statistic stat : registry.getEndpointStatistics()) {
            CompositeType ct = CamelOpenMBeanTypes.listRuntimeEndpointsCompositeType();
            String url = stat.getUri();
            Boolean isStatic = staticRegistry.isStatic(url);
            Boolean isDynamic = staticRegistry.isDynamic(url);
            if (sanitize) {
                url = URISupport.sanitizeUri(url);
            }
            String routeId = stat.getRouteId();
            String direction = stat.getDirection();
            long hits = stat.getHits();
            CompositeData data = new CompositeDataSupport(ct, new String[] { "index", "url", "routeId", "direction", "static", "dynamic", "hits" }, new Object[] { index, url, routeId, direction, isStatic, isDynamic, hits });
            answer.put(data);
            // use a counter as the single index in the TabularData as we do not want a multi-value index
            index++;
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
Also used : CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) TabularData(javax.management.openmbean.TabularData) TabularDataSupport(javax.management.openmbean.TabularDataSupport) RuntimeEndpointRegistry(org.apache.camel.spi.RuntimeEndpointRegistry) EndpointRegistry(org.apache.camel.spi.EndpointRegistry) RuntimeEndpointRegistry(org.apache.camel.spi.RuntimeEndpointRegistry) CompositeType(javax.management.openmbean.CompositeType)

Example 57 with TabularDataSupport

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

the class ManagedTransformerRegistry method listTransformers.

@SuppressWarnings("unchecked")
public TabularData listTransformers() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listTransformersTabularType());
        Collection<Transformer> transformers = transformerRegistry.values();
        for (Transformer transformer : transformers) {
            CompositeType ct = CamelOpenMBeanTypes.listTransformersCompositeType();
            String scheme = transformer.getModel();
            DataType from = transformer.getFrom();
            DataType to = transformer.getTo();
            String desc = transformer.toString();
            boolean fromStatic = scheme != null ? transformerRegistry.isStatic(scheme) : transformerRegistry.isStatic(from, to);
            boolean fromDynamic = scheme != null ? transformerRegistry.isDynamic(scheme) : transformerRegistry.isDynamic(from, to);
            CompositeData data = new CompositeDataSupport(ct, new String[] { "scheme", "from", "to", "static", "dynamic", "description" }, new Object[] { scheme, from.toString(), to.toString(), fromStatic, fromDynamic, desc });
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
Also used : Transformer(org.apache.camel.spi.Transformer) TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) DataType(org.apache.camel.spi.DataType) TabularData(javax.management.openmbean.TabularData) CompositeType(javax.management.openmbean.CompositeType)

Example 58 with TabularDataSupport

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

the class ManagedWireTapProcessor method extendedInformation.

@Override
public TabularData extendedInformation() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.endpointsUtilizationTabularType());
        EndpointUtilizationStatistics stats = processor.getEndpointUtilizationStatistics();
        if (stats != null) {
            for (Map.Entry<String, Long> entry : stats.getStatistics().entrySet()) {
                CompositeType ct = CamelOpenMBeanTypes.endpointsUtilizationCompositeType();
                String url = entry.getKey();
                if (sanitize) {
                    url = URISupport.sanitizeUri(url);
                }
                Long hits = entry.getValue();
                if (hits == null) {
                    hits = 0L;
                }
                CompositeData data = new CompositeDataSupport(ct, new String[] { "url", "hits" }, new Object[] { url, hits });
                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) EndpointUtilizationStatistics(org.apache.camel.spi.EndpointUtilizationStatistics) Map(java.util.Map) TabularData(javax.management.openmbean.TabularData) CompositeType(javax.management.openmbean.CompositeType)

Example 59 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project druid by alibaba.

the class JdbcDataSourceStat method getConnectionList.

@Override
public TabularData getConnectionList() throws JMException {
    CompositeType rowType = JdbcConnectionStat.Entry.getCompositeType();
    String[] indexNames = rowType.keySet().toArray(new String[rowType.keySet().size()]);
    TabularType tabularType = new TabularType("ConnectionListStatistic", "ConnectionListStatistic", rowType, indexNames);
    TabularData data = new TabularDataSupport(tabularType);
    for (Map.Entry<Long, JdbcConnectionStat.Entry> entry : getConnections().entrySet()) {
        data.put(entry.getValue().getCompositeData());
    }
    return data;
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) AtomicLong(java.util.concurrent.atomic.AtomicLong) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) CompositeType(javax.management.openmbean.CompositeType) TabularData(javax.management.openmbean.TabularData)

Example 60 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project druid by alibaba.

the class JdbcDataSourceStat method getSqlList.

@Override
public TabularData getSqlList() throws JMException {
    Map<String, JdbcSqlStat> sqlStatMap = this.getSqlStatMap();
    CompositeType rowType = JdbcSqlStat.getCompositeType();
    String[] indexNames = rowType.keySet().toArray(new String[rowType.keySet().size()]);
    TabularType tabularType = new TabularType("SqlListStatistic", "SqlListStatistic", rowType, indexNames);
    TabularData data = new TabularDataSupport(tabularType);
    for (Map.Entry<String, JdbcSqlStat> entry : sqlStatMap.entrySet()) {
        data.put(entry.getValue().getCompositeData());
    }
    return data;
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) CompositeType(javax.management.openmbean.CompositeType) TabularData(javax.management.openmbean.TabularData)

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