modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/SocketBindingJBossASClient.java
| 166 ++++++++++
modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
| 7
modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
| 67 ++++
modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
| 35 +-
4 files changed, 261 insertions(+), 14 deletions(-)
New commits:
commit cf4b61137ffc434db9243bca6a24f7a284f5dd92
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Sep 25 14:03:26 2012 -0400
set the ports as defined in rhq-server.properties
diff --git
a/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/SocketBindingJBossASClient.java
b/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/SocketBindingJBossASClient.java
new file mode 100644
index 0000000..247eefe
--- /dev/null
+++
b/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/SocketBindingJBossASClient.java
@@ -0,0 +1,166 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2012 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.common.jbossas.client.controller;
+
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.dmr.ModelNode;
+
+/**
+ * Provides convenience methods associated with socket binding management.
+ *
+ * @author John Mazzitelli
+ */
+public class SocketBindingJBossASClient extends JBossASClient {
+
+ public static final String SOCKET_BINDING_GROUP = "socket-binding-group";
+ public static final String SOCKET_BINDING = "socket-binding";
+ public static final String PORT = "port";
+ public static final String PORT_OFFSET = "port-offset";
+ public static final String STANDARD_SOCKETS = "standard-sockets";
+ public static final String JBOSS_SYSPROP_PORT_OFFSET =
"jboss.socket.binding.port-offset";
+ public static final String DEFAULT_BINDING_MGMT_NATIVE =
"management-native";
+ public static final String DEFAULT_BINDING_MGMT_HTTP = "management-http";
+ public static final String DEFAULT_BINDING_MGMT_HTTPS =
"management-https";
+ public static final String DEFAULT_BINDING_AJP = "ajp";
+ public static final String DEFAULT_BINDING_HTTP = "http";
+ public static final String DEFAULT_BINDING_HTTPS = "https";
+ public static final String DEFAULT_BINDING_JACORB = "jacorb";
+ public static final String DEFAULT_BINDING_JACORB_SSL = "jacorb-ssl";
+ public static final String DEFAULT_BINDING_MESSAGING = "messaging";
+ public static final String DEFAULT_BINDING_MESSAGING_THRUPUT =
"messaging-throughput";
+ public static final String DEFAULT_BINDING_OSGI_HTTP = "osgi-http";
+ public static final String DEFAULT_BINDING_REMOTING = "remoting";
+ public static final String DEFAULT_BINDING_TXN_RECOVERY_ENV =
"txn-recovery-environment";
+ public static final String DEFAULT_BINDING_TXN_STATUS_MGR =
"txn-status-manager";
+
+ public SocketBindingJBossASClient(ModelControllerClient client) {
+ super(client);
+ }
+
+ /**
+ * Sets the port offset for the socket bindings found in the standard socket binding
group.
+ * This will configure the offset to be allowed to be overridden by the standard
+ * {@link #JBOSS_SYSPROP_PORT_OFFSET} system property.
+ *
+ * @param offset the new port offset
+ * @throws Exception
+ */
+ public void setStandardPortOffset(int offset) throws Exception {
+ setPortOffset(STANDARD_SOCKETS, JBOSS_SYSPROP_PORT_OFFSET, offset);
+ }
+
+ /**
+ * Sets the port offset for the socket bindings found in the named socket binding
group.
+ * If sysPropName is null, this simply sets the offset explicitly to the given
offset.
+ * If sysPropName is not null, this sets the offset to the expression
"${sysPropName:offset}".
+ * You typically will want to use the standard {@link #JBOSS_SYSPROP_PORT_OFFSET}
system property
+ * name as the sysPropName to follow the normal out-of-box JBossAS configuration,
though you don't have to.
+ *
+ * @param socketBindingGroupName name of the socket binding group whose port offset
is to be set
+ * @param sysPropName the name of the system property whose value is to be the port
offset
+ * @param offset the default port offset if the sysPropName is not defined
+ * @throws Exception
+ */
+ public void setPortOffset(String socketBindingGroupName, String sysPropName, int
offset) throws Exception {
+ String offsetValue;
+ if (sysPropName != null) {
+ offsetValue = "${" + sysPropName + ":" + offset +
"}";
+ } else {
+ offsetValue = String.valueOf(offset);
+ }
+
+ Address addr = Address.root().add(SOCKET_BINDING_GROUP, socketBindingGroupName);
+ ModelNode request = createWriteAttributeRequest(PORT_OFFSET, offsetValue, addr);
+ ModelNode results = execute(request);
+ if (!isSuccess(results)) {
+ throw new FailureException(results);
+ }
+ return; // everything is OK
+ }
+
+ /**
+ * Sets the port number for the named standard socket binding.
+ *
+ * @param socketBindingName the name of the standard socket binding whose port is to
be set
+ * @param port the new port number
+ * @throws Exception
+ */
+ public void setStandardSocketBindingPort(String socketBindingName, int port) throws
Exception {
+ setStandardSocketBindingPortExpression(socketBindingName, null, port);
+ }
+
+ /**
+ * Sets the port number for the named standard socket binding.
+ * If sysPropName is null, this simply sets the port number explicitly to the given
port number.
+ * If sysPropName is not null, this sets the port to the expression
"${sysPropName:port}".
+ *
+ * @param socketBindingName the name of the standard socket binding whose port is to
be set
+ * @param sysPropName the name of the system property whose value is to be the port
number
+ * @param port the default port number if the sysPropName is not defined
+ * @throws Exception
+ */
+ public void setStandardSocketBindingPortExpression(String socketBindingName, String
sysPropName, int port)
+ throws Exception {
+ setSocketBindingPortExpression(STANDARD_SOCKETS, socketBindingName, sysPropName,
port);
+ }
+
+ /**
+ * Sets the port number for the named socket binding found in the named socket
binding group.
+ *
+ * @param socketBindingGroupName the name of the socket binding group that has the
named socket binding
+ * @param socketBindingName the name of the socket binding whose port is to be set
+ * @param port the new port number
+ * @throws Exception
+ */
+ public void setSocketBindingPort(String socketBindingGroupName, String
socketBindingName, int port)
+ throws Exception {
+ setSocketBindingPortExpression(socketBindingGroupName, socketBindingName, null,
port);
+ }
+
+ /**
+ * Sets the port number for the named socket binding found in the named socket
binding group.
+ * If sysPropName is null, this simply sets the port number explicitly to the given
port number.
+ * If sysPropName is not null, this sets the port to the expression
"${sysPropName:port}".
+ *
+ * @param socketBindingGroupName the name of the socket binding group that has the
named socket binding
+ * @param socketBindingName the name of the socket binding whose port is to be set
+ * @param sysPropName the name of the system property whose value is to be the port
number
+ * @param port the default port number if the sysPropName is not defined
+ * @throws Exception
+ */
+ public void setSocketBindingPortExpression(String socketBindingGroupName, String
socketBindingName,
+ String sysPropName, int port) throws Exception {
+
+ String portValue;
+ if (sysPropName != null) {
+ portValue = "${" + sysPropName + ":" + port +
"}";
+ } else {
+ portValue = String.valueOf(port);
+ }
+
+ Address addr = Address.root().add(SOCKET_BINDING_GROUP, socketBindingGroupName,
SOCKET_BINDING,
+ socketBindingName);
+ ModelNode request = createWriteAttributeRequest(PORT, portValue, addr);
+ ModelNode results = execute(request);
+ if (!isSuccess(results)) {
+ throw new FailureException(results);
+ }
+ return; // everything is OK
+ }
+}
diff --git
a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
index e285655..9c0f871 100644
---
a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
+++
b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
@@ -331,10 +331,15 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet
implements Ins
// create a keystore whose cert has a CN of this server's public endpoint
address
ServerInstallUtil.createKeystore(serverDetails, getAppServerConfigDir());
- // Make sure our deployment scanner is configured to be ready for deploy our
services and application
+ // perform stuff that has to get done via the JBossAS management client
ModelControllerClient mcc = null;
try {
mcc = getModelControllerClient();
+
+ // ensure the server info is up to date and stored in the DB
+ ServerInstallUtil.setSocketBindings(mcc, serverProperties);
+
+ // Make sure our deployment scanner is configured to be ready for deploy our
services and application
ServerInstallUtil.configureDeploymentScanner(mcc);
} finally {
safeClose(mcc);
diff --git
a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
index 1fc4388..aa3faff 100644
---
a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
+++
b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
@@ -54,6 +54,7 @@ import
org.rhq.common.jbossas.client.controller.InfinispanJBossASClient;
import org.rhq.common.jbossas.client.controller.JBossASClient;
import org.rhq.common.jbossas.client.controller.MessagingJBossASClient;
import org.rhq.common.jbossas.client.controller.SecurityDomainJBossASClient;
+import org.rhq.common.jbossas.client.controller.SocketBindingJBossASClient;
import org.rhq.core.db.DatabaseType;
import org.rhq.core.db.DatabaseTypeFactory;
import org.rhq.core.db.DbUtil;
@@ -97,6 +98,53 @@ public class ServerInstallUtil {
}
}
+ private static class SocketBindingInfo {
+ public String name;
+ public String sysprop;
+ public int port;
+
+ public SocketBindingInfo(String n, String s, int p) {
+ name = n;
+ sysprop = s;
+ port = p;
+ }
+ }
+
+ private static final ArrayList<SocketBindingInfo> defaultSocketBindings;
+ static {
+ // all ports are -1000 from out-of-box AS7 defaults
+ // except for the jboss.management ones - those are -3000 from their out-of-box
defaults
+ defaultSocketBindings = new ArrayList<SocketBindingInfo>();
+ defaultSocketBindings.add(new
SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_AJP,
+ "rhq.server.socket.binding.port.ajp", 7009));
+ defaultSocketBindings.add(new
SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_HTTP,
+ "rhq.server.socket.binding.port.http", 7080));
+ defaultSocketBindings.add(new
SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_HTTPS,
+ "rhq.server.socket.binding.port.https", 7443));
+ defaultSocketBindings.add(new
SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_JACORB,
+ "rhq.server.socket.binding.port.jacorb", 2528));
+ defaultSocketBindings.add(new
SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_JACORB_SSL,
+ "rhq.server.socket.binding.port.jacorb-ssl", 2529));
+ defaultSocketBindings.add(new
SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_MESSAGING,
+ "rhq.server.socket.binding.port.messaging", 4445));
+ defaultSocketBindings.add(new
SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_MESSAGING_THRUPUT,
+ "rhq.server.socket.binding.port.messaging-throughput", 4455));
+ defaultSocketBindings.add(new
SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_MGMT_HTTP,
+ "jboss.management.http.port", 6990));
+ defaultSocketBindings.add(new
SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_MGMT_HTTPS,
+ "jboss.management.https.port", 6443));
+ defaultSocketBindings.add(new
SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_MGMT_NATIVE,
+ "jboss.management.native.port", 6999));
+ defaultSocketBindings.add(new
SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_OSGI_HTTP,
+ "rhq.server.socket.binding.port.osgi-http", 7090));
+ defaultSocketBindings.add(new
SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_REMOTING,
+ "rhq.server.socket.binding.port.remoting", 3447));
+ defaultSocketBindings.add(new
SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_TXN_RECOVERY_ENV,
+ "rhq.server.socket.binding.port.txn-recovery-environment", 3712));
+ defaultSocketBindings.add(new
SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_TXN_STATUS_MGR,
+ "rhq.server.socket.binding.port.txn-status-manager", 3713));
+ }
+
private static final String RHQ_DATASOURCE_NAME_NOTX = "NoTxRHQDS";
private static final String RHQ_DATASOURCE_NAME_XA = "RHQDS";
private static final String RHQ_DS_SECURITY_DOMAIN =
"RHQDSSecurityDomain";
@@ -1203,4 +1251,23 @@ public class ServerInstallUtil {
return markerFile.exists();
}
+ public static void setSocketBindings(ModelControllerClient mcc, HashMap<String,
String> serverProperties)
+ throws Exception {
+ final SocketBindingJBossASClient client = new SocketBindingJBossASClient(mcc);
+ for (SocketBindingInfo binding : defaultSocketBindings) {
+ // use the port defined by the server's properties if set, otherwise,
just use our hardcoded default
+ int newPort = binding.port;
+ String overrideValue = serverProperties.get(binding.sysprop);
+ if (overrideValue != null) {
+ try {
+ newPort = Integer.parseInt(overrideValue);
+ } catch (Exception e) {
+ LOG.warn("Invalid port in system property [" +
binding.sysprop + "]: " + overrideValue);
+ }
+ }
+ LOG.info(String.format("Setting socket binding [%s] to [${%s:%d}]",
binding.name, binding.sysprop, newPort));
+ client.setStandardSocketBindingPortExpression(binding.name, binding.sysprop,
newPort);
+ }
+ }
+
}
diff --git a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
index 9bca2a2..f060121 100644
--- a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
@@ -356,29 +356,38 @@
rhq.server.quartz.driverDelegateClass=${rhq.server.quartz.driverDelegateClass}
rhq.server.quartz.selectWithLockSQL=${rhq.server.quartz.selectWithLockSQL}
rhq.server.quartz.lockHandlerClass=${rhq.server.quartz.lockHandlerClass}
-# Container configuration
+# Host and Port Bindings
+jboss.bind.address=0.0.0.0
+jboss.bind.address.management=127.0.0.1
+
+jboss.socket.binding.port-offset=0
+
+jboss.management.native.port=6999
+jboss.management.http.port=6990
+jboss.management.https.port=6443
+
+rhq.server.socket.binding.port.ajp=7009
+rhq.server.socket.binding.port.http=7080
+rhq.server.socket.binding.port.https=7443
+rhq.server.socket.binding.port.jacorb=2528
+rhq.server.socket.binding.port.jacorb-ssl=2529
+rhq.server.socket.binding.port.messaging=4445
+rhq.server.socket.binding.port.messaging-throughput=4455
+rhq.server.socket.binding.port.osgi-http=7090
+rhq.server.socket.binding.port.remoting=3447
+rhq.server.socket.binding.port.txn-recovery-environment=3712
+rhq.server.socket.binding.port.txn-status-manager=3713
+
# ********************************** NOTE ************************************
# If the jboss.bind.address property is set to anything besides 0.0.0.0,
# uncomment the java.rmi.server.hostname property below and set it to the same
# value - setting it to ${jboss.bind.address} will *not* work.
-jboss.bind.address=0.0.0.0
#java.rmi.server.hostname=0.0.0.0
# High Availability (HA)
rhq.server.high-availability.name=
rhq.server.maintenance-mode-at-startup=false
-# General Properties
-rhq.server.startup.web.http.port=${rhq.server.http.port}
-rhq.server.startup.web.https.port=${rhq.server.https.port}
-rhq.server.startup.namingservice.port=2099
-rhq.server.startup.namingservice.rmiport=2098
-rhq.server.startup.jrmpinvoker.rmiport=7444
-rhq.server.startup.pooledinvoker.rmiport=7445
-rhq.server.startup.ajp.port=9009
-rhq.server.startup.unifiedinvoker.port=5446
-rhq.server.startup.aspectdeployer.bind-port=4873
-
# RHQ Server's remote endpoint for agents to talk to
# bind-address and bind-port are derived from the HA server definition,
# if you set the address/port here, they will override the HA server definition found in
the database