Search in sources :

Example 11 with TabularData

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}\""));
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) TabularData(javax.management.openmbean.TabularData)

Example 12 with TabularData

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);
    }
}
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 13 with TabularData

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);
    }
}
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 14 with TabularData

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);
    }
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) TabularData(javax.management.openmbean.TabularData) CompositeType(javax.management.openmbean.CompositeType)

Example 15 with TabularData

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);
    }
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) TabularData(javax.management.openmbean.TabularData) 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