Search in sources :

Example 16 with TabularData

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

the class ManagedValidatorRegistry method listValidators.

@SuppressWarnings("unchecked")
public TabularData listValidators() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listValidatorsTabularType());
        Collection<Validator> validators = validatorRegistry.values();
        for (Validator validator : validators) {
            CompositeType ct = CamelOpenMBeanTypes.listValidatorsCompositeType();
            DataType type = validator.getType();
            String desc = validator.toString();
            boolean isStatic = validatorRegistry.isStatic(type);
            boolean isDynamic = validatorRegistry.isDynamic(type);
            CompositeData data = new CompositeDataSupport(ct, new String[] { "type", "static", "dynamic", "description" }, new Object[] { type.toString(), isStatic, isDynamic, desc });
            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) DataType(org.apache.camel.spi.DataType) Validator(org.apache.camel.spi.Validator) TabularData(javax.management.openmbean.TabularData) CompositeType(javax.management.openmbean.CompositeType)

Example 17 with TabularData

use of javax.management.openmbean.TabularData 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 18 with TabularData

use of javax.management.openmbean.TabularData 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 19 with TabularData

use of javax.management.openmbean.TabularData 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 20 with TabularData

use of javax.management.openmbean.TabularData 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)

Aggregations

TabularData (javax.management.openmbean.TabularData)183 CompositeData (javax.management.openmbean.CompositeData)91 TabularDataSupport (javax.management.openmbean.TabularDataSupport)67 ObjectName (javax.management.ObjectName)54 MBeanServer (javax.management.MBeanServer)50 CompositeType (javax.management.openmbean.CompositeType)47 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)43 Test (org.junit.Test)38 Map (java.util.Map)28 ArrayList (java.util.ArrayList)23 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)21 HashMap (java.util.HashMap)20 TabularType (javax.management.openmbean.TabularType)17 Bundle (org.osgi.framework.Bundle)17 AbstractIntegrationTest (org.apache.aries.jmx.AbstractIntegrationTest)15 Collection (java.util.Collection)13 IOException (java.io.IOException)11 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)9 List (java.util.List)8 ServiceReference (org.osgi.framework.ServiceReference)8