Java 类org.apache.camel.ManagementStatisticsLevel 实例源码

项目:Camel    文件:ManagedRedeliverRouteOnlyTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            context.getManagementStrategy().getManagementAgent().setStatisticsLevel(ManagementStatisticsLevel.RoutesOnly);

            onException(Exception.class).handled(true)
                .maximumRedeliveries(4).logStackTrace(false)
                .setBody().constant("Error");

            from("direct:start")
                .to("mock:foo")
                .process(new Processor() {
                    public void process(Exchange exchange) throws Exception {
                        log.info("Invoking me");

                        throw new IllegalArgumentException("Damn");
                    }
                }).id("myprocessor");
        }
    };
}
项目:switchyard    文件:CamelContextConfiguratorTest.java   
@Test
public void configurePerformanceStatistics() throws Exception {
    domain.setProperty(CamelContextConfigurator.PERFORMANCE_STATISTICS, "RoutesOnly");
    CamelContextConfigurator.configure(context, domain);
    Assert.assertEquals(ManagementStatisticsLevel.RoutesOnly, 
            context.getManagementStrategy().getStatisticsLevel());

    domain.setProperty(CamelContextConfigurator.PERFORMANCE_STATISTICS, "Off");
    CamelContextConfigurator.configure(context, domain);
    Assert.assertEquals(ManagementStatisticsLevel.Off, 
            context.getManagementStrategy().getStatisticsLevel());

    domain.setProperty(CamelContextConfigurator.PERFORMANCE_STATISTICS, "All");
    CamelContextConfigurator.configure(context, domain);
    Assert.assertEquals(ManagementStatisticsLevel.All, 
            context.getManagementStrategy().getStatisticsLevel());
}
项目:Camel    文件:DefaultManagementLifecycleStrategy.java   
@Override
public void onCamelContextStarted(CamelContext context, boolean alreadyStarted) throws Exception {
    // we are disabled either if configured explicit, or if level is off
    boolean load = camelContext.getManagementStrategy().getManagementAgent().getLoadStatisticsEnabled() != null
            && camelContext.getManagementStrategy().getManagementAgent().getLoadStatisticsEnabled();
    boolean disabled = !load || camelContext.getManagementStrategy().getStatisticsLevel() == ManagementStatisticsLevel.Off;

    LOG.debug("Load performance statistics {}", disabled ? "disabled" : "enabled");
    if (!disabled) {
        // must use 1 sec interval as the load statistics is based on 1 sec calculations
        loadTimer.setInterval(1000);
        // we have to defer enlisting timer lister manager as a service until CamelContext has been started
        getCamelContext().addService(loadTimer);
    }
}
项目:Camel    文件:DefaultManagementStrategy.java   
@Deprecated
public void setStatisticsLevel(ManagementStatisticsLevel level) {
    LOG.warn("Using @deprecated option statisticsLevel on ManagementStrategy. Configure this on ManagementAgent instead.");
    if (managementAgent != null) {
        getManagementAgent().setStatisticsLevel(level);
    } else {
        throw new IllegalStateException("Not started");
    }
}
项目:Camel    文件:DefaultManagementStrategy.java   
@Deprecated
public ManagementStatisticsLevel getStatisticsLevel() {
    if (managementAgent != null) {
        return getManagementAgent().getStatisticsLevel();
    } else {
        throw new IllegalStateException("Not started");
    }
}
项目:Camel    文件:ManagedRoute.java   
@Override
public void init(ManagementStrategy strategy) {
    super.init(strategy);
    boolean enabled = context.getManagementStrategy().getManagementAgent().getStatisticsLevel() != ManagementStatisticsLevel.Off;
    setStatisticsEnabled(enabled);

    exchangesInFlightKeys.clear();
    exchangesInFlightStartTimestamps.clear();
}
项目:Camel    文件:ManagedStatisticsLevelOffTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    // disable it by default
    context.getManagementStrategy().getManagementAgent().setStatisticsLevel(ManagementStatisticsLevel.Off);
    return context;
}
项目:Camel    文件:ManagedStatisticsLevelRoutesOnlyTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();

    // only routes
    context.getManagementStrategy().getManagementAgent().setStatisticsLevel(ManagementStatisticsLevel.RoutesOnly);
    return context;
}
项目:switchyard    文件:CamelContextConfiguratorTest.java   
@Test
public void configureCamelContextXML() throws Exception {
    domain.setProperty(CamelContextConfigurator.CAMEL_CONTEXT_CONFIG_XML, PATH_CAMEL_CONTEXT_XML);

    Assert.assertNull(context.getProperty("abc"));
    Assert.assertNotEquals("foobar-camel-context", context.getName());
    Assert.assertEquals(false, context.isUseMDCLogging());
    Assert.assertEquals(ManagementStatisticsLevel.All
            , context.getManagementStrategy().getStatisticsLevel());
    Assert.assertEquals(true, context.isAllowUseOriginalMessage());
    Assert.assertEquals(false, context.isStreamCaching());

    context.start();

    Assert.assertNotNull(context.getProperty("abc"));
    Assert.assertEquals("xyz", context.getProperty("abc"));
    Assert.assertEquals("foobar-camel-context", context.getName());
    Assert.assertEquals(true, context.isUseMDCLogging());
    Assert.assertEquals(ManagementStatisticsLevel.RoutesOnly
            , context.getManagementStrategy().getStatisticsLevel());
    Assert.assertEquals(false, context.isAllowUseOriginalMessage());
    Assert.assertEquals(true, context.isStreamCaching());
    DataFormatDefinition dfd = context.getDataFormats().get("transform-json");
    Assert.assertNotNull(dfd);
    Assert.assertEquals("json-jackson", dfd.getDataFormatName());
    Assert.assertTrue(dfd instanceof JsonDataFormat);

    MockEndpoint mock = context.getEndpoint("mock:output", MockEndpoint.class);
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived("foobar-input");
    context.createProducerTemplate().sendBody("direct:input", "foobar-input");
    mock.assertIsSatisfied();

}
项目:switchyard    文件:DomainCamelContextConfigurationTest.java   
@Test
public void testConfiguration() throws Exception {
    Assert.assertNotNull(_camelContext.getProperty("abc"));
    Assert.assertEquals("xyz", _camelContext.getProperty("abc"));
    Assert.assertEquals("foobar-camel-context", _camelContext.getName());
    Assert.assertEquals(true, _camelContext.isUseMDCLogging());
    Assert.assertEquals(ManagementStatisticsLevel.RoutesOnly
            , _camelContext.getManagementStrategy().getStatisticsLevel());
    Assert.assertEquals(false, _camelContext.isAllowUseOriginalMessage());
    Assert.assertEquals(true, _camelContext.isStreamCaching());
    DataFormatDefinition dfd = _camelContext.getDataFormats().get("transform-json");
    Assert.assertNotNull(dfd);
    Assert.assertEquals("json-jackson", dfd.getDataFormatName());
    Assert.assertTrue(dfd instanceof JsonDataFormat);

    MockEndpoint mock = _camelContext.getEndpoint("mock:output", MockEndpoint.class);
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived("foobar-input");
    _camelContext.createProducerTemplate().sendBody("direct:input", "foobar-input");
    mock.assertIsSatisfied();

    // CamelContext should be able to find CDI beans produced by this class from registry.
    Assert.assertEquals(true, _camelContext.isTracing());
    DefaultTraceFormatter formatter =
            (DefaultTraceFormatter) ((Tracer)_camelContext.getDefaultTracer()).getFormatter();
    Assert.assertEquals(false, formatter.isShowBody());
    Assert.assertEquals(false, formatter.isShowBreadCrumb());
    Assert.assertEquals(100, formatter.getMaxChars());

    @SuppressWarnings("deprecation")
    ErrorHandlerBuilder builder = _camelContext.getErrorHandlerBuilder();
    Assert.assertEquals(ErrorHandlerBuilderRef.class, builder.getClass());
    Assert.assertEquals("foobarErrorHandler", ((ErrorHandlerBuilderRef)builder).getRef());
}
项目:camel-sjms-demo    文件:CamelContextProducer.java   
@Produces
@ApplicationScoped
public CamelContext camelContext() throws Exception {
    DefaultCamelContext context = new DefaultCamelContext();
    context.getManagementStrategy().setStatisticsLevel(ManagementStatisticsLevel.Off);

    SjmsComponent jmsComponent = new SjmsComponent();
    jmsComponent.setConnectionFactory(cf);

    context.addComponent("sjms", jmsComponent);
    context.addComponent("ejb", new EjbComponent());

    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:calculatorProxy").routeId("calculatorSource")
                .log("calculator proxy called")
                .to("sjms:calculator-queue?exchangePattern=InOut&responseTimeOut=10000");
            from("sjms:calculator-queue?exchangePattern=InOut").routeId("calculatorSink")
                .log("calling calculator impl")
                .to("ejb://java:global/sjms-demo1/CalculatorImpl");
        }

    });
    context.start();
    return context;
}
项目:camel-sjms-demo    文件:CamelContextProducer.java   
@Produces
@ApplicationScoped
public CamelContext camelContext() throws Exception {
    DefaultCamelContext context = new DefaultCamelContext();
    context.getManagementStrategy().setStatisticsLevel(ManagementStatisticsLevel.Off);

    SjmsComponent jmsComponent = new SjmsComponent();
    jmsComponent.setConnectionFactory(cf);

    context.addComponent("sjms", jmsComponent);
    context.addComponent("ejb", new EjbComponent());

    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:calculatorProxy")
                .routeId("calculatorSource")
                .log("calculator proxy called")
                .to("sjms:calculator-queue?exchangePattern=InOut&responseTimeOut=1000000&synchronous=false");
            from("sjms:calculator-queue?exchangePattern=InOut").routeId("calculatorSink")
                .log("calling calculator impl")
                .to("ejb://java:global/sjms-demo2/CalculatorImpl");
        }

    });
    context.start();
    return context;
}
项目:camel-sjms-demo    文件:CamelContextProducer.java   
@Produces
@ApplicationScoped
public CamelContext camelContext() throws Exception {
    DefaultCamelContext context = new DefaultCamelContext();
    context.setName("camel-" + applicationNameHolder.getApplicationName());
    context.getManagementStrategy().setStatisticsLevel(ManagementStatisticsLevel.Off);

    SjmsComponent jmsComponent = new SjmsComponent();
    jmsComponent.setConnectionFactory(cf);

    context.addComponent("sjms", jmsComponent);
    context.addComponent("ejb", new EjbComponent());

    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:calculatorProxy").routeId("calculatorSource")
                .log("calculator proxy called")
                .to("sjms:calculator-queue?exchangePattern=InOut");
            from("sjms:calculator-queue?exchangePattern=InOut&synchronous=false")
                .routeId("calculatorSink").log("calling calculator impl")
                .to(ejb("CalculatorImpl"));
        }

    });
    context.start();
    return context;
}
项目:Camel    文件:DefaultManagementAgent.java   
protected void finalizeSettings() throws Exception {
    // JVM system properties take precedence over any configuration
    Map<String, Object> values = new LinkedHashMap<String, Object>();

    if (System.getProperty(JmxSystemPropertyKeys.REGISTRY_PORT) != null) {
        registryPort = Integer.getInteger(JmxSystemPropertyKeys.REGISTRY_PORT);
        values.put(JmxSystemPropertyKeys.REGISTRY_PORT, registryPort);
    }
    if (System.getProperty(JmxSystemPropertyKeys.CONNECTOR_PORT) != null) {
        connectorPort = Integer.getInteger(JmxSystemPropertyKeys.CONNECTOR_PORT);
        values.put(JmxSystemPropertyKeys.CONNECTOR_PORT, connectorPort);
    }
    if (System.getProperty(JmxSystemPropertyKeys.DOMAIN) != null) {
        mBeanServerDefaultDomain = System.getProperty(JmxSystemPropertyKeys.DOMAIN);
        values.put(JmxSystemPropertyKeys.DOMAIN, mBeanServerDefaultDomain);
    }
    if (System.getProperty(JmxSystemPropertyKeys.MBEAN_DOMAIN) != null) {
        mBeanObjectDomainName = System.getProperty(JmxSystemPropertyKeys.MBEAN_DOMAIN);
        values.put(JmxSystemPropertyKeys.MBEAN_DOMAIN, mBeanObjectDomainName);
    }
    if (System.getProperty(JmxSystemPropertyKeys.SERVICE_URL_PATH) != null) {
        serviceUrlPath = System.getProperty(JmxSystemPropertyKeys.SERVICE_URL_PATH);
        values.put(JmxSystemPropertyKeys.SERVICE_URL_PATH, serviceUrlPath);
    }
    if (System.getProperty(JmxSystemPropertyKeys.CREATE_CONNECTOR) != null) {
        createConnector = Boolean.getBoolean(JmxSystemPropertyKeys.CREATE_CONNECTOR);
        values.put(JmxSystemPropertyKeys.CREATE_CONNECTOR, createConnector);
    }
    if (System.getProperty(JmxSystemPropertyKeys.ONLY_REGISTER_PROCESSOR_WITH_CUSTOM_ID) != null) {
        onlyRegisterProcessorWithCustomId = Boolean.getBoolean(JmxSystemPropertyKeys.ONLY_REGISTER_PROCESSOR_WITH_CUSTOM_ID);
        values.put(JmxSystemPropertyKeys.ONLY_REGISTER_PROCESSOR_WITH_CUSTOM_ID, onlyRegisterProcessorWithCustomId);
    }
    if (System.getProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS) != null) {
        usePlatformMBeanServer = Boolean.getBoolean(JmxSystemPropertyKeys.USE_PLATFORM_MBS);
        values.put(JmxSystemPropertyKeys.USE_PLATFORM_MBS, usePlatformMBeanServer);
    }
    if (System.getProperty(JmxSystemPropertyKeys.REGISTER_ALWAYS) != null) {
        registerAlways = Boolean.getBoolean(JmxSystemPropertyKeys.REGISTER_ALWAYS);
        values.put(JmxSystemPropertyKeys.REGISTER_ALWAYS, registerAlways);
    }
    if (System.getProperty(JmxSystemPropertyKeys.REGISTER_NEW_ROUTES) != null) {
        registerNewRoutes = Boolean.getBoolean(JmxSystemPropertyKeys.REGISTER_NEW_ROUTES);
        values.put(JmxSystemPropertyKeys.REGISTER_NEW_ROUTES, registerNewRoutes);
    }
    if (System.getProperty(JmxSystemPropertyKeys.MASK) != null) {
        mask = Boolean.getBoolean(JmxSystemPropertyKeys.MASK);
        values.put(JmxSystemPropertyKeys.MASK, mask);
    }
    if (System.getProperty(JmxSystemPropertyKeys.INCLUDE_HOST_NAME) != null) {
        includeHostName = Boolean.getBoolean(JmxSystemPropertyKeys.INCLUDE_HOST_NAME);
        values.put(JmxSystemPropertyKeys.INCLUDE_HOST_NAME, includeHostName);
    }
    if (System.getProperty(JmxSystemPropertyKeys.CREATE_CONNECTOR) != null) {
        createConnector = Boolean.getBoolean(JmxSystemPropertyKeys.CREATE_CONNECTOR);
        values.put(JmxSystemPropertyKeys.CREATE_CONNECTOR, createConnector);
    }
    if (System.getProperty(JmxSystemPropertyKeys.LOAD_STATISTICS_ENABLED) != null) {
        loadStatisticsEnabled = Boolean.getBoolean(JmxSystemPropertyKeys.LOAD_STATISTICS_ENABLED);
        values.put(JmxSystemPropertyKeys.LOAD_STATISTICS_ENABLED, loadStatisticsEnabled);
    }
    if (System.getProperty(JmxSystemPropertyKeys.ENDPOINT_RUNTIME_STATISTICS_ENABLED) != null) {
        endpointRuntimeStatisticsEnabled = Boolean.getBoolean(JmxSystemPropertyKeys.ENDPOINT_RUNTIME_STATISTICS_ENABLED);
        values.put(JmxSystemPropertyKeys.ENDPOINT_RUNTIME_STATISTICS_ENABLED, endpointRuntimeStatisticsEnabled);
    }
    if (System.getProperty(JmxSystemPropertyKeys.STATISTICS_LEVEL) != null) {
        statisticsLevel = camelContext.getTypeConverter().mandatoryConvertTo(ManagementStatisticsLevel.class, System.getProperty(JmxSystemPropertyKeys.STATISTICS_LEVEL));
        values.put(JmxSystemPropertyKeys.STATISTICS_LEVEL, statisticsLevel);
    }
    if (System.getProperty(JmxSystemPropertyKeys.MANAGEMENT_NAME_PATTERN) != null) {
        managementNamePattern = System.getProperty(JmxSystemPropertyKeys.MANAGEMENT_NAME_PATTERN);
        values.put(JmxSystemPropertyKeys.MANAGEMENT_NAME_PATTERN, managementNamePattern);
    }
    if (System.getProperty(JmxSystemPropertyKeys.USE_HOST_IP_ADDRESS) != null) {
        useHostIPAddress = Boolean.getBoolean(JmxSystemPropertyKeys.USE_HOST_IP_ADDRESS);
        values.put(JmxSystemPropertyKeys.USE_HOST_IP_ADDRESS, useHostIPAddress);
    }

    if (!values.isEmpty()) {
        LOG.info("ManagementAgent detected JVM system properties: {}", values);
    }
}
项目:Camel    文件:DefaultManagementAgent.java   
public ManagementStatisticsLevel getStatisticsLevel() {
    return statisticsLevel;
}
项目:Camel    文件:DefaultManagementAgent.java   
public void setStatisticsLevel(ManagementStatisticsLevel statisticsLevel) {
    this.statisticsLevel = statisticsLevel;
}
项目:Camel    文件:ManagedCamelContext.java   
@Override
public void init(ManagementStrategy strategy) {
    super.init(strategy);
    boolean enabled = context.getManagementStrategy().getManagementAgent() != null && context.getManagementStrategy().getManagementAgent().getStatisticsLevel() != ManagementStatisticsLevel.Off;
    setStatisticsEnabled(enabled);
}
项目:Camel    文件:ManagedPollEnricherTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    context.getManagementStrategy().getManagementAgent().setStatisticsLevel(ManagementStatisticsLevel.Extended);
    return context;
}
项目:Camel    文件:ManagedWireTapTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    context.getManagementStrategy().getManagementAgent().setStatisticsLevel(ManagementStatisticsLevel.Extended);
    return context;
}
项目:Camel    文件:ManagedDynamicRouterTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    context.getManagementStrategy().getManagementAgent().setStatisticsLevel(ManagementStatisticsLevel.Extended);
    return context;
}
项目:Camel    文件:ManagedEnricherTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    context.getManagementStrategy().getManagementAgent().setStatisticsLevel(ManagementStatisticsLevel.Extended);
    return context;
}
项目:Camel    文件:ManagedRoutingSlipTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    context.getManagementStrategy().getManagementAgent().setStatisticsLevel(ManagementStatisticsLevel.Extended);
    return context;
}
项目:Camel    文件:ManagedSendDynamicProcessorTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    context.getManagementStrategy().getManagementAgent().setStatisticsLevel(ManagementStatisticsLevel.Extended);
    return context;
}
项目:Camel    文件:ManagedRecipientListTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    context.getManagementStrategy().getManagementAgent().setStatisticsLevel(ManagementStatisticsLevel.Extended);
    return context;
}
项目:Camel    文件:AbstractCamelContextFactoryBean.java   
protected void initJMXAgent() throws Exception {
    CamelJMXAgentDefinition camelJMXAgent = getCamelJMXAgent();

    boolean disabled = false;
    if (camelJMXAgent != null) {
        disabled = camelJMXAgent.getDisabled() != null && CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getDisabled());
    }

    if (disabled) {
        LOG.info("JMXAgent disabled");
        // clear the existing lifecycle strategies define by the DefaultCamelContext constructor
        getContext().getLifecycleStrategies().clear();
        // no need to add a lifecycle strategy as we do not need one as JMX is disabled
        getContext().setManagementStrategy(new DefaultManagementStrategy());
    } else if (camelJMXAgent != null) {
        LOG.info("JMXAgent enabled: {}", camelJMXAgent);
        DefaultManagementAgent agent = new DefaultManagementAgent(getContext());

        if (camelJMXAgent.getConnectorPort() != null) {
            agent.setConnectorPort(CamelContextHelper.parseInteger(getContext(), camelJMXAgent.getConnectorPort()));
        }
        if (camelJMXAgent.getCreateConnector() != null) {
            agent.setCreateConnector(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getCreateConnector()));
        }
        if (camelJMXAgent.getMbeanObjectDomainName() != null) {
            agent.setMBeanObjectDomainName(CamelContextHelper.parseText(getContext(), camelJMXAgent.getMbeanObjectDomainName()));
        }
        if (camelJMXAgent.getMbeanServerDefaultDomain() != null) {
            agent.setMBeanServerDefaultDomain(CamelContextHelper.parseText(getContext(), camelJMXAgent.getMbeanServerDefaultDomain()));
        }
        if (camelJMXAgent.getRegistryPort() != null) {
            agent.setRegistryPort(CamelContextHelper.parseInteger(getContext(), camelJMXAgent.getRegistryPort()));
        }
        if (camelJMXAgent.getServiceUrlPath() != null) {
            agent.setServiceUrlPath(CamelContextHelper.parseText(getContext(), camelJMXAgent.getServiceUrlPath()));
        }
        if (camelJMXAgent.getUsePlatformMBeanServer() != null) {
            agent.setUsePlatformMBeanServer(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getUsePlatformMBeanServer()));
        }
        if (camelJMXAgent.getOnlyRegisterProcessorWithCustomId() != null) {
            agent.setOnlyRegisterProcessorWithCustomId(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getOnlyRegisterProcessorWithCustomId()));
        }
        if (camelJMXAgent.getRegisterAlways() != null) {
            agent.setRegisterAlways(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getRegisterAlways()));
        }
        if (camelJMXAgent.getRegisterNewRoutes() != null) {
            agent.setRegisterNewRoutes(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getRegisterNewRoutes()));
        }
        if (camelJMXAgent.getIncludeHostName() != null) {
            agent.setIncludeHostName(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getIncludeHostName()));
        }
        if (camelJMXAgent.getUseHostIPAddress() != null) {
            agent.setUseHostIPAddress(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getUseHostIPAddress()));
        }
        if (camelJMXAgent.getMask() != null) {
            agent.setMask(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getMask()));
        }
        if (camelJMXAgent.getLoadStatisticsEnabled() != null) {
            agent.setLoadStatisticsEnabled(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getLoadStatisticsEnabled()));
        }
        if (camelJMXAgent.getEndpointRuntimeStatisticsEnabled() != null) {
            agent.setEndpointRuntimeStatisticsEnabled(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getEndpointRuntimeStatisticsEnabled()));
        }
        if (camelJMXAgent.getStatisticsLevel() != null) {
            String level = CamelContextHelper.parseText(getContext(), camelJMXAgent.getStatisticsLevel());
            ManagementStatisticsLevel msLevel = getContext().getTypeConverter().mandatoryConvertTo(ManagementStatisticsLevel.class, level);
            agent.setStatisticsLevel(msLevel);
        }

        ManagementStrategy managementStrategy = new ManagedManagementStrategy(getContext(), agent);
        getContext().setManagementStrategy(managementStrategy);

        // clear the existing lifecycle strategies define by the DefaultCamelContext constructor
        getContext().getLifecycleStrategies().clear();
        getContext().addLifecycleStrategy(new DefaultManagementLifecycleStrategy(getContext()));
    }
}
项目:Camel    文件:CamelServletContextListener.java   
/**
 * Initializes JMX on {@link ServletCamelContext} with the configuration from the given init parameters.
 */
