Search in sources :

Example 6 with CompositeType

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

the class ManagedCircuitBreakerLoadBalancer method exceptionStatistics.

@Override
public TabularData exceptionStatistics() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.loadbalancerExceptionsTabularType());
        ExceptionFailureStatistics statistics = processor.getExceptionFailureStatistics();
        Iterator<Class<?>> it = statistics.getExceptions();
        boolean empty = true;
        while (it.hasNext()) {
            empty = false;
            Class<?> exception = it.next();
            String name = ObjectHelper.name(exception);
            long counter = statistics.getFailureCounter(exception);
            CompositeType ct = CamelOpenMBeanTypes.loadbalancerExceptionsCompositeType();
            CompositeData data = new CompositeDataSupport(ct, new String[] { "exception", "failures" }, new Object[] { name, counter });
            answer.put(data);
        }
        if (empty) {
            // use Exception as a single general
            String name = ObjectHelper.name(Exception.class);
            long counter = statistics.getFailureCounter(Exception.class);
            CompositeType ct = CamelOpenMBeanTypes.loadbalancerExceptionsCompositeType();
            CompositeData data = new CompositeDataSupport(ct, new String[] { "exception", "failures" }, new Object[] { name, counter });
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
Also used : CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) ExceptionFailureStatistics(org.apache.camel.processor.loadbalancer.ExceptionFailureStatistics) TabularData(javax.management.openmbean.TabularData) TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Example 7 with CompositeType

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

the class ManagedDynamicRouter 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 8 with CompositeType

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

the class ManagedEnricher 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 9 with CompositeType

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

the class ManagedFailoverLoadBalancer method exceptionStatistics.

@Override
public TabularData exceptionStatistics() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.loadbalancerExceptionsTabularType());
        ExceptionFailureStatistics statistics = processor.getExceptionFailureStatistics();
        Iterator<Class<?>> it = statistics.getExceptions();
        boolean empty = true;
        while (it.hasNext()) {
            empty = false;
            Class<?> exception = it.next();
            String name = ObjectHelper.name(exception);
            long counter = statistics.getFailureCounter(exception);
            CompositeType ct = CamelOpenMBeanTypes.loadbalancerExceptionsCompositeType();
            CompositeData data = new CompositeDataSupport(ct, new String[] { "exception", "failures" }, new Object[] { name, counter });
            answer.put(data);
        }
        if (empty) {
            // use Exception as a single general
            String name = ObjectHelper.name(Exception.class);
            long counter = statistics.getFailureCounter(Exception.class);
            CompositeType ct = CamelOpenMBeanTypes.loadbalancerExceptionsCompositeType();
            CompositeData data = new CompositeDataSupport(ct, new String[] { "exception", "failures" }, new Object[] { name, counter });
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
Also used : CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) ExceptionFailureStatistics(org.apache.camel.processor.loadbalancer.ExceptionFailureStatistics) TabularData(javax.management.openmbean.TabularData) TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Example 10 with CompositeType

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

the class ManagedInflightRepository method browse.

@Override
public TabularData browse(String routeId, int limit, boolean sortByLongestDuration) {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listInflightExchangesTabularType());
        Collection<InflightRepository.InflightExchange> exchanges = inflightRepository.browse(routeId, limit, sortByLongestDuration);
        for (InflightRepository.InflightExchange entry : exchanges) {
            CompositeType ct = CamelOpenMBeanTypes.listInflightExchangesCompositeType();
            String exchangeId = entry.getExchange().getExchangeId();
            String fromRouteId = entry.getFromRouteId();
            String atRouteId = entry.getAtRouteId();
            String nodeId = entry.getNodeId();
            String elapsed = "" + entry.getElapsed();
            String duration = "" + entry.getDuration();
            CompositeData data = new CompositeDataSupport(ct, new String[] { "exchangeId", "fromRouteId", "routeId", "nodeId", "elapsed", "duration" }, new Object[] { exchangeId, fromRouteId, atRouteId, nodeId, elapsed, duration });
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
Also used : InflightRepository(org.apache.camel.spi.InflightRepository) TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) TabularData(javax.management.openmbean.TabularData) CompositeType(javax.management.openmbean.CompositeType)

Aggregations

CompositeType (javax.management.openmbean.CompositeType)82 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)55 CompositeData (javax.management.openmbean.CompositeData)50 TabularDataSupport (javax.management.openmbean.TabularDataSupport)50 TabularData (javax.management.openmbean.TabularData)47 TabularType (javax.management.openmbean.TabularType)27 OpenType (javax.management.openmbean.OpenType)23 OpenDataException (javax.management.openmbean.OpenDataException)22 Map (java.util.Map)20 ObjectName (javax.management.ObjectName)7 EndpointUtilizationStatistics (org.apache.camel.spi.EndpointUtilizationStatistics)7 MBeanServer (javax.management.MBeanServer)6 ArrayType (javax.management.openmbean.ArrayType)6 ConcurrentMap (java.util.concurrent.ConcurrentMap)5 MBeanException (javax.management.MBeanException)5 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)5 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)3 DataSourceProxyImpl (com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3