brooklyn.entity.webapp.jetty.Jetty6ServerImpl Maven / Gradle / Ivy
package brooklyn.entity.webapp.jetty;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import brooklyn.enricher.Enrichers;
import brooklyn.entity.annotation.Effector;
import brooklyn.entity.annotation.EffectorParam;
import brooklyn.entity.basic.Lifecycle;
import brooklyn.entity.java.JavaAppUtils;
import brooklyn.entity.webapp.JavaWebAppSoftwareProcessImpl;
import brooklyn.entity.webapp.tomcat.TomcatServer;
import brooklyn.event.feed.jmx.JmxAttributePollConfig;
import brooklyn.event.feed.jmx.JmxFeed;
import brooklyn.util.time.Duration;
import com.google.common.base.Functions;
import com.google.common.base.Predicates;
/**
* An {@link brooklyn.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.