in software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/tomcat/TomcatServerImpl.java [51:97]
public void connectSensors() {
super.connectSensors();
if (getDriver().isJmxEnabled()) {
String requestProcessorMbeanName = "Catalina:type=GlobalRequestProcessor,name=\"http-*\"";
Integer port = isHttpsEnabled() ? getAttribute(HTTPS_PORT) : getAttribute(HTTP_PORT);
String connectorMbeanName = format("Catalina:type=Connector,port=%s", port);
boolean retrieveUsageMetrics = getConfig(RETRIEVE_USAGE_METRICS);
jmxWebFeed = JmxFeed.builder()
.entity(this)
.period(3000, TimeUnit.MILLISECONDS)
.pollAttribute(new JmxAttributePollConfig<Boolean>(SERVICE_PROCESS_IS_RUNNING)
// TODO Want to use something different from SERVICE_PROCESS_IS_RUNNING,
// to indicate this is jmx MBean's reported state (or failure to connect)
.objectName(connectorMbeanName)
.attributeName("stateName")
.onSuccess(Functions.forPredicate(Predicates.<Object>equalTo("STARTED")))
.setOnFailureOrException(false)
.suppressDuplicates(true))
.pollAttribute(new JmxAttributePollConfig<String>(CONNECTOR_STATUS)
.objectName(connectorMbeanName)
.attributeName("stateName")
.suppressDuplicates(true))
.pollAttribute(new JmxAttributePollConfig<Integer>(ERROR_COUNT)
.objectName(requestProcessorMbeanName)
.attributeName("errorCount")
.enabled(retrieveUsageMetrics))
.pollAttribute(new JmxAttributePollConfig<Integer>(REQUEST_COUNT)
.objectName(requestProcessorMbeanName)
.attributeName("requestCount")
.enabled(retrieveUsageMetrics)
.onFailureOrException(EntityFunctions.attribute(this, REQUEST_COUNT)))
.pollAttribute(new JmxAttributePollConfig<Integer>(TOTAL_PROCESSING_TIME)
.objectName(requestProcessorMbeanName)
.attributeName("processingTime")
.enabled(retrieveUsageMetrics))
.build();
jmxAppFeed = JavaAppUtils.connectMXBeanSensors(this);
} else {
// if not using JMX
LOG.warn("Tomcat running without JMX monitoring; limited visibility of service available");
connectServiceUpIsRunning();
}
}