public void connectSensors()

in software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/jetty/Jetty6ServerImpl.java [47:93]


    public void connectSensors() {
        super.connectSensors();
        
        if (getDriver().isJmxEnabled()) {
            String serverMbeanName = "org.mortbay.jetty:type=server,id=0";
            String statsMbeanName = "org.mortbay.jetty.handler:type=atomicstatisticshandler,id=0";

            jmxFeedJetty = JmxFeed.builder()
                    .entity(this)
                    .period(500, TimeUnit.MILLISECONDS)
                    .pollAttribute(new JmxAttributePollConfig<Boolean>(SERVICE_UP)
                            .objectName(serverMbeanName)
                            .attributeName("running")
                            .onSuccess(Functions.forPredicate(Predicates.<Object>equalTo(true)))
                            .setOnFailureOrException(false))
                    .pollAttribute(new JmxAttributePollConfig<Integer>(REQUEST_COUNT)
                            .objectName(statsMbeanName)
                            .attributeName("requests")
                            .onFailureOrException(EntityFunctions.attribute(this, REQUEST_COUNT)))
                    .pollAttribute(new JmxAttributePollConfig<Integer>(RESPONSES_4XX_COUNT)
                            .objectName(statsMbeanName)
                            .attributeName("responses4xx"))
                    .pollAttribute(new JmxAttributePollConfig<Integer>(RESPONSES_5XX_COUNT)
                            .objectName(statsMbeanName)
                            .attributeName("responses5xx"))
                    .pollAttribute(new JmxAttributePollConfig<Integer>(TOTAL_PROCESSING_TIME)
                            .objectName(statsMbeanName)
                            .attributeName("requestTimeTotal"))
                    .pollAttribute(new JmxAttributePollConfig<Integer>(MAX_PROCESSING_TIME)
                            .objectName(statsMbeanName)
                            .attributeName("requestTimeMax"))
                    // NB: requestsActive may be useful
                    .build();
            
            enrichers().add(Enrichers.builder()
                    .combining(RESPONSES_4XX_COUNT, RESPONSES_5XX_COUNT)
                    .publishing(ERROR_COUNT)
                    .computingSum()
                    .build());

            jmxFeedMx = JavaAppUtils.connectMXBeanSensors(this);
        } else {
            // if not using JMX
            log.warn("Jetty running without JMX monitoring; limited visibility of service available");
            // TODO we could do simple things, like check that web server is accepting connections
        }
    }