use of javax.management.openmbean.TabularData in project camel by apache.
the class ManagedWireTapTest method testManageWireTap.
public void testManageWireTap() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MockEndpoint foo = getMockEndpoint("mock:foo");
foo.expectedMessageCount(2);
MockEndpoint bar = getMockEndpoint("mock:bar");
bar.expectedMessageCount(1);
template.sendBodyAndHeader("direct:start", "Hello World", "whereto", "foo");
template.sendBodyAndHeader("direct:start", "Bye World", "whereto", "foo");
template.sendBodyAndHeader("direct:start", "Hi World", "whereto", "bar");
assertMockEndpointsSatisfied();
// get the stats for the route
MBeanServer mbeanServer = getMBeanServer();
// get the object name for the delayer
ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"mysend\"");
// should be on route1
String routeId = (String) mbeanServer.getAttribute(on, "RouteId");
assertEquals("route1", routeId);
String camelId = (String) mbeanServer.getAttribute(on, "CamelId");
assertEquals("camel-1", camelId);
String state = (String) mbeanServer.getAttribute(on, "State");
assertEquals(ServiceStatus.Started.name(), state);
String uri = (String) mbeanServer.getAttribute(on, "Uri");
assertEquals("direct:${header.whereto}", uri);
TabularData data = (TabularData) mbeanServer.invoke(on, "extendedInformation", null, null);
assertNotNull(data);
assertEquals(2, data.size());
data = (TabularData) mbeanServer.invoke(on, "explain", new Object[] { false }, new String[] { "boolean" });
assertNotNull(data);
assertEquals(3, data.size());
data = (TabularData) mbeanServer.invoke(on, "explain", new Object[] { true }, new String[] { "boolean" });
assertNotNull(data);
assertEquals(11, data.size());
String json = (String) mbeanServer.invoke(on, "informationJson", null, null);
assertNotNull(json);
assertTrue(json.contains("\"description\": \"Routes a copy of a message (or creates a new message) to a secondary destination while continue routing the original message"));
assertTrue(json.contains(" \"uri\": { \"kind\": \"attribute\", \"required\": \"true\", \"type\": \"string\", \"javaType\": \"java.lang.String\"," + " \"deprecated\": \"false\", \"value\": \"direct:${header.whereto}\""));
}
use of javax.management.openmbean.TabularData 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 javax.management.openmbean.TabularData 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 javax.management.openmbean.TabularData in project camel by apache.
the class ManagedSendProcessor method extendedInformation.
@Override
public TabularData extendedInformation() {
try {
TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.endpointsUtilizationTabularType());
// we only have 1 endpoint
CompositeType ct = CamelOpenMBeanTypes.endpointsUtilizationCompositeType();
String url = getDestination();
Long hits = processor.getCounter();
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 javax.management.openmbean.TabularData in project camel by apache.
the class ManagedTypeConverterRegistry method listTypeConverters.
public TabularData listTypeConverters() {
try {
TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listTypeConvertersTabularType());
List<Class<?>[]> converters = registry.listAllTypeConvertersFromTo();
for (Class<?>[] entry : converters) {
CompositeType ct = CamelOpenMBeanTypes.listTypeConvertersCompositeType();
String from = entry[0].getCanonicalName();
String to = entry[1].getCanonicalName();
CompositeData data = new CompositeDataSupport(ct, new String[] { "from", "to" }, new Object[] { from, to });
answer.put(data);
}
return answer;
} catch (Exception e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
}
}
Aggregations