You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by mikezaccardo <gi...@git.apache.org> on 2015/05/01 01:43:12 UTC

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

GitHub user mikezaccardo opened a pull request:

    https://github.com/apache/incubator-brooklyn/pull/621

    Wildfly 8 Support (Partial)

    Wildfly 8 is now partially supported.  `brooklyn.entity.webapp.jboss.WildflyServer` can now be used in place of `brooklyn.entity.webapp.jboss.JBoss7Server` in the example blueprints.
    
    However, Wildfly 8's Undertow subsystem does not yet provide several required statistics that are used by certain policies -- for example, an auto-scaling policy configured to use the requests-per-second metric would not yet work.
    
    The JBoss / Wildfly live tests have been refactored and Wildfly 8 live tests have been added (integration tests not yet added).  Note that they will not yet pass due to the missing metrics.
    
    See: https://issues.apache.org/jira/browse/BROOKLYN-142

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/mikezaccardo/incubator-brooklyn feature/wildfly-support

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-brooklyn/pull/621.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #621
    
----
commit 3d0c4688f37eaceda7546fb2ea5fcba4059205ed
Author: Duncan Grant <du...@cloudsoftcorp.com>
Date:   2014-11-27T09:34:58Z

    wip

commit 51e22e201d9a420d0308b3b78b0ccf6c38de9f80
Author: Mike Zaccardo <mi...@cloudsoftcorp.com>
Date:   2015-04-30T16:50:21Z

    Update management URI for undertow and remove requests for unsupported
    metrics

commit 128f082a4dde68759429e95a247e483710b8e355
Author: Mike Zaccardo <mi...@cloudsoftcorp.com>
Date:   2015-04-30T16:51:40Z

    Enable undertow statistics and remove old web config

commit d395ef934c07ced191c1f15a58865140df76c341
Author: Mike Zaccardo <mi...@cloudsoftcorp.com>
Date:   2015-04-30T17:17:20Z

    Fix class name and remove unused imports

commit 4ee9e8a050cc8fa0aef538146443fdc8f6df18e7
Author: Mike Zaccardo <mi...@cloudsoftcorp.com>
Date:   2015-04-30T17:32:54Z

    Extract password hashing method to parent class and some cleanup

commit 93ed13600570c2eb58c35c85483d83a65f606c69
Author: Mike Zaccardo <mi...@cloudsoftcorp.com>
Date:   2015-04-30T20:56:13Z

    Add Wildfly to WebAppLiveIntegrationTest

commit 8f614ca75719c419fbd4675ce48f41f47e2bdbbf
Author: Mike Zaccardo <mi...@cloudsoftcorp.com>
Date:   2015-04-30T21:45:29Z

    Add Wildfly 8 to multi-version test

commit 25856a86a984ee9bafaf3a1609de8cb2e50fe996
Author: Mike Zaccardo <mi...@cloudsoftcorp.com>
Date:   2015-04-30T22:35:01Z

    Rename all Wildfly* resources to Wildfly8*

commit e17c7459a6f68e4933f66192b43dd36ceb5263c7
Author: Mike Zaccardo <mi...@cloudsoftcorp.com>
Date:   2015-04-30T23:33:56Z

    Refactor JBoss test structure and add Wildfly 8 test classes

