[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rhq-commits
Subject:    [rhq] modules/common modules/enterprise
From:       mazz <mazz () fedoraproject ! org>
Date:       2013-05-31 21:05:04
Message-ID: 20130531210504.88101610C1 () fedorahosted ! org
[Download RAW message or body]

 modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/SocketBindingJBossASClient.java \
|   73 ++++++++++  modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java \
|   49 +++++-  2 files changed, 113 insertions(+), 9 deletions(-)

New commits:
commit cf58fcee5e938f9e012753f8325c12208763407e
Author: John Mazzitelli <mazz@redhat.com>
Date:   Fri May 31 17:05:00 2013 -0400

    BZ 966160 bind some internal services to local loopback only

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
 index 247eefe..5800956 100644
--- 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
 @@ -31,6 +31,7 @@ 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 INTERFACE = "interface";
     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"; @@ -163,4 +164,76 @@ public class \
SocketBindingJBossASClient extends JBossASClient {  }
         return; // everything is OK
     }
+
+    /**
+     * Sets the interface name for the named standard socket binding.
+     * 
+     * @param socketBindingName the name of the standard socket binding whose \
interface is to be set +     * @param interfaceName the new interface name
+     * @throws Exception
+     */
+    public void setStandardSocketBindingInterface(String socketBindingName, String \
interfaceName) throws Exception { +        \
setStandardSocketBindingInterfaceExpression(socketBindingName, null, interfaceName); \
+    } +
+    /**
+     * Sets the interface name for the named standard socket binding.
+     * If sysPropName is null, this simply sets the interface name explicitly.
+     * If sysPropName is not null, this sets the interface to the expression \
"${sysPropName:interfaceName}". +     * 
+     * @param socketBindingName the name of the standard socket binding whose \
interface is to be set +     * @param sysPropName the name of the system property \
whose value is to be the interface name +     * @param interfaceName the default \
interface name if the sysPropName is not defined +     * @throws Exception
+     */
+    public void setStandardSocketBindingInterfaceExpression(String \
socketBindingName, String sysPropName, +        String interfaceName) throws \
Exception { +        setSocketBindingInterfaceExpression(STANDARD_SOCKETS, \
socketBindingName, sysPropName, interfaceName); +    }
+
+    /**
+     * Sets the interface name 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 interface is to be set +     * @param interfaceName the new interface \
name +     * @throws Exception
+     */
+    public void setSocketBindingPort(String socketBindingGroupName, String \
socketBindingName, String interfaceName) +        throws Exception {
+        setSocketBindingInterfaceExpression(socketBindingGroupName, \
socketBindingName, null, interfaceName); +    }
+
+    /**
+     * Sets the interface name for the named socket binding found in the named \
socket binding group. +     * If sysPropName is null, this simply sets the interface \
name explicitly to the given name. +     * If sysPropName is not null, this sets the \
interface name to the expression "${sysPropName:interfaceName}". +     *
+     * @param socketBindingGroupName the name of the socket binding group that has \
the named socket binding +     * @param socketBindingName the name of the socket \
binding whose interface is to be set +     * @param sysPropName the name of the \
system property whose value is to be the interface name +     * @param interfaceName \
the default interface name if the sysPropName is not defined +     * @throws \
Exception +     */
+    public void setSocketBindingInterfaceExpression(String socketBindingGroupName, \
String socketBindingName, +        String sysPropName, String interfaceName) throws \
Exception { +
+        // /socket-binding-group=standard-sockets/socket-binding=messaging/:write-attribute(name=interface,value=unsecure)
 +
+        String interfaceNameValue;
+        if (sysPropName != null) {
+            interfaceNameValue = "${" + sysPropName + ":" + interfaceName + "}";
+        } else {
+            interfaceNameValue = String.valueOf(interfaceName);
+        }
+
+        Address addr = Address.root().add(SOCKET_BINDING_GROUP, \
socketBindingGroupName, SOCKET_BINDING, +            socketBindingName);
+        ModelNode request = createWriteAttributeRequest(INTERFACE, \
interfaceNameValue, addr); +        ModelNode results = execute(request);
+        if (!isSuccess(results)) {
+            throw new FailureException(results);
+        }
+        return; // everything is OK
+    }
 }
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java \
b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java
 index 61c0853..0318e0e 100644
--- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java
                
+++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java
 @@ -95,18 +95,27 @@ public class ServerInstallUtil {
         public String sysprop;
         public int port;
         public boolean required = true;
+        public String interfaceName = null; // not null if we know we want it to be \
changed from its default setting  
         public SocketBindingInfo(String n, String s, int p) {
-            name = n;
-            sysprop = s;
-            port = p;
+            this.name = n;
+            this.sysprop = s;
+            this.port = p;
         }
 
-        public SocketBindingInfo(String name, String sysprop, int port, boolean \
required) { +        public SocketBindingInfo(String n, String s, int p, String i) {
+            this.name = n;
+            this.sysprop = s;
+            this.port = p;
+            this.interfaceName = i;
+        }
+
+        public SocketBindingInfo(String name, String sysprop, int port, String \
interfaceName, boolean required) {  this.name = name;
+            this.sysprop = sysprop;
             this.port = port;
+            this.interfaceName = interfaceName;
             this.required = required;
-            this.sysprop = sysprop;
         }
     }
 
@@ -126,9 +135,9 @@ public class ServerInstallUtil {
         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));
+            "rhq.server.socket.binding.port.messaging", 4445, "management"));
         defaultSocketBindings.add(new \
                SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_MESSAGING_THRUPUT,
                
-            "rhq.server.socket.binding.port.messaging-throughput", 4455));
+            "rhq.server.socket.binding.port.messaging-throughput", 4455, \
                "management"));
         defaultSocketBindings.add(new \
SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_MGMT_HTTP,  \
                "jboss.management.http.port", 6990));
         defaultSocketBindings.add(new \
SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_MGMT_HTTPS, @@ -136,7 \
                +145,7 @@ public class ServerInstallUtil {
         defaultSocketBindings.add(new \
SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_MGMT_NATIVE,  \
                "jboss.management.native.port", 6999));
         defaultSocketBindings.add(new \
                SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_REMOTING,
                
-            "rhq.server.socket.binding.port.remoting", 3447));
+            "rhq.server.socket.binding.port.remoting", 3447, "management"));
         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, @@ \
-1514,6 +1523,7 @@ public class ServerInstallUtil {  
     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 @@ -1535,9 +1545,30 @@ public class ServerInstallUtil \
{  throw e;
                 }
                 else {
-                    LOG.info(String.format("Setting socket binding: [%s] resulted in \
[%s] -- this is harmless " , binding.name , e.getMessage())); // TODO log at debug \
level only? +                    LOG.info(String.format("Setting socket binding port \
for [%s] resulted in [%s] - this is harmless ", +                        \
binding.name, e.getMessage())); // TODO log at debug level only? +                }
+            }
+
+            // if we need to switch the binding's interface, do it now
+            if (binding.interfaceName != null) {
+                LOG.info(String.format("Setting socket binding [%s] to use interface \
[%s]", binding.name, +                    binding.interfaceName));
+                try {
+                    client.setStandardSocketBindingInterface(binding.name, \
binding.interfaceName); +                } catch (Exception e) {
+                    // If the binding is required, we re-throw a possible exception. \
Otherwise just log +                    if (binding.required) {
+                        throw e;
+                    } else {
+                        LOG.info(String.format(
+                            "Setting socket binding interface for [%s] resulted in \
[%s] - this is harmless ", +                            binding.name, \
e.getMessage())); // TODO log at debug level only? +                    }
                 }
             }
         }
+
+        return;
     }
 }


_______________________________________________
rhq-commits mailing list
rhq-commits@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/rhq-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic