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);
}
}
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);
}
}
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);
}
}
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);
}
}
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();
}
Aggregations