org.apache.brooklyn.entity.webapp.jetty.Jetty6ServerImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of brooklyn-software-webapp Show documentation
Show all versions of brooklyn-software-webapp Show documentation
Brooklyn entities for Web App software processes
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.brooklyn.entity.webapp.jetty;
import java.util.concurrent.TimeUnit;
import org.apache.brooklyn.core.entity.EntityFunctions;
import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
import org.apache.brooklyn.enricher.stock.Enrichers;
import org.apache.brooklyn.entity.java.JavaAppUtils;
import org.apache.brooklyn.entity.java.UsesJmx;
import org.apache.brooklyn.entity.webapp.JavaWebAppSoftwareProcessImpl;
import org.apache.brooklyn.feed.jmx.JmxAttributePollConfig;
import org.apache.brooklyn.feed.jmx.JmxFeed;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Functions;
import com.google.common.base.Predicates;
/**
* An {@link org.apache.brooklyn.api.entity.Entity} that represents a single Jetty instance.
*/
public class Jetty6ServerImpl extends JavaWebAppSoftwareProcessImpl implements Jetty6Server {
private static final Logger log = LoggerFactory.getLogger(Jetty6ServerImpl.class);
private volatile JmxFeed jmxFeedJetty, jmxFeedMx;
@Override
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(SERVICE_UP)
.objectName(serverMbeanName)
.attributeName("running")
.onSuccess(Functions.forPredicate(Predicates.