brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)
Date Fri, 19 Jun 2015 21:18:18 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32870218
  
    --- Diff: software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8ServerImpl.java
---
    @@ -0,0 +1,196 @@
    +/*
    + * 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 brooklyn.entity.webapp.jboss;
    +
    +import brooklyn.config.render.RendererHints;
    +import brooklyn.enricher.Enrichers;
    +import brooklyn.entity.Entity;
    +import brooklyn.entity.basic.Attributes;
    +import brooklyn.entity.webapp.JavaWebAppSoftwareProcessImpl;
    +import brooklyn.event.feed.http.HttpFeed;
    +import brooklyn.event.feed.http.HttpPollConfig;
    +import brooklyn.event.feed.http.HttpValueFunctions;
    +import brooklyn.location.access.BrooklynAccessUtils;
    +import brooklyn.util.guava.Functionals;
    +import com.google.common.base.Functions;
    +import com.google.common.net.HostAndPort;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.Map;
    +
    +public class Wildfly8ServerImpl extends JavaWebAppSoftwareProcessImpl implements Wildfly8Server
{
    +
    +    public static final Logger log = LoggerFactory.getLogger(Wildfly8ServerImpl.class);
    +
    +    private volatile HttpFeed httpFeed;
    +
    +    public Wildfly8ServerImpl(){
    +        super();
    +    }
    +
    +    public Wildfly8ServerImpl(@SuppressWarnings("rawtypes") Map flags){
    +        this(flags, null);
    +    }
    +
    +    public Wildfly8ServerImpl(@SuppressWarnings("rawtypes") Map flags, Entity parent)
{
    +        super(flags, parent);
    +    }
    +
    +    @Override
    +    public Class<?> getDriverInterface() {
    +        return Wildfly8Driver.class;
    +    }
    +
    +    @Override
    +    public Wildfly8Driver getDriver() {
    +        return (Wildfly8Driver) super.getDriver();
    +    }
    +    
    +    static {
    +        RendererHints.register(MANAGEMENT_URL, RendererHints.namedActionWithUrl());
    +    }
    +
    +    @Override
    +    protected void connectSensors() {
    +        super.connectSensors();
    +
    +        HostAndPort hp = BrooklynAccessUtils.getBrooklynAccessibleAddress(this,
    +                getAttribute(MANAGEMENT_HTTP_PORT) + getConfig(PORT_INCREMENT));
    +        
    +        String managementUri = String.format("http://%s:%s/management/subsystem/undertow/server/default-server/http-listener/default",
    +                hp.getHostText(), hp.getPort());
    +        setAttribute(MANAGEMENT_URL, managementUri);
    +        log.debug("JBoss sensors for "+this+" reading from "+managementUri);
    +        
    +//        Map<String, String> includeRuntimeUriVars = ImmutableMap.of("include-runtime","true");
    +        
    +        httpFeed = HttpFeed.builder()
    +                .entity(this)
    +                .period(200)
    +                .baseUri(managementUri)
    +                .credentials(getConfig(MANAGEMENT_USER), getConfig(MANAGEMENT_PASSWORD))
    +                .poll(new HttpPollConfig<Integer>(MANAGEMENT_STATUS)
    +                        .onSuccess(HttpValueFunctions.responseCode()))
    +                .poll(new HttpPollConfig<Boolean>(MANAGEMENT_URL_UP)
    +                        .onSuccess(HttpValueFunctions.responseCodeEquals(200))
    +                        .onFailureOrException(Functions.constant(false)))
    +               /*
    +                * TODO Re-enable these metrics once they are supported by Wildfly.
    +                * 
    +                * See: https://issues.jboss.org/browse/WFLY-3835 
    +                */
    +                        
    +//                .poll(new HttpPollConfig<Integer>(REQUEST_COUNT)
    +//                        .vars(includeRuntimeUriVars)
    +//                        .onSuccess(HttpValueFunctions.jsonContents("requestCount",
Integer.class)))
    +//                .poll(new HttpPollConfig<Integer>(ERROR_COUNT)
    +//                        .vars(includeRuntimeUriVars)
    +//                        .onSuccess(HttpValueFunctions.jsonContents("errorCount", Integer.class)))
    +//                .poll(new HttpPollConfig<Integer>(TOTAL_PROCESSING_TIME)
    +//                        .vars(includeRuntimeUriVars)
    +//                        .onSuccess(HttpValueFunctions.jsonContents("processingTime",
Integer.class)))
    +//                .poll(new HttpPollConfig<Integer>(MAX_PROCESSING_TIME)
    +//                        .vars(includeRuntimeUriVars)
    +//                        .onSuccess(HttpValueFunctions.jsonContents("maxTime", Integer.class)))
    +//                .poll(new HttpPollConfig<Long>(BYTES_RECEIVED)
    +//                        .vars(includeRuntimeUriVars)
    +//                        // jboss seems to report 0 even if it has received lots of
requests; dunno why.
    +//                        .onSuccess(HttpValueFunctions.jsonContents("bytesReceived",
Long.class)))
    +//                .poll(new HttpPollConfig<Long>(BYTES_SENT)
    +//                        .vars(includeRuntimeUriVars)
    +//                        .onSuccess(HttpValueFunctions.jsonContents("bytesSent", Long.class)))
    +                        
    +                .build();
    +        
    +        connectServiceUp();
    +    }
    +    
    +    protected void connectServiceUp() {
    +        connectServiceUpIsRunning();
    +        
    +        addEnricher(Enrichers.builder().updatingMap(Attributes.SERVICE_NOT_UP_INDICATORS)
    +            .from(MANAGEMENT_URL_UP)
    +            .computing(Functionals.ifNotEquals(true).value("Management URL not reachable")
)
    +            .build());
    +    }
    +    
    +    protected void disconnectServiceUp() {
    +        disconnectServiceUpIsRunning();
    +    }
    +    
    +    @Override
    +    protected void disconnectSensors() {
    +        super.disconnectSensors();
    +        
    +        if (httpFeed != null) httpFeed.stop();
    +        disconnectServiceUp();
    +    }
    +    
    +    public int getManagementHttpsPort() {
    +        return getAttribute(MANAGEMENT_HTTPS_PORT);
    +    }
    +    
    +    public int getManagementHttpPort() {
    +        return getAttribute(MANAGEMENT_HTTP_PORT);
    +    }
    +    
    +    public int getManagementNativePort() {
    +        return getAttribute(MANAGEMENT_NATIVE_PORT);
    +    }
    +    
    +    public int getPortOffset() {
    +        return getConfig(PORT_INCREMENT);
    +    }
    +    
    +    public boolean isWelcomeRootEnabled() {
    +        return false;
    +    }
    +
    +    public String getBindAddress() {
    +        return getConfig(BIND_ADDRESS);
    +    }
    +    
    +    public String getManagementBindAddress() {
    +        return getConfig(BIND_ADDRESS);
    +    }
    +    
    +    public String getUnsecureBindAddress() {
    +        return getConfig(BIND_ADDRESS);
    +    }
    +    
    +    // If empty-string, disables Management security (!) by excluding the security-realm
attribute
    +    public String getHttpManagementInterfaceSecurityRealm() {
    --- End diff --
    
    Appears not to be used. I see you took it from the JBoss7 impl. Not sure what uses that
one either!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message