Search in sources :

Example 1 with EndpointUtilizationStatistics

use of org.apache.camel.spi.EndpointUtilizationStatistics in project camel by apache.

the class ManagedRoutingSlip 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 2 with EndpointUtilizationStatistics

use of org.apache.camel.spi.EndpointUtilizationStatistics in project camel by apache.

the class ManagedSendDynamicProcessor 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 3 with EndpointUtilizationStatistics

use of org.apache.camel.spi.EndpointUtilizationStatistics 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 4 with EndpointUtilizationStatistics

use of org.apache.camel.spi.EndpointUtilizationStatistics 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 5 with EndpointUtilizationStatistics

use of org.apache.camel.spi.EndpointUtilizationStatistics in project camel by apache.

the class DefaultProducerCacheTest method testExtendedStatistics.

public void testExtendedStatistics() throws Exception {
    ProducerCache cache = new ProducerCache(this, context, 5);
    cache.setExtendedStatistics(true);
    cache.start();
    assertEquals("Size should be 0", 0, cache.size());
    // use 1 = 2 times
    // use 2 = 3 times
    // use 3..4 = 1 times
    // use 5 = 0 times
    Endpoint e = new MyEndpoint(true, 1);
    Producer p = cache.acquireProducer(e);
    cache.releaseProducer(e, p);
    e = new MyEndpoint(true, 1);
    p = cache.acquireProducer(e);
    cache.releaseProducer(e, p);
    e = new MyEndpoint(true, 2);
    p = cache.acquireProducer(e);
    cache.releaseProducer(e, p);
    e = new MyEndpoint(true, 2);
    p = cache.acquireProducer(e);
    cache.releaseProducer(e, p);
    e = new MyEndpoint(true, 2);
    p = cache.acquireProducer(e);
    cache.releaseProducer(e, p);
    e = new MyEndpoint(true, 3);
    p = cache.acquireProducer(e);
    cache.releaseProducer(e, p);
    e = new MyEndpoint(true, 4);
    p = cache.acquireProducer(e);
    cache.releaseProducer(e, p);
    assertEquals("Size should be 4", 4, cache.size());
    EndpointUtilizationStatistics stats = cache.getEndpointUtilizationStatistics();
    assertEquals(4, stats.size());
    Map<String, Long> recent = stats.getStatistics();
    assertEquals(2, recent.get("my://1").longValue());
    assertEquals(3, recent.get("my://2").longValue());
    assertEquals(1, recent.get("my://3").longValue());
    assertEquals(1, recent.get("my://4").longValue());
    assertNull(recent.get("my://5"));
    cache.stop();
}
Also used : Endpoint(org.apache.camel.Endpoint) Producer(org.apache.camel.Producer) EndpointUtilizationStatistics(org.apache.camel.spi.EndpointUtilizationStatistics)

Aggregations

EndpointUtilizationStatistics (org.apache.camel.spi.EndpointUtilizationStatistics)8 Map (java.util.Map)7 CompositeData (javax.management.openmbean.CompositeData)7 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)7 CompositeType (javax.management.openmbean.CompositeType)7 TabularData (javax.management.openmbean.TabularData)7 TabularDataSupport (javax.management.openmbean.TabularDataSupport)7 Endpoint (org.apache.camel.Endpoint)1 Producer (org.apache.camel.Producer)1