Search in sources :

Example 1 with CamelRouteMBean

use of io.fabric8.camel.facade.mbean.CamelRouteMBean in project fabric8 by jboss-fuse.

the class CamelBackwardsCompatibleSupport method dumpRoutesStatsAsXml.

/**
 * This operation is only available from Apache Camel 2.10, and Fuse Camel 2.9 onwards.
 */
public static String dumpRoutesStatsAsXml(CamelFacade facade, String contextId) throws Exception {
    StringBuilder sb = new StringBuilder();
    sb.append("<camelContextStat").append(String.format(" id=\"%s\"", contextId)).append(">\n");
    // gather all the routes for this CamelContext, which requires JMX
    List<CamelRouteMBean> routes = facade.getRoutes(contextId);
    List<CamelProcessorMBean> processors = facade.getProcessors(contextId);
    // loop the routes, and append the processor stats if needed
    sb.append("  <routeStats>\n");
    for (CamelRouteMBean route : routes) {
        sb.append("    <routeStat").append(String.format(" id=\"%s\"", route.getRouteId()));
        sb.append(" ").append(dumpStatsAsXmlAttributes(route)).append(">\n");
        // add processor details if needed
        sb.append("      <processorStats>\n");
        for (CamelProcessorMBean processor : processors) {
            // the processor must belong to this route
            if (route.getRouteId().equals(processor.getRouteId())) {
                sb.append("        <processorStat").append(String.format(" id=\"%s\"", processor.getProcessorId()));
                sb.append(" ").append(dumpStatsAsXmlAttributes(processor)).append("/>\n");
            }
        }
        sb.append("      </processorStats>\n");
        sb.append("    </routeStat>\n");
    }
    sb.append("  </routeStats>\n");
    sb.append("</camelContextStat>");
    return sb.toString();
}
Also used : CamelProcessorMBean(io.fabric8.camel.facade.mbean.CamelProcessorMBean) CamelRouteMBean(io.fabric8.camel.facade.mbean.CamelRouteMBean)

Aggregations

CamelProcessorMBean (io.fabric8.camel.facade.mbean.CamelProcessorMBean)1 CamelRouteMBean (io.fabric8.camel.facade.mbean.CamelRouteMBean)1