private void initJmx(ServletCamelContext camelContext, Map<String, Object> parameters) throws Exception {
    // setup jmx
    Map<String, Object> properties = IntrospectionSupport.extractProperties(parameters, "jmx.");
    if (properties != null && !properties.isEmpty()) {
        String disabled = (String) properties.remove("disabled");
        boolean disableJmx = CamelContextHelper.parseBoolean(camelContext, disabled != null ? disabled : "false");
        if (disableJmx) {
            // disable JMX which is a bit special to do
            LOG.info("JMXAgent disabled");
            // clear the existing lifecycle strategies define by the DefaultCamelContext constructor
            camelContext.getLifecycleStrategies().clear();
            // no need to add a lifecycle strategy as we do not need one as JMX is disabled
            camelContext.setManagementStrategy(new DefaultManagementStrategy());
        } else {
            LOG.info("JMXAgent enabled");
            DefaultManagementAgent agent = new DefaultManagementAgent(camelContext);
            IntrospectionSupport.setProperties(agent, properties);

            ManagementStrategy managementStrategy = new ManagedManagementStrategy(camelContext, agent);
            camelContext.setManagementStrategy(managementStrategy);

            // clear the existing lifecycle strategies defined by the DefaultCamelContext constructor
            camelContext.getLifecycleStrategies().clear();
            camelContext.addLifecycleStrategy(new DefaultManagementLifecycleStrategy(camelContext));
            // set additional configuration from agent
            boolean onlyId = agent.getOnlyRegisterProcessorWithCustomId() != null && agent.getOnlyRegisterProcessorWithCustomId();
            camelContext.getManagementStrategy().onlyManageProcessorWithCustomId(onlyId);

            String statisticsLevel = (String) properties.remove("statisticsLevel");
            if (statisticsLevel != null) {
                camelContext.getManagementStrategy().setStatisticsLevel(ManagementStatisticsLevel.valueOf(statisticsLevel));
            }

            String loadStatisticsEnabled = (String) properties.remove("loadStatisticsEnabled");
            Boolean statisticsEnabled = CamelContextHelper.parseBoolean(camelContext, loadStatisticsEnabled != null ? loadStatisticsEnabled : "true");
            if (statisticsEnabled != null) {
                camelContext.getManagementStrategy().setLoadStatisticsEnabled(statisticsEnabled);
            }
        }
        // validate we could set all parameters
        if (!properties.isEmpty()) {
            throw new IllegalArgumentException("Error setting jmx parameters on CamelContext."
                    + " There are " + properties.size() + " unknown parameters. [" + properties + "]");
        }
    }
}
项目:Camel    文件:CamelConfigurationProperties.java   
public ManagementStatisticsLevel getJmxManagementStatisticsLevel() {
    return jmxManagementStatisticsLevel;
}
项目:Camel    文件:CamelConfigurationProperties.java   
public void setJmxManagementStatisticsLevel(ManagementStatisticsLevel jmxManagementStatisticsLevel) {
    this.jmxManagementStatisticsLevel = jmxManagementStatisticsLevel;
}
项目:switchyard    文件:CamelContextConfigurator.java   
private static void configurePerformanceStatistics(CamelContext context, Object value) {
    ManagementStatisticsLevel level = ManagementStatisticsLevel.valueOf(value.toString());
    context.getManagementStrategy().setStatisticsLevel(level);
}
项目:camel-cookbook-examples    文件:JmxConfigureCamelApplication.java   
public static void main(String[] args) throws Exception {
        final CamelContext context = new DefaultCamelContext();

        // Configure JMX settings
        final ManagementStrategy managementStrategy = context.getManagementStrategy();
/*
        managementStrategy.setStatisticsLevel(ManagementStatisticsLevel.All);
        managementStrategy.setLoadStatisticsEnabled(true);
*/

        // TODO: double check this is right way to get and configure Management Agent
        final ManagementAgent managementAgent = managementStrategy.getManagementAgent();
        managementAgent.setConnectorPort(1099);
        managementAgent.setServiceUrlPath("/jmxrmi/camel");
        managementAgent.setCreateConnector(false);
        managementAgent.setUsePlatformMBeanServer(true);

        // TODO: check that level Extended is same/better as ALL
        managementAgent.setStatisticsLevel(ManagementStatisticsLevel.Extended);
        managementAgent.setLoadStatisticsEnabled(true);

        // Add a simple test route
        context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("direct:start")
                    .log("${body}")
                    .to("mock:result");
            }
        });

        // Start the context
        context.start();

        // Send a couple of messages to get some route statistics
        final ProducerTemplate template = context.createProducerTemplate();
        template.sendBody("direct:start", "Hello Camel");
        template.sendBody("direct:start", "Camel Rocks!");

        // let the Camel runtime do its job for a while
        Thread.sleep(60000);

        // shutdown
        context.stop();
    }
项目:Camel    文件:ManagementStrategy.java   
/**
 * Sets the statistics level
 * <p/>
 * Default is {@link org.apache.camel.ManagementStatisticsLevel#Default}
 *
 * @param level the new level
 * @deprecated use {@link org.apache.camel.spi.ManagementAgent}
 */
@Deprecated
void setStatisticsLevel(ManagementStatisticsLevel level);
项目:Camel    文件:ManagementStrategy.java   
/**
 * Gets the statistics level
 *
 * @return the level
 * @deprecated use {@link org.apache.camel.spi.ManagementAgent}
 */
@Deprecated
ManagementStatisticsLevel getStatisticsLevel();
项目:Camel    文件:ManagementAgent.java   
/**
 * Sets the statistics level
 * <p/>
 * Default is {@link org.apache.camel.ManagementStatisticsLevel#Default}
 * <p/>
 * The level can be set to <tt>Extended</tt> to gather additional information
 *
 * @param level the new level
 */
void setStatisticsLevel(ManagementStatisticsLevel level);
项目:Camel    文件:ManagementAgent.java   
/**
 * Gets the statistics level
 *
 * @return the level
 */
ManagementStatisticsLevel getStatisticsLevel();