Search in sources :

Example 1 with ManagementStatisticsLevel

use of org.apache.camel.ManagementStatisticsLevel in project camel by apache.

the class AbstractCamelContextFactoryBean method initJMXAgent.

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()));
    }
}
Also used : ManagedManagementStrategy(org.apache.camel.management.ManagedManagementStrategy) DefaultManagementStrategy(org.apache.camel.management.DefaultManagementStrategy) ManagementStrategy(org.apache.camel.spi.ManagementStrategy) ManagedManagementStrategy(org.apache.camel.management.ManagedManagementStrategy) DefaultManagementLifecycleStrategy(org.apache.camel.management.DefaultManagementLifecycleStrategy) DefaultManagementAgent(org.apache.camel.management.DefaultManagementAgent) ManagementStatisticsLevel(org.apache.camel.ManagementStatisticsLevel) DefaultManagementStrategy(org.apache.camel.management.DefaultManagementStrategy)

Aggregations

ManagementStatisticsLevel (org.apache.camel.ManagementStatisticsLevel)1 DefaultManagementAgent (org.apache.camel.management.DefaultManagementAgent)1 DefaultManagementLifecycleStrategy (org.apache.camel.management.DefaultManagementLifecycleStrategy)1 DefaultManagementStrategy (org.apache.camel.management.DefaultManagementStrategy)1 ManagedManagementStrategy (org.apache.camel.management.ManagedManagementStrategy)1 ManagementStrategy (org.apache.camel.spi.ManagementStrategy)1