----


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by mikezaccardo <gi...@git.apache.org>.
Github user mikezaccardo commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#issuecomment-113662711
  
    As per discussion with @aledsage, this is not going to be merged just yet.  I will work adding tests that will pass given the incomplete state of Wildfly's metrics, and cleanup whatever else is deemed necessary.


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32871832
  
    --- Diff: software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerDockerLiveTest.java ---
    @@ -0,0 +1,44 @@
    +/*
    + * 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 org.testng.annotations.Test;
    +
    +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess;
    +import brooklyn.location.Location;
    +
    +/**
    + * A simple test of installing+running Wildfly 8 on Docker, using various OS distros and versions.
    + */
    +public class Wildfly8ServerDockerLiveTest extends JBossServerDockerLiveTest {
    --- End diff --
    
    As with the Wildfly AWS test, will this fail because the attributes aren't being set? In which case we should include a comment explaining why.
    
    Could also parameterise the `super.doTest()` to say whether to assert those attributes are non-null.


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#issuecomment-113652109
  
    Thanks @mikezaccardo - looking good. A few minor comments, some of which should be addressed and many of which should be deferred.
    
    You said in the description that the live tests "will not yet pass due to the missing metrics". Given we'll not get those metrics out of Wildfly in the short term, is there something we should do to get the live tests passing? For example, parameterise the `doTest()` method to say whether to assert the attributes have been set?
    
    Would be good to have some tests that pass, so we can regression test this after it's been merged.


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32871677
  
    --- Diff: software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossPasswordHashingTest.java ---
    @@ -18,42 +18,44 @@
      */
     package brooklyn.entity.webapp.jboss;
     
    +import static org.testng.Assert.assertEquals;
    +
     import org.testng.annotations.Test;
     
    -import static org.testng.Assert.assertEquals;
    +import brooklyn.entity.webapp.JavaWebAppSshDriver;
     
     /**
      * Expected values in tests were generated by AS7's add-user.sh script and copied here.
      */
    -public class JBoss7PasswordHashingTest {
    +public class JBossPasswordHashingTest {
     
         @Test
         public void testPasswordForManagementRealm() {
             assertEquals(
    -                JBoss7SshDriver.hashPassword("username", "password", "ManagementRealm"),
    +        		JavaWebAppSshDriver.hashPassword("username", "password", "ManagementRealm"),
    --- End diff --
    
    Strange indent - tabs instead of spaces perhaps?


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by mikezaccardo <gi...@git.apache.org>.
Github user mikezaccardo commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32875438
  
    --- Diff: software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossPasswordHashingTest.java ---
    @@ -18,42 +18,44 @@
      */
     package brooklyn.entity.webapp.jboss;
     
    +import static org.testng.Assert.assertEquals;
    +
     import org.testng.annotations.Test;
     
    -import static org.testng.Assert.assertEquals;
    +import brooklyn.entity.webapp.JavaWebAppSshDriver;
     
     /**
      * Expected values in tests were generated by AS7's add-user.sh script and copied here.
      */
    -public class JBoss7PasswordHashingTest {
    +public class JBossPasswordHashingTest {
     
         @Test
         public void testPasswordForManagementRealm() {
             assertEquals(
    -                JBoss7SshDriver.hashPassword("username", "password", "ManagementRealm"),
    +        		JavaWebAppSshDriver.hashPassword("username", "password", "ManagementRealm"),
    --- End diff --
    
    Yes since writing this code I changed my Eclipse settings so this won't happen in the future.


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by mikezaccardo <gi...@git.apache.org>.
Github user mikezaccardo commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32873455
  
    --- Diff: software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8SshDriver.java ---
    @@ -0,0 +1,249 @@
    +/*
    + * 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 static java.lang.String.format;
    +
    +import java.io.InputStream;
    +import java.util.LinkedList;
    +import java.util.List;
    +import java.util.Map;
    +
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import brooklyn.entity.basic.Entities;
    +import brooklyn.entity.basic.SoftwareProcess;
    +import brooklyn.entity.webapp.JavaWebAppSshDriver;
    +import brooklyn.location.basic.SshMachineLocation;
    +import brooklyn.util.collections.MutableList;
    +import brooklyn.util.collections.MutableMap;
    +import brooklyn.util.net.Networking;
    +import brooklyn.util.os.Os;
    +import brooklyn.util.ssh.BashCommands;
    +import brooklyn.util.text.Strings;
    +
    +import com.google.common.base.Preconditions;
    +
    +public class Wildfly8SshDriver extends JavaWebAppSshDriver implements Wildfly8Driver {
    +
    +    private static final Logger LOG = LoggerFactory.getLogger(Wildfly8SshDriver.class);
    +
    +    // TODO more configurability of config files, java memory, etc
    +
    +    public static final String SERVER_TYPE = "standalone";
    +    public static final String CONFIG_FILE = "standalone-brooklyn.xml";
    +    public static final String KEYSTORE_FILE = ".keystore";
    +    public static final String MANAGEMENT_REALM = "ManagementRealm";
    +
    +    public Wildfly8SshDriver(Wildfly8ServerImpl entity, SshMachineLocation machine) {
    +        super(entity, machine);
    +    }
    +
    +    @Override
    +    public Wildfly8ServerImpl getEntity() {
    +        return (Wildfly8ServerImpl) super.getEntity();
    +    }
    +
    +    @Override
    +    public String getSslKeystoreFile() {
    +        return Os.mergePathsUnix(getRunDir(), SERVER_TYPE, "configuration", KEYSTORE_FILE);
    +    }
    +    
    +    protected String getTemplateConfigurationUrl() {
    +        return entity.getConfig(Wildfly8Server.TEMPLATE_CONFIGURATION_URL);
    +    }
    +
    +    @Override
    +    protected String getLogFileLocation() {
    +        return Os.mergePathsUnix(getRunDir(), SERVER_TYPE, "log/server.log");
    +    }
    +
    +    @Override
    +    protected String getDeploySubdir() {
    +        return Os.mergePathsUnix(SERVER_TYPE, "deployments");
    +    }
    +
    +    private Integer getManagementHttpPort() {
    +        return entity.getAttribute(Wildfly8Server.MANAGEMENT_HTTP_PORT);
    +    }
    +
    +    private Integer getManagementHttpsPort() {
    +        return entity.getAttribute(Wildfly8Server.MANAGEMENT_HTTPS_PORT);
    +    }
    +
    +    private Integer getManagementNativePort() {
    +        return entity.getAttribute(Wildfly8Server.MANAGEMENT_NATIVE_PORT);
    +    }
    +
    +    private String getManagementUsername() {
    +        return entity.getConfig(Wildfly8Server.MANAGEMENT_USER);
    +    }
    +
    +    private String getManagementPassword() {
    +        return entity.getConfig(Wildfly8Server.MANAGEMENT_PASSWORD);
    +    }
    +
    +    @Override
    +    public void preInstall() {
    +        resolver = Entities.newDownloader(this);
    +        setExpandedInstallDir(Os.mergePaths(getInstallDir(), resolver.getUnpackedDirectoryName(format("wildfly-%s", getVersion()))));
    +    }
    +
    +    @Override
    +    public void install() {
    +        List<String> urls = resolver.getTargets();
    +        String saveAs = resolver.getFilename();
    +
    +        List<String> commands = new LinkedList<String>();
    +        commands.addAll(BashCommands.commandsToDownloadUrlsAs(urls, saveAs));
    +        commands.add(BashCommands.INSTALL_TAR);
    +        commands.add("tar xzfv " + saveAs);
    +
    +        newScript(INSTALLING)
    +                // don't set vars yet -- it resolves dependencies (e.g. DB) which we don't want until we start
    +                .environmentVariablesReset()
    +                .body.append(commands)
    +                .execute();
    +    }
    +
    +    /**
    +     * AS7 config notes and TODOs:
    --- End diff --
    
    Will investigate further!


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32869821
  
    --- 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){
    --- End diff --
    
    Don't need these constructors (just the no-arg constructor, so can miss them out entirely).
    
    We only have them in other (older) entities for backwards compatibility reasons, where folk called the constructors directly. Now everything should go through the EntitySpec mechanism for creating an entity.


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by mikezaccardo <gi...@git.apache.org>.
Github user mikezaccardo commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32875467
  
    --- Diff: software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy ---
    @@ -81,7 +83,8 @@ public class WebAppLiveIntegrationTest {
             TomcatServer tomcat = new TomcatServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT)
             JBoss6Server jboss6 = new JBoss6ServerImpl(parent:application, portIncrement:PORT_INCREMENT, jmxPort:DEFAULT_JMX_PORT)
             JBoss7Server jboss7 = new JBoss7ServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT)
    -        return [ [ tomcat ], [ jboss6 ], [ jboss7 ] ]
    +		Wildfly8Server wildfly8 = new Wildfly8ServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT)
    --- End diff --
    
    Added TODO


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32871223
  
    --- Diff: software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy ---
    @@ -81,7 +83,8 @@ public class WebAppLiveIntegrationTest {
             TomcatServer tomcat = new TomcatServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT)
             JBoss6Server jboss6 = new JBoss6ServerImpl(parent:application, portIncrement:PORT_INCREMENT, jmxPort:DEFAULT_JMX_PORT)
             JBoss7Server jboss7 = new JBoss7ServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT)
    -        return [ [ tomcat ], [ jboss6 ], [ jboss7 ] ]
    +		Wildfly8Server wildfly8 = new Wildfly8ServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT)
    --- End diff --
    
    Ah, I see we still do have code that calls entity constructors directly (and that wants to do it for Wildfly8ServerImpl).
    
    We should convert this class to Java, and see about using EntitySpec. But don't want to add yet more to this PR so let's address this another time.


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by mikezaccardo <gi...@git.apache.org>.
Github user mikezaccardo commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32875449
  
    --- Diff: software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerAwsEc2LiveTest.java ---
    @@ -0,0 +1,49 @@
    +/*
    + * 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 org.testng.annotations.Test;
    +
    +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess;
    +import brooklyn.location.Location;
    +
    +/**
    + * A simple test of installing+running Wildfly 8 on AWS-EC2, using various OS distros and versions. 
    + */
    +public class Wildfly8ServerAwsEc2LiveTest extends JBossServerAwsEc2LiveTest {
    +
    +    @Override
    +    protected void doTest(Location loc) throws Exception {
    +    	super.doTest(loc);
    +    }
    +    
    +    @Test(groups = {"Live", "Live-sanity"})
    +    @Override
    +    public void test_CentOS_6_3() throws Exception {
    --- End diff --
    
    Done


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32871592
  
    --- Diff: software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerAwsEc2LiveTest.java ---
    @@ -0,0 +1,49 @@
    +/*
    + * 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 org.testng.annotations.Test;
    +
    +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess;
    +import brooklyn.location.Location;
    +
    +/**
    + * A simple test of installing+running Wildfly 8 on AWS-EC2, using various OS distros and versions. 
    + */
    +public class Wildfly8ServerAwsEc2LiveTest extends JBossServerAwsEc2LiveTest {
    +
    +    @Override
    +    protected void doTest(Location loc) throws Exception {
    +    	super.doTest(loc);
    +    }
    +    
    +    @Test(groups = {"Live", "Live-sanity"})
    +    @Override
    +    public void test_CentOS_6_3() throws Exception {
    --- End diff --
    
    Will this fail, because `JBossServerAwsEc2LiveTest` asserts things like `assertNotNull(server.getAttribute(WebAppServiceMetrics.REQUEST_COUNT)`. But in Wildfly8ServerImpl it says "TODO Re-enable these metrics once they are supported by Wildfly", and does not set these metrics.
    
    If so, worth ensuring the tests are marked in the "WIP" group. And having a comment to explain why they'll fail.


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32869672
  
    --- Diff: software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8Server.java ---
    @@ -0,0 +1,101 @@
    +/*
    + * 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.catalog.Catalog;
    +import brooklyn.config.ConfigKey;
    +import brooklyn.entity.basic.ConfigKeys;
    +import brooklyn.entity.basic.SoftwareProcess;
    +import brooklyn.entity.proxying.ImplementedBy;
    +import brooklyn.entity.trait.HasShortName;
    +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess;
    +import brooklyn.event.AttributeSensor;
    +import brooklyn.event.basic.BasicAttributeSensorAndConfigKey;
    +import brooklyn.event.basic.BasicAttributeSensorAndConfigKey.StringAttributeSensorAndConfigKey;
    +import brooklyn.event.basic.PortAttributeSensorAndConfigKey;
    +import brooklyn.event.basic.Sensors;
    +import brooklyn.util.flags.SetFromFlag;
    +import brooklyn.util.javalang.JavaClassNames;
    +
    +@Catalog(name="Wildfly 8 Application Server", description="Wildfly: an open source Java application server from JBoss", iconUrl="classpath:///jboss-logo.png")
    +@ImplementedBy(Wildfly8ServerImpl.class)
    +public interface Wildfly8Server extends JavaWebAppSoftwareProcess, HasShortName {
    +
    +    @SetFromFlag("version")
    +    ConfigKey<String> SUGGESTED_VERSION =
    +            ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION, "8.2.0.Final");
    +
    +    @SetFromFlag("downloadUrl")
    +    BasicAttributeSensorAndConfigKey<String> DOWNLOAD_URL = new StringAttributeSensorAndConfigKey(
    +            SoftwareProcess.DOWNLOAD_URL, "http://download.jboss.org/wildfly/${version}/wildfly-${version}.tar.gz");
    +
    +    @SetFromFlag("bindAddress")
    +    BasicAttributeSensorAndConfigKey<String> BIND_ADDRESS =
    +            new StringAttributeSensorAndConfigKey("jboss.bind.address",
    +                "Address of interface JBoss should listen on, defaulting 0.0.0.0 (but could set e.g. to attributeWhenReady(HOSTNAME)", 
    +                "0.0.0.0");
    +
    +    @SetFromFlag("managementHttpPort")
    +    PortAttributeSensorAndConfigKey MANAGEMENT_HTTP_PORT =
    +            new PortAttributeSensorAndConfigKey("webapp.jboss.managementHttpPort", "Management port", "9990+");
    +
    +    @SetFromFlag("managementHttpsPort")
    +    PortAttributeSensorAndConfigKey MANAGEMENT_HTTPS_PORT =
    +            new PortAttributeSensorAndConfigKey("webapp.jboss.managementHttpsPort", "Management port", "9443+");
    +
    +    @SetFromFlag("managementNativePort")
    +    PortAttributeSensorAndConfigKey MANAGEMENT_NATIVE_PORT =
    +            new PortAttributeSensorAndConfigKey("webapp.jboss.managementNativePort", "Management native port", "10999+");
    +
    +    /**
    +     * Port increments are the standard way to run multiple instances of AS7 on the same machine.
    --- End diff --
    
    Wildlfy, rather than AS7. 


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32870410
  
    --- Diff: software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8SshDriver.java ---
    @@ -0,0 +1,249 @@
    +/*
    + * 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 static java.lang.String.format;
    +
    +import java.io.InputStream;
    +import java.util.LinkedList;
    +import java.util.List;
    +import java.util.Map;
    +
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import brooklyn.entity.basic.Entities;
    +import brooklyn.entity.basic.SoftwareProcess;
    +import brooklyn.entity.webapp.JavaWebAppSshDriver;
    +import brooklyn.location.basic.SshMachineLocation;
    +import brooklyn.util.collections.MutableList;
    +import brooklyn.util.collections.MutableMap;
    +import brooklyn.util.net.Networking;
    +import brooklyn.util.os.Os;
    +import brooklyn.util.ssh.BashCommands;
    +import brooklyn.util.text.Strings;
    +
    +import com.google.common.base.Preconditions;
    +
    +public class Wildfly8SshDriver extends JavaWebAppSshDriver implements Wildfly8Driver {
    +
    +    private static final Logger LOG = LoggerFactory.getLogger(Wildfly8SshDriver.class);
    +
    +    // TODO more configurability of config files, java memory, etc
    +
    +    public static final String SERVER_TYPE = "standalone";
    +    public static final String CONFIG_FILE = "standalone-brooklyn.xml";
    +    public static final String KEYSTORE_FILE = ".keystore";
    +    public static final String MANAGEMENT_REALM = "ManagementRealm";
    +
    +    public Wildfly8SshDriver(Wildfly8ServerImpl entity, SshMachineLocation machine) {
    +        super(entity, machine);
    +    }
    +
    +    @Override
    +    public Wildfly8ServerImpl getEntity() {
    +        return (Wildfly8ServerImpl) super.getEntity();
    +    }
    +
    +    @Override
    +    public String getSslKeystoreFile() {
    +        return Os.mergePathsUnix(getRunDir(), SERVER_TYPE, "configuration", KEYSTORE_FILE);
    +    }
    +    
    +    protected String getTemplateConfigurationUrl() {
    +        return entity.getConfig(Wildfly8Server.TEMPLATE_CONFIGURATION_URL);
    +    }
    +
    +    @Override
    +    protected String getLogFileLocation() {
    +        return Os.mergePathsUnix(getRunDir(), SERVER_TYPE, "log/server.log");
    +    }
    +
    +    @Override
    +    protected String getDeploySubdir() {
    +        return Os.mergePathsUnix(SERVER_TYPE, "deployments");
    +    }
    +
    +    private Integer getManagementHttpPort() {
    +        return entity.getAttribute(Wildfly8Server.MANAGEMENT_HTTP_PORT);
    +    }
    +
    +    private Integer getManagementHttpsPort() {
    +        return entity.getAttribute(Wildfly8Server.MANAGEMENT_HTTPS_PORT);
    +    }
    +
    +    private Integer getManagementNativePort() {
    +        return entity.getAttribute(Wildfly8Server.MANAGEMENT_NATIVE_PORT);
    +    }
    +
    +    private String getManagementUsername() {
    +        return entity.getConfig(Wildfly8Server.MANAGEMENT_USER);
    +    }
    +
    +    private String getManagementPassword() {
    +        return entity.getConfig(Wildfly8Server.MANAGEMENT_PASSWORD);
    +    }
    +
    +    @Override
    +    public void preInstall() {
    +        resolver = Entities.newDownloader(this);
    +        setExpandedInstallDir(Os.mergePaths(getInstallDir(), resolver.getUnpackedDirectoryName(format("wildfly-%s", getVersion()))));
    +    }
    +
    +    @Override
    +    public void install() {
    +        List<String> urls = resolver.getTargets();
    +        String saveAs = resolver.getFilename();
    +
    +        List<String> commands = new LinkedList<String>();
    +        commands.addAll(BashCommands.commandsToDownloadUrlsAs(urls, saveAs));
    +        commands.add(BashCommands.INSTALL_TAR);
    +        commands.add("tar xzfv " + saveAs);
    +
    +        newScript(INSTALLING)
    +                // don't set vars yet -- it resolves dependencies (e.g. DB) which we don't want until we start
    +                .environmentVariablesReset()
    +                .body.append(commands)
    +                .execute();
    +    }
    +
    +    /**
    +     * AS7 config notes and TODOs:
    --- End diff --
    
    Are all of these applicable to Wildfly as well?


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32871050
  
    --- Diff: software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8SshDriver.java ---
    @@ -0,0 +1,249 @@
    +/*
    + * 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 static java.lang.String.format;
    +
    +import java.io.InputStream;
    +import java.util.LinkedList;
    +import java.util.List;
    +import java.util.Map;
    +
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import brooklyn.entity.basic.Entities;
    +import brooklyn.entity.basic.SoftwareProcess;
    +import brooklyn.entity.webapp.JavaWebAppSshDriver;
    +import brooklyn.location.basic.SshMachineLocation;
    +import brooklyn.util.collections.MutableList;
    +import brooklyn.util.collections.MutableMap;
    +import brooklyn.util.net.Networking;
    +import brooklyn.util.os.Os;
    +import brooklyn.util.ssh.BashCommands;
    +import brooklyn.util.text.Strings;
    +
    +import com.google.common.base.Preconditions;
    +
    +public class Wildfly8SshDriver extends JavaWebAppSshDriver implements Wildfly8Driver {
    +
    +    private static final Logger LOG = LoggerFactory.getLogger(Wildfly8SshDriver.class);
    +
    +    // TODO more configurability of config files, java memory, etc
    +
    +    public static final String SERVER_TYPE = "standalone";
    +    public static final String CONFIG_FILE = "standalone-brooklyn.xml";
    +    public static final String KEYSTORE_FILE = ".keystore";
    +    public static final String MANAGEMENT_REALM = "ManagementRealm";
    +
    +    public Wildfly8SshDriver(Wildfly8ServerImpl entity, SshMachineLocation machine) {
    +        super(entity, machine);
    +    }
    +
    +    @Override
    +    public Wildfly8ServerImpl getEntity() {
    +        return (Wildfly8ServerImpl) super.getEntity();
    +    }
    +
    +    @Override
    +    public String getSslKeystoreFile() {
    +        return Os.mergePathsUnix(getRunDir(), SERVER_TYPE, "configuration", KEYSTORE_FILE);
    +    }
    +    
    +    protected String getTemplateConfigurationUrl() {
    +        return entity.getConfig(Wildfly8Server.TEMPLATE_CONFIGURATION_URL);
    +    }
    +
    +    @Override
    +    protected String getLogFileLocation() {
    +        return Os.mergePathsUnix(getRunDir(), SERVER_TYPE, "log/server.log");
    +    }
    +
    +    @Override
    +    protected String getDeploySubdir() {
    +        return Os.mergePathsUnix(SERVER_TYPE, "deployments");
    +    }
    +
    +    private Integer getManagementHttpPort() {
    +        return entity.getAttribute(Wildfly8Server.MANAGEMENT_HTTP_PORT);
    +    }
    +
    +    private Integer getManagementHttpsPort() {
    +        return entity.getAttribute(Wildfly8Server.MANAGEMENT_HTTPS_PORT);
    +    }
    +
    +    private Integer getManagementNativePort() {
    +        return entity.getAttribute(Wildfly8Server.MANAGEMENT_NATIVE_PORT);
    +    }
    +
    +    private String getManagementUsername() {
    +        return entity.getConfig(Wildfly8Server.MANAGEMENT_USER);
    +    }
    +
    +    private String getManagementPassword() {
    +        return entity.getConfig(Wildfly8Server.MANAGEMENT_PASSWORD);
    +    }
    +
    +    @Override
    +    public void preInstall() {
    +        resolver = Entities.newDownloader(this);
    +        setExpandedInstallDir(Os.mergePaths(getInstallDir(), resolver.getUnpackedDirectoryName(format("wildfly-%s", getVersion()))));
    +    }
    +
    +    @Override
    +    public void install() {
    +        List<String> urls = resolver.getTargets();
    +        String saveAs = resolver.getFilename();
    +
    +        List<String> commands = new LinkedList<String>();
    +        commands.addAll(BashCommands.commandsToDownloadUrlsAs(urls, saveAs));
    +        commands.add(BashCommands.INSTALL_TAR);
    +        commands.add("tar xzfv " + saveAs);
    +
    +        newScript(INSTALLING)
    +                // don't set vars yet -- it resolves dependencies (e.g. DB) which we don't want until we start
    +                .environmentVariablesReset()
    +                .body.append(commands)
    +                .execute();
    +    }
    +
    +    /**
    +     * AS7 config notes and TODOs:
    +     * We're using the http management interface on port managementPort
    +     * We're not using any JMX.
    +     * - AS 7 simply doesn't boot with Sun JMX enabled (https://issues.jboss.org/browse/JBAS-7427)
    +     * - 7.1 onwards uses Remoting 3, which we haven't configured
    +     * - We have generic support for jmxmp, which one could configure
    +     * We're completely disabling security on the management interface.
    +     * - In the future we probably want to use the as7/bin/add-user.sh script using config keys for user and password
    +     * - Or we could create our own security realm and use that.
    +     * We disable the root welcome page, since we can't deploy our own root otherwise
    +     * We bind all interfaces to entity.hostname, rather than 127.0.0.1.
    +     */
    +    @Override
    +    public void customize() {
    +        // Check that a password was set for the management user
    +        Preconditions.checkState(Strings.isNonBlank(getManagementUsername()), "User for management realm required");
    +        String managementPassword = getManagementPassword();
    +        if (Strings.isBlank(managementPassword)) {
    +            LOG.debug(this+" has no password specified for "+Wildfly8Server.MANAGEMENT_PASSWORD.getName()+"; using a random string");
    +            entity.setConfig(Wildfly8Server.MANAGEMENT_PASSWORD, Strings.makeRandomId(8));
    +        }
    +        String hashedPassword = hashPassword(getManagementUsername(), getManagementPassword(), MANAGEMENT_REALM);
    +
    +        // Check that ports are all configured
    +        Map<String,Integer> ports = MutableMap.<String,Integer>builder()
    +                .put("managementHttpPort", getManagementHttpPort()) 
    +                .put("managementHttpsPort", getManagementHttpsPort())
    +                .put("managementNativePort", getManagementNativePort())
    +                .build();
    +        if (isProtocolEnabled("HTTP")) {
    +            ports.put("httpPort", getHttpPort());
    +        }
    +        if (isProtocolEnabled("HTTPS")) {
    +            ports.put("httpsPort", getHttpsPort());
    +        }
    +        Networking.checkPortsValid(ports);
    +
    +        // Check hostname is defined
    +        String hostname = entity.getAttribute(SoftwareProcess.HOSTNAME);
    +        Preconditions.checkNotNull(hostname, "AS 7 entity must set hostname otherwise server will only be visible on localhost");
    +
    +        // Copy the install files to the run-dir and add the management user
    +        newScript(CUSTOMIZING)
    +                // don't set vars yet -- it resolves dependencies (e.g. DB) which we don't want until we start
    +                .environmentVariablesReset()
    +                .body.append(
    +                        format("cp -r %s/%s . || exit $!", getExpandedInstallDir(), SERVER_TYPE),
    +                        format("echo -e '\n%s=%s' >> %s/%s/configuration/mgmt-users.properties",
    +                                getManagementUsername(), hashedPassword, getRunDir(), SERVER_TYPE)
    +                    )
    +                .execute();
    +
    +        // Copy the keystore across, if there is one
    +        if (isProtocolEnabled("HTTPS")) {
    +            String keystoreUrl = Preconditions.checkNotNull(getSslKeystoreUrl(), "keystore URL must be specified if using HTTPS for "+entity);
    +            String destinationSslKeystoreFile = getSslKeystoreFile();
    +            InputStream keystoreStream = resource.getResourceFromUrl(keystoreUrl);
    +            getMachine().copyTo(keystoreStream, destinationSslKeystoreFile);
    +        }
    +
    +        // Copy the configuration file across
    +        String destinationConfigFile = Os.mergePathsUnix(getRunDir(), SERVER_TYPE, "configuration", CONFIG_FILE);
    +        copyTemplate(getTemplateConfigurationUrl(), destinationConfigFile);
    +
    +        // Copy the initial wars to the deploys directory
    +        getEntity().deployInitialWars();
    +    }
    +
    +    @Override
    +    public void launch() {
    +        entity.setAttribute(Wildfly8Server.PID_FILE, Os.mergePathsUnix(getRunDir(), PID_FILENAME));
    +
    +        // We wait for evidence of JBoss running because, using
    +        // brooklyn.ssh.config.tool.class=brooklyn.util.internal.ssh.cli.SshCliTool,
    +        // we saw the ssh session return before the JBoss process was fully running
    +        // so the process failed to start.
    +        newScript(MutableMap.of(USE_PID_FILE, false), LAUNCHING)
    +                .body.append(
    +                        "export LAUNCH_JBOSS_IN_BACKGROUND=true",
    +                        format("export JBOSS_HOME=%s", getExpandedInstallDir()),
    +                        format("export JBOSS_PIDFILE=%s/%s", getRunDir(), PID_FILENAME),
    +                        format("%s/bin/%s.sh ", getExpandedInstallDir(), SERVER_TYPE) +
    +                                format("--server-config %s ", CONFIG_FILE) +
    +                                format("-Djboss.server.base.dir=%s/%s ", getRunDir(), SERVER_TYPE) +
    +                                format("\"-Djboss.server.base.url=file://%s/%s\" ", getRunDir(), SERVER_TYPE) +
    +                                "-Djava.net.preferIPv4Stack=true " +
    +                                "-Djava.net.preferIPv6Addresses=false " +
    +                                format(" >> %s/console 2>&1 </dev/null &", getRunDir()),
    +                        "for i in {1..10}\n" +
    +                                "do\n" +
    +                                "    grep -i 'starting' "+getRunDir()+"/console && exit\n" +
    +                                "    sleep 1\n" +
    +                                "done\n" +
    +                                "echo \"Couldn't determine if process is running (console output does not contain 'starting'); continuing but may subsequently fail\""
    +                    )
    +                .execute();
    +    }
    +
    +    @Override
    +    public boolean isRunning() {
    +        return newScript(MutableMap.of(USE_PID_FILE, true), CHECK_RUNNING).execute() == 0;
    +    }
    +
    +    @Override
    +    public void stop() {
    +        newScript(MutableMap.of(USE_PID_FILE, true), STOPPING).environmentVariablesReset().execute();
    +    }
    +
    +    @Override
    +    public void kill() {
    +        newScript(MutableMap.of(USE_PID_FILE, true), KILLING).execute();
    +    }
    +
    +    @Override
    +    protected List<String> getCustomJavaConfigOptions() {
    +        return MutableList.<String>builder()
    +                .addAll(super.getCustomJavaConfigOptions())
    +                .add("-Xms200m")
    --- End diff --
    
    I'm fine with this for now because it's the same as JBoss7Server...
    
    However, would be good if this was easier to control via config. If someone wanted a different Xmx then they'd currently (probably?) have to write code to override this, rather than being able to do it in YAML.
    
    For example, maybe we should look at using `UsesJava.JAVA_OPTS` (here, in Tomcat, and in a whole bunch of other entities).
    
    Let's not do that in this PR though!


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32871843
  
    --- Diff: software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerGoogleComputeLiveTest.java ---
    @@ -0,0 +1,49 @@
    +/*
    + * 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 org.testng.annotations.Test;
    +
    +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess;
    +import brooklyn.location.Location;
    +
    +/**
    + * A simple test of installing+running Wildfly 8 on AWS-EC2, using various OS distros and versions. 
    + */
    +public class Wildfly8ServerGoogleComputeLiveTest extends JBossServerGoogleComputeLiveTest {
    +
    +    @Override
    +    protected void doTest(Location loc) throws Exception {
    +    	super.doTest(loc);
    +    }
    +    
    +    @Test(groups = {"Live"})
    +    @Override
    +    public void test_DefaultImage() throws Exception {
    +        super.test_DefaultImage();
    +    }
    +
    +    @Test(enabled=false)
    +    public void testDummy() {} // Convince testng IDE integration that this really does have test methods
    +    
    +	@Override
    +	protected Class<? extends JavaWebAppSoftwareProcess> getServerType() {
    --- End diff --
    
    strange indent


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by aledsage <gi...@git.apache.org>.
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32871600
  
    --- Diff: software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerAwsEc2LiveTest.java ---
    @@ -0,0 +1,49 @@
    +/*
    + * 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 org.testng.annotations.Test;
    +
    +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess;
    +import brooklyn.location.Location;
    +
    +/**
    + * A simple test of installing+running Wildfly 8 on AWS-EC2, using various OS distros and versions. 
    + */
    +public class Wildfly8ServerAwsEc2LiveTest extends JBossServerAwsEc2LiveTest {
    +
    +    @Override
    +    protected void doTest(Location loc) throws Exception {
    +    	super.doTest(loc);
    +    }
    +    
    +    @Test(groups = {"Live", "Live-sanity"})
    +    @Override
    +    public void test_CentOS_6_3() throws Exception {
    +        super.test_CentOS_6_3();
    +    }
    +
    +    @Test(enabled=false)
    +    public void testDummy() {} // Convince testng IDE integration that this really does have test methods  
    +
    +	@Override
    +	protected Class<? extends JavaWebAppSoftwareProcess> getServerType() {
    --- End diff --
    
    strange indent


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by mikezaccardo <gi...@git.apache.org>.
Github user mikezaccardo commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32873433
  
    --- Diff: software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8SshDriver.java ---
    @@ -0,0 +1,249 @@
    +/*
    + * 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 static java.lang.String.format;
    +
    +import java.io.InputStream;
    +import java.util.LinkedList;
    +import java.util.List;
    +import java.util.Map;
    +
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import brooklyn.entity.basic.Entities;
    +import brooklyn.entity.basic.SoftwareProcess;
    +import brooklyn.entity.webapp.JavaWebAppSshDriver;
    +import brooklyn.location.basic.SshMachineLocation;
    +import brooklyn.util.collections.MutableList;
    +import brooklyn.util.collections.MutableMap;
    +import brooklyn.util.net.Networking;
    +import brooklyn.util.os.Os;
    +import brooklyn.util.ssh.BashCommands;
    +import brooklyn.util.text.Strings;
    +
    +import com.google.common.base.Preconditions;
    +
    +public class Wildfly8SshDriver extends JavaWebAppSshDriver implements Wildfly8Driver {
    +
    +    private static final Logger LOG = LoggerFactory.getLogger(Wildfly8SshDriver.class);
    +
    +    // TODO more configurability of config files, java memory, etc
    +
    +    public static final String SERVER_TYPE = "standalone";
    +    public static final String CONFIG_FILE = "standalone-brooklyn.xml";
    +    public static final String KEYSTORE_FILE = ".keystore";
    +    public static final String MANAGEMENT_REALM = "ManagementRealm";
    +
    +    public Wildfly8SshDriver(Wildfly8ServerImpl entity, SshMachineLocation machine) {
    +        super(entity, machine);
    +    }
    +
    +    @Override
    +    public Wildfly8ServerImpl getEntity() {
    +        return (Wildfly8ServerImpl) super.getEntity();
    +    }
    +
    +    @Override
    +    public String getSslKeystoreFile() {
    +        return Os.mergePathsUnix(getRunDir(), SERVER_TYPE, "configuration", KEYSTORE_FILE);
    +    }
    +    
    +    protected String getTemplateConfigurationUrl() {
    +        return entity.getConfig(Wildfly8Server.TEMPLATE_CONFIGURATION_URL);
    +    }
    +
    +    @Override
    +    protected String getLogFileLocation() {
    +        return Os.mergePathsUnix(getRunDir(), SERVER_TYPE, "log/server.log");
    +    }
    +
    +    @Override
    +    protected String getDeploySubdir() {
    +        return Os.mergePathsUnix(SERVER_TYPE, "deployments");
    +    }
    +
    +    private Integer getManagementHttpPort() {
    +        return entity.getAttribute(Wildfly8Server.MANAGEMENT_HTTP_PORT);
    +    }
    +
    +    private Integer getManagementHttpsPort() {
    +        return entity.getAttribute(Wildfly8Server.MANAGEMENT_HTTPS_PORT);
    +    }
    +
    +    private Integer getManagementNativePort() {
    +        return entity.getAttribute(Wildfly8Server.MANAGEMENT_NATIVE_PORT);
    +    }
    +
    +    private String getManagementUsername() {
    +        return entity.getConfig(Wildfly8Server.MANAGEMENT_USER);
    +    }
    +
    +    private String getManagementPassword() {
    +        return entity.getConfig(Wildfly8Server.MANAGEMENT_PASSWORD);
    +    }
    +
    +    @Override
    +    public void preInstall() {
    +        resolver = Entities.newDownloader(this);
    +        setExpandedInstallDir(Os.mergePaths(getInstallDir(), resolver.getUnpackedDirectoryName(format("wildfly-%s", getVersion()))));
    +    }
    +
    +    @Override
    +    public void install() {
    +        List<String> urls = resolver.getTargets();
    +        String saveAs = resolver.getFilename();
    +
    +        List<String> commands = new LinkedList<String>();
    +        commands.addAll(BashCommands.commandsToDownloadUrlsAs(urls, saveAs));
    +        commands.add(BashCommands.INSTALL_TAR);
    +        commands.add("tar xzfv " + saveAs);
    +
    +        newScript(INSTALLING)
    +                // don't set vars yet -- it resolves dependencies (e.g. DB) which we don't want until we start
    +                .environmentVariablesReset()
    +                .body.append(commands)
    +                .execute();
    +    }
    +
    +    /**
    +     * AS7 config notes and TODOs:
    +     * We're using the http management interface on port managementPort
    +     * We're not using any JMX.
    +     * - AS 7 simply doesn't boot with Sun JMX enabled (https://issues.jboss.org/browse/JBAS-7427)
    +     * - 7.1 onwards uses Remoting 3, which we haven't configured
    +     * - We have generic support for jmxmp, which one could configure
    +     * We're completely disabling security on the management interface.
    +     * - In the future we probably want to use the as7/bin/add-user.sh script using config keys for user and password
    +     * - Or we could create our own security realm and use that.
    +     * We disable the root welcome page, since we can't deploy our own root otherwise
    +     * We bind all interfaces to entity.hostname, rather than 127.0.0.1.
    +     */
    +    @Override
    +    public void customize() {
    +        // Check that a password was set for the management user
    +        Preconditions.checkState(Strings.isNonBlank(getManagementUsername()), "User for management realm required");
    +        String managementPassword = getManagementPassword();
    +        if (Strings.isBlank(managementPassword)) {
    +            LOG.debug(this+" has no password specified for "+Wildfly8Server.MANAGEMENT_PASSWORD.getName()+"; using a random string");
    +            entity.setConfig(Wildfly8Server.MANAGEMENT_PASSWORD, Strings.makeRandomId(8));
    +        }
    +        String hashedPassword = hashPassword(getManagementUsername(), getManagementPassword(), MANAGEMENT_REALM);
    +
    +        // Check that ports are all configured
    +        Map<String,Integer> ports = MutableMap.<String,Integer>builder()
    +                .put("managementHttpPort", getManagementHttpPort()) 
    +                .put("managementHttpsPort", getManagementHttpsPort())
    +                .put("managementNativePort", getManagementNativePort())
    +                .build();
    +        if (isProtocolEnabled("HTTP")) {
    +            ports.put("httpPort", getHttpPort());
    +        }
    +        if (isProtocolEnabled("HTTPS")) {
    +            ports.put("httpsPort", getHttpsPort());
    +        }
    +        Networking.checkPortsValid(ports);
    +
    +        // Check hostname is defined
    +        String hostname = entity.getAttribute(SoftwareProcess.HOSTNAME);
    +        Preconditions.checkNotNull(hostname, "AS 7 entity must set hostname otherwise server will only be visible on localhost");
    +
    +        // Copy the install files to the run-dir and add the management user
    +        newScript(CUSTOMIZING)
    +                // don't set vars yet -- it resolves dependencies (e.g. DB) which we don't want until we start
    +                .environmentVariablesReset()
    +                .body.append(
    +                        format("cp -r %s/%s . || exit $!", getExpandedInstallDir(), SERVER_TYPE),
    +                        format("echo -e '\n%s=%s' >> %s/%s/configuration/mgmt-users.properties",
    +                                getManagementUsername(), hashedPassword, getRunDir(), SERVER_TYPE)
    +                    )
    +                .execute();
    +
    +        // Copy the keystore across, if there is one
    +        if (isProtocolEnabled("HTTPS")) {
    +            String keystoreUrl = Preconditions.checkNotNull(getSslKeystoreUrl(), "keystore URL must be specified if using HTTPS for "+entity);
    +            String destinationSslKeystoreFile = getSslKeystoreFile();
    +            InputStream keystoreStream = resource.getResourceFromUrl(keystoreUrl);
    +            getMachine().copyTo(keystoreStream, destinationSslKeystoreFile);
    +        }
    +
    +        // Copy the configuration file across
    +        String destinationConfigFile = Os.mergePathsUnix(getRunDir(), SERVER_TYPE, "configuration", CONFIG_FILE);
    +        copyTemplate(getTemplateConfigurationUrl(), destinationConfigFile);
    +
    +        // Copy the initial wars to the deploys directory
    +        getEntity().deployInitialWars();
    +    }
    +
    +    @Override
    +    public void launch() {
    +        entity.setAttribute(Wildfly8Server.PID_FILE, Os.mergePathsUnix(getRunDir(), PID_FILENAME));
    +
    +        // We wait for evidence of JBoss running because, using
    +        // brooklyn.ssh.config.tool.class=brooklyn.util.internal.ssh.cli.SshCliTool,
    +        // we saw the ssh session return before the JBoss process was fully running
    +        // so the process failed to start.
    +        newScript(MutableMap.of(USE_PID_FILE, false), LAUNCHING)
    +                .body.append(
    +                        "export LAUNCH_JBOSS_IN_BACKGROUND=true",
    +                        format("export JBOSS_HOME=%s", getExpandedInstallDir()),
    +                        format("export JBOSS_PIDFILE=%s/%s", getRunDir(), PID_FILENAME),
    +                        format("%s/bin/%s.sh ", getExpandedInstallDir(), SERVER_TYPE) +
    +                                format("--server-config %s ", CONFIG_FILE) +
    +                                format("-Djboss.server.base.dir=%s/%s ", getRunDir(), SERVER_TYPE) +
    +                                format("\"-Djboss.server.base.url=file://%s/%s\" ", getRunDir(), SERVER_TYPE) +
    +                                "-Djava.net.preferIPv4Stack=true " +
    +                                "-Djava.net.preferIPv6Addresses=false " +
    +                                format(" >> %s/console 2>&1 </dev/null &", getRunDir()),
    +                        "for i in {1..10}\n" +
    +                                "do\n" +
    +                                "    grep -i 'starting' "+getRunDir()+"/console && exit\n" +
    +                                "    sleep 1\n" +
    +                                "done\n" +
    +                                "echo \"Couldn't determine if process is running (console output does not contain 'starting'); continuing but may subsequently fail\""
    +                    )
    +                .execute();
    +    }
    +
    +    @Override
    +    public boolean isRunning() {
    +        return newScript(MutableMap.of(USE_PID_FILE, true), CHECK_RUNNING).execute() == 0;
    +    }
    +
    +    @Override
    +    public void stop() {
    +        newScript(MutableMap.of(USE_PID_FILE, true), STOPPING).environmentVariablesReset().execute();
    +    }
    +
    +    @Override
    +    public void kill() {
    +        newScript(MutableMap.of(USE_PID_FILE, true), KILLING).execute();
    +    }
    +
    +    @Override
    +    protected List<String> getCustomJavaConfigOptions() {
    +        return MutableList.<String>builder()
    +                .addAll(super.getCustomJavaConfigOptions())
    +                .add("-Xms200m")
    --- End diff --
    
    Created ticket: https://issues.apache.org/jira/browse/BROOKLYN-152


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32871624
  
    --- Diff: software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerGoogleComputeLiveTest.java ---
    @@ -0,0 +1,49 @@
    +/*
    + * 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 org.testng.annotations.Test;
    +
    +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess;
    +import brooklyn.location.Location;
    +
    +/**
    + * A simple test of installing+running JBoss AS7 on AWS-EC2, using various OS distros and versions. 
    + */
    +public class JBoss7ServerGoogleComputeLiveTest extends JBossServerGoogleComputeLiveTest {
    +
    +    @Override
    +    protected void doTest(Location loc) throws Exception {
    +    	super.doTest(loc);
    +    }
    +    
    +    @Test(groups = {"Live"})
    +    @Override
    +    public void test_DefaultImage() throws Exception {
    +        super.test_DefaultImage();
    +    }
    +
    +    @Test(enabled=false)
    +    public void testDummy() {} // Convince testng IDE integration that this really does have test methods
    +    
    +	@Override
    +	protected Class<? extends JavaWebAppSoftwareProcess> getServerType() {
    --- End diff --
    
    strange indent


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32871322
  
    --- Diff: software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java ---
    @@ -18,55 +18,32 @@
      */
     package brooklyn.entity.webapp.jboss;
     
    -import static com.google.common.base.Preconditions.checkNotNull;
    -import static org.testng.Assert.assertNotNull;
    -
    -import java.net.URL;
    -
    -import brooklyn.test.TestResourceUnavailableException;
     import org.testng.annotations.Test;
     
    -import brooklyn.entity.AbstractEc2LiveTest;
    -import brooklyn.entity.proxying.EntitySpec;
    +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess;
     import brooklyn.location.Location;
    -import brooklyn.test.Asserts;
    -import brooklyn.test.HttpTestUtils;
    -
    -import com.google.common.collect.ImmutableList;
     
     /**
    - * A simple test of installing+running on AWS-EC2, using various OS distros and versions. 
    + * A simple test of installing+running JBoss AS6 on AWS-EC2, using various OS distros and versions. 
      */
    -public class JBoss6ServerAwsEc2LiveTest extends AbstractEc2LiveTest {
    -    
    -    public String getTestWar() {
    -        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world-no-mapping.war");
    -        return "classpath://hello-world-no-mapping.war";
    -    }
    +public class JBoss6ServerAwsEc2LiveTest extends JBossServerAwsEc2LiveTest {
     
         @Override
         protected void doTest(Location loc) throws Exception {
    -        final JBoss6Server server = app.createAndManageChild(EntitySpec.create(JBoss6Server.class)
    -                .configure("war", getTestWar()));
    -        
    -        app.start(ImmutableList.of(loc));
    -        
    -        String url = server.getAttribute(JBoss6Server.ROOT_URL);
    -        
    -        HttpTestUtils.assertHttpStatusCodeEventuallyEquals(url, 200);
    -        HttpTestUtils.assertContentContainsText(url, "Hello");
    -        
    -        Asserts.succeedsEventually(new Runnable() {
    -            @Override public void run() {
    -                assertNotNull(server.getAttribute(JBoss6Server.REQUEST_COUNT));
    -                assertNotNull(server.getAttribute(JBoss6Server.ERROR_COUNT));
    -                assertNotNull(server.getAttribute(JBoss6Server.TOTAL_PROCESSING_TIME));
    -                assertNotNull(server.getAttribute(JBoss6Server.MAX_PROCESSING_TIME));
    -                assertNotNull(server.getAttribute(JBoss6Server.BYTES_RECEIVED));
    -                assertNotNull(server.getAttribute(JBoss6Server.BYTES_SENT));
    -            }});
    +    	super.doTest(loc);
         }
         
    +    @Test(groups = {"Live", "Live-sanity"})
    +    @Override
    +    public void test_CentOS_6_3() throws Exception {
    +        super.test_CentOS_6_3();
    +    }
    +
         @Test(enabled=false)
         public void testDummy() {} // Convince testng IDE integration that this really does have test methods  
    +
    +	@Override
    +	protected Class<? extends JavaWebAppSoftwareProcess> getServerType() {
    --- End diff --
    
    strange indentation


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by mikezaccardo <gi...@git.apache.org>.
Github user mikezaccardo commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32875402
  
    --- Diff: software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerDockerLiveTest.java ---
    @@ -0,0 +1,44 @@
    +/*
    + * 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 org.testng.annotations.Test;
    +
    +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess;
    +import brooklyn.location.Location;
    +
    +/**
    + * A simple test of installing+running Wildfly 8 on Docker, using various OS distros and versions.
    + */
    +public class Wildfly8ServerDockerLiveTest extends JBossServerDockerLiveTest {
    --- End diff --
    
    Moved all to WIP with explanation.


---
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.
---

[GitHub] incubator-brooklyn pull request: Wildfly 8 Support (Partial)

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/621#discussion_r32870079
  
    --- 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() {
    --- End diff --
    
    What is this for? Can't see it used anywhere (including not from freemarker).


---
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.
---