Search in sources :

Example 1 with ExceptionFailureStatistics

use of org.apache.camel.processor.loadbalancer.ExceptionFailureStatistics 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 2 with ExceptionFailureStatistics

use of org.apache.camel.processor.loadbalancer.ExceptionFailureStatistics 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

CompositeData (javax.management.openmbean.CompositeData)2 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)2 CompositeType (javax.management.openmbean.CompositeType)2 TabularData (javax.management.openmbean.TabularData)2 TabularDataSupport (javax.management.openmbean.TabularDataSupport)2 ExceptionFailureStatistics (org.apache.camel.processor.loadbalancer.ExceptionFailureStatistics)2