You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2015/11/25 13:17:49 UTC
[04/13] incubator-brooklyn git commit: JBoss6: support disabling
direct connection
JBoss6: support disabling direct connection
- If !isJmxEnabled then don’t do imx polling
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/b70a5565
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/b70a5565
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/b70a5565
Branch: refs/heads/master
Commit: b70a556540b794563895bfcb23080318def301ca
Parents: ec76f12
Author: Aled Sage <al...@gmail.com>
Authored: Wed Nov 18 15:36:24 2015 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Nov 24 13:53:45 2015 +0000
----------------------------------------------------------------------
.../entity/webapp/jboss/JBoss6ServerImpl.java | 62 ++++++++++++--------
.../entity/webapp/jboss/JBoss6SshDriver.java | 2 +-
.../jboss/JBoss6ServerAwsEc2LiveTest.java | 31 +++++++++-
3 files changed, 67 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b70a5565/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/jboss/JBoss6ServerImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/jboss/JBoss6ServerImpl.java b/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/jboss/JBoss6ServerImpl.java
index 2d8bc54..c977a80 100644
--- a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/jboss/JBoss6ServerImpl.java
+++ b/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/jboss/JBoss6ServerImpl.java
@@ -23,8 +23,7 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.enricher.stock.Enrichers;
+import org.apache.brooklyn.entity.java.UsesJmx;
import org.apache.brooklyn.entity.webapp.JavaWebAppSoftwareProcessImpl;
import org.apache.brooklyn.feed.jmx.JmxAttributePollConfig;
import org.apache.brooklyn.feed.jmx.JmxFeed;
@@ -63,40 +62,51 @@ public class JBoss6ServerImpl extends JavaWebAppSoftwareProcessImpl implements J
String serverMbeanName = "jboss.system:type=Server";
boolean retrieveUsageMetrics = getConfig(RETRIEVE_USAGE_METRICS);
- jmxFeed = JmxFeed.builder()
- .entity(this)
- .period(500, TimeUnit.MILLISECONDS)
- .pollAttribute(new JmxAttributePollConfig<Boolean>(SERVICE_UP)
- // TODO instead of setting SERVICE_UP directly, want to use equivalent of
- // addEnricher(Enrichers.builder().updatingMap(Attributes.SERVICE_NOT_UP_INDICATORS).key("serverMBean")...
- // but not supported in feed?
- .objectName(serverMbeanName)
- .attributeName("Started")
- .onException(Functions.constant(false))
- .suppressDuplicates(true))
- .pollAttribute(new JmxAttributePollConfig<Integer>(ERROR_COUNT)
- .objectName(requestProcessorMbeanName)
- .attributeName("errorCount")
- .enabled(retrieveUsageMetrics))
- .pollAttribute(new JmxAttributePollConfig<Integer>(REQUEST_COUNT)
- .objectName(requestProcessorMbeanName)
- .attributeName("requestCount")
- .enabled(retrieveUsageMetrics))
- .pollAttribute(new JmxAttributePollConfig<Integer>(TOTAL_PROCESSING_TIME)
- .objectName(requestProcessorMbeanName)
- .attributeName("processingTime")
- .enabled(retrieveUsageMetrics))
- .build();
+ if (isJmxEnabled()) {
+ jmxFeed = JmxFeed.builder()
+ .entity(this)
+ .period(500, TimeUnit.MILLISECONDS)
+ .pollAttribute(new JmxAttributePollConfig<Boolean>(SERVICE_UP)
+ // TODO instead of setting SERVICE_UP directly, want to use equivalent of
+ // addEnricher(Enrichers.builder().updatingMap(Attributes.SERVICE_NOT_UP_INDICATORS).key("serverMBean")...
+ // but not supported in feed?
+ .objectName(serverMbeanName)
+ .attributeName("Started")
+ .onException(Functions.constant(false))
+ .suppressDuplicates(true))
+ .pollAttribute(new JmxAttributePollConfig<Integer>(ERROR_COUNT)
+ .objectName(requestProcessorMbeanName)
+ .attributeName("errorCount")
+ .enabled(retrieveUsageMetrics))
+ .pollAttribute(new JmxAttributePollConfig<Integer>(REQUEST_COUNT)
+ .objectName(requestProcessorMbeanName)
+ .attributeName("requestCount")
+ .enabled(retrieveUsageMetrics))
+ .pollAttribute(new JmxAttributePollConfig<Integer>(TOTAL_PROCESSING_TIME)
+ .objectName(requestProcessorMbeanName)
+ .attributeName("processingTime")
+ .enabled(retrieveUsageMetrics))
+ .build();
+ } else {
+ // if not using JMX
+ log.warn(this+" running without JMX monitoring; limited visibility of service available");
+ connectServiceUpIsRunning();
+ }
}
@Override
public void disconnectSensors() {
super.disconnectSensors();
if (jmxFeed != null) jmxFeed.stop();
+ disconnectServiceUpIsRunning();
}
@Override
public Class<JBoss6Driver> getDriverInterface() {
return JBoss6Driver.class;
}
+
+ protected boolean isJmxEnabled() {
+ return (this instanceof UsesJmx) && Boolean.TRUE.equals(getConfig(UsesJmx.USE_JMX));
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b70a5565/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/jboss/JBoss6SshDriver.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/jboss/JBoss6SshDriver.java b/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/jboss/JBoss6SshDriver.java
index 30509a9..704fa2a 100644
--- a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/jboss/JBoss6SshDriver.java
+++ b/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/jboss/JBoss6SshDriver.java
@@ -134,7 +134,7 @@ public class JBoss6SshDriver extends JavaWebAppSshDriver implements JBoss6Driver
public void launch() {
Map<String,Integer> ports = new HashMap<String, Integer>();
ports.put("httpPort",getHttpPort());
- ports.put("jmxPort",getJmxPort());
+ if (isJmxEnabled()) ports.put("jmxPort",getJmxPort());
Networking.checkPortsValid(ports);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b70a5565/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java b/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java
index 8d77679..8da350c 100644
--- a/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java
+++ b/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java
@@ -18,11 +18,14 @@
*/
package org.apache.brooklyn.entity.webapp.jboss;
-import static com.google.common.base.Preconditions.checkNotNull;
import static org.testng.Assert.assertNotNull;
import org.apache.brooklyn.api.entity.EntitySpec;
import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.core.entity.Attributes;
+import org.apache.brooklyn.core.entity.EntityAsserts;
+import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
+import org.apache.brooklyn.core.location.cloud.CloudLocationConfig;
import org.apache.brooklyn.entity.AbstractEc2LiveTest;
import org.apache.brooklyn.test.Asserts;
import org.apache.brooklyn.test.HttpTestUtils;
@@ -30,6 +33,7 @@ import org.apache.brooklyn.test.support.TestResourceUnavailableException;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
/**
* A simple test of installing+running on AWS-EC2, using various OS distros and versions.
@@ -64,6 +68,31 @@ public class JBoss6ServerAwsEc2LiveTest extends AbstractEc2LiveTest {
}});
}
+ @Test(groups = {"Live"})
+ public void testWithOnlyPort22() throws Exception {
+ // CentOS-6.3-x86_64-GA-EBS-02-85586466-5b6c-4495-b580-14f72b4bcf51-ami-bb9af1d2.1
+ jcloudsLocation = mgmt.getLocationRegistry().resolve(LOCATION_SPEC, ImmutableMap.of(
+ "tags", ImmutableList.of(getClass().getName()),
+ "imageId", "us-east-1/ami-a96b01c0",
+ "hardwareId", SMALL_HARDWARE_ID));
+
+ final JBoss6Server server = app.createAndManageChild(EntitySpec.create(JBoss6Server.class)
+ .configure(JBoss6Server.PROVISIONING_PROPERTIES.subKey(CloudLocationConfig.INBOUND_PORTS.getName()), ImmutableList.of(22))
+ .configure(JBoss6Server.USE_JMX, false)
+ .configure(JBoss6Server.OPEN_IPTABLES, true)
+ .configure("war", getTestWar()));
+
+ app.start(ImmutableList.of(jcloudsLocation));
+
+ EntityAsserts.assertAttributeEqualsEventually(server, Attributes.SERVICE_UP, true);
+ EntityAsserts.assertAttributeEqualsEventually(server, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
+
+ String url = server.getAttribute(JBoss6Server.ROOT_URL);
+ assertNotNull(url);
+
+ assertViaSshLocalUrlListeningEventually(server, url);
+ }
+
@Test(enabled=false)
public void testDummy() {} // Convince testng IDE integration that this really does have test methods
}