[jboss-cvs] JBossAS SVN: r63812 - in trunk/cluster/src: resources/jgroups and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 3 23:42:03 EDT 2007


Author: bstansberry at jboss.com
Date: 2007-07-03 23:42:03 -0400 (Tue, 03 Jul 2007)
New Revision: 63812

Modified:
   trunk/cluster/src/main/org/jboss/ha/framework/server/JChannelFactory.java
   trunk/cluster/src/resources/jgroups/multiplexer-beans.xml
Log:
[JBAS-4513] Inject naming service port into JChannelFactory

Modified: trunk/cluster/src/main/org/jboss/ha/framework/server/JChannelFactory.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/server/JChannelFactory.java	2007-07-04 03:40:13 UTC (rev 63811)
+++ trunk/cluster/src/main/org/jboss/ha/framework/server/JChannelFactory.java	2007-07-04 03:42:03 UTC (rev 63812)
@@ -56,6 +56,7 @@
    
    private InetAddress nodeAddress;
    private String nodeName;
+   private int namingServicePort = -1;
 
    /**
     * Overrides the superclass version by generating a unique node id
@@ -108,6 +109,16 @@
       this.nodeName = nodeName;
    }
 
+   public int getNamingServicePort()
+   {
+      return namingServicePort;
+   }
+
+   public void setNamingServicePort(int jndiPort)
+   {
+      this.namingServicePort = jndiPort;
+   }
+
    private void setChannelUniqueId(Channel channel) throws Exception
    {
       IpAddress address = (IpAddress) channel.getLocalAddress();
@@ -175,35 +186,17 @@
 
       // 1st: is JNDI up and running?
       //
-      try
+      if (namingServicePort > 0)
       {
-         MBeanServer server = MBeanServerLocator.locateJBoss();
-         AttributeList al = server.getAttributes(NamingServiceMBean.OBJECT_NAME,
-                                      new String[] {"State", "Port"});
-
-         int status = ((Integer)((Attribute)al.get(0)).getValue()).intValue();
-         if (status == ServiceMBean.STARTED)
-         {
-            // we can proceed with the JNDI trick!
-            int port = ((Integer)((Attribute)al.get(1)).getValue()).intValue();
-            return hostIP + ":" + port;
-         }
-         else
-         {
-            log.debug("JNDI has been found but the service wasn't started so we cannot " +
-                      "be entirely sure we are the only one that wants to use this PORT " +
-                      "as a GUID on this host.");
-         }
-
+         // we can proceed with the JNDI trick!
+         return hostIP + ":" + namingServicePort;
       }
-      catch (InstanceNotFoundException e)
+      else
       {
-         log.debug ("JNDI not running here, cannot use this strategy to find a node GUID for the cluster");
+         log.debug("JNDI has been found but the service wasn't started so we cannot " +
+                   "be entirely sure we are the only one that wants to use this PORT " +
+                   "as a GUID on this host.");
       }
-      catch (ReflectionException e)
-      {
-         log.debug ("JNDI querying has returned an exception, cannot use this strategy to find a node GUID for the cluster");
-      }
 
       // 2nd: host-GUID strategy
       //

Modified: trunk/cluster/src/resources/jgroups/multiplexer-beans.xml
===================================================================
--- trunk/cluster/src/resources/jgroups/multiplexer-beans.xml	2007-07-04 03:40:13 UTC (rev 63811)
+++ trunk/cluster/src/resources/jgroups/multiplexer-beans.xml	2007-07-04 03:42:03 UTC (rev 63812)
@@ -15,6 +15,8 @@
         <!-- The address used to determine the node name  -->
         <property name="nodeAddress">${jboss.bind.address}</property>
         
+        <!-- Naming Service Port is used to generate a unique node name -->
+        <property name="namingServicePort"><inject bean="jboss:service=Naming" property="Port"/></property>
 	</bean>
 	
     <!-- The JMX wrapper for the factory -->




More information about the jboss-cvs-commits mailing list