22.3. JBoss configuration

The hajndi-jboss-beans.xml file in the <JBOSS_HOME>/server/production/deploy/cluster directory includes the following bean to enable HA-JNDI services.
<bean name="HAJNDI" class="org.jboss.ha.jndi.HANamingService">    

      <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX
      (name="jboss:service=HAJNDI", 
         exposedInterface=org.jboss.ha.jndi.HANamingServiceMBean.class)</annotation>  
      
      <!-- The partition used for group RPCs to find locally bound objects on other nodes -->
      <property name="HAPartition"><inject bean="HAPartition"/></property>
      
      <!-- Handler for the replicated tree -->
      <property name="distributedTreeManager">
         <bean class="org.jboss.ha.jndi.impl.jbc.JBossCacheDistributedTreeManager">
            <property name="cacheHandler"><inject bean="HAPartitionCacheHandler"/></property>
         </bean>
      </property>
      
      <property name="localNamingInstance">
         <inject bean="jboss:service=NamingBeanImpl" property="namingInstance"/>
      </property>
      
      <!-- The thread pool used to control the bootstrap and auto discovery lookups -->
      <property name="lookupPool"><inject bean="jboss.system:service=ThreadPool"/></property>
      
      <!-- Bind address of bootstrap endpoint -->
      <property name="bindAddress">${jboss.bind.address}</property>
      <!-- Port on which the HA-JNDI stub is made available -->
      <property name="port">
         <!-- Get the port from the ServiceBindingManager -->
         <value-factory bean="ServiceBindingManager" method="getIntBinding">
            <parameter>jboss:service=HAJNDI</parameter>
            <parameter>Port</parameter>
         </value-factory>
      </property>
      
      <!-- Bind address of the HA-JNDI RMI endpoint -->
      <property name="rmiBindAddress">${jboss.bind.address}</property>
      
      <!-- RmiPort to be used by the HA-JNDI service once bound. 0 = ephemeral. -->
      <property name="rmiPort">
         <!-- Get the port from the ServiceBindingManager -->
         <value-factory bean="ServiceBindingManager" method="getIntBinding">
            <parameter>jboss:service=HAJNDI</parameter>
            <parameter>RmiPort</parameter>
         </value-factory>
      </property>
      
      <!-- Accept backlog of the bootstrap socket -->
      <property name="backlog">50</property>

      <!-- A flag to disable the auto discovery via multicast -->
      <property name="discoveryDisabled">false</property>
      <!-- Set the auto-discovery bootstrap multicast bind address. If not 
      specified and a BindAddress is specified, the BindAddress will be used. -->
      <property name="autoDiscoveryBindAddress">${jboss.bind.address}</property>
      <!-- Multicast Address and group port used for auto-discovery -->
      <property name="autoDiscoveryAddress">${jboss.partition.udpGroup:230.0.0.4}</property>
      <property name="autoDiscoveryGroup">1102</property>
      <!-- The TTL (time-to-live) for autodiscovery IP multicast packets -->
      <property name="autoDiscoveryTTL">16</property>
      
      <!-- The load balancing policy for HA-JNDI -->
      <property name="loadBalancePolicy">org.jboss.ha.framework.interfaces.RoundRobin</property>

      <!-- Client socket factory to be used for client-server
           RMI invocations during JNDI queries
      <property name="clientSocketFactory">custom</property>
      -->
      <!-- Server socket factory to be used for client-server
           RMI invocations during JNDI queries
      <property name="serverSocketFactory">custom</property>
      -->
   </bean>
You can see that this bean has a number of other services injected into different properties:
  • HAPartition accepts the core clustering service used manage HA-JNDI's clustered proxies and to make the group RPCs that find locally bound objects on other nodes. See Section 21.3, “The HAPartition Service” for more.
  • distributedTreeManager accepts a handler for the replicated tree. The standard handler uses JBoss Cache to manage the replicated tree. The JBoss Cache instance is retrieved using the injected HAPartitionCacheHandler bean. See Section 21.3, “The HAPartition Service” for more details.
  • localNamingInstance accepts the reference to the local JNDI service.
  • lookupPool accepts the thread pool used to provide threads to handle the bootstrap and auto discovery lookups.
Besides the above dependency injected services, the available configuration attributes for the HA-JNDI bean are as follows:
  • bindAddress specifies the address to which the HA-JNDI server will bind to listen for naming proxy download requests from JNP clients. The default value is the value of the jboss.bind.address system property, or localhost if that property is not set. The jboss.bind.address system property is set if the -b command line switch is used when JBoss is started.
  • port specifies the port to which the HA-JNDI server will bind to listen for naming proxy download requests from JNP clients. The value is obtained from the ServiceBindingManager bean configured in conf/bootstrap/bindings.xml. The default value is 1100.
  • backlog specifies the maximum queue length for incoming connection indications for the TCP server socket on which the service listens for naming proxy download requests from JNP clients. The default value is 50.
  • rmiBindAddress specifies the address to which the HA-JNDI server will bind to listen for RMI requests (e.g. for JNDI lookups) from naming proxies. The default value is the value of the jboss.bind.address system property, or localhost if that property is not set. The jboss.bind.address system property is set if the -b command line switch is used when JBoss is started.
  • rmiPort specifies the port to which the server will bind to communicate with the downloaded stub. The value is obtained from the ServiceBindingManager bean configured in conf/bootstrap/bindings.xml. The default value is 1101. If no value is set, the operating system automatically assigns a port.
  • discoveryDisabled is a boolean flag that disables configuration of the auto discovery multicast listener. The default is false.
  • autoDiscoveryAddress specifies the multicast address to listen to for JNDI automatic discovery. The default value is the value of the jboss.partition.udpGroup system property, or 230.0.0.4 if that is not set. The jboss.partition.udpGroup system property is set if the -u command line switch is used when JBoss is started.
  • autoDiscoveryGroup specifies the port to listen on for multicast JNDI automatic discovery packets. The default value is 1102.
  • autoDiscoveryBindAddress sets the interface on which HA-JNDI should listen for auto-discovery request packets. If this attribute is not specified and a bindAddress is specified, the bindAddress will be used.
  • autoDiscoveryTTL specifies the TTL (time-to-live) for autodiscovery IP multicast packets. This value represents the number of network hops a multicast packet can be allowed to propagate before networking equipment should drop the packet. Despite its name, it does not represent a unit of time.
  • loadBalancePolicy specifies the class name of the LoadBalancePolicy implementation that should be included in the client proxy. See Chapter 19, Introduction and Quick Start the Introduction and Quick Start chapter for details.
  • clientSocketFactory is an optional attribute that specifies the fully qualified classname of the java.rmi.server.RMIClientSocketFactory that should be used to create client sockets. The default is null.
  • serverSocketFactory is an optional attribute that specifies the fully qualified classname of the java.rmi.server.RMIServerSocketFactory that should be used to create server sockets. The default is null.

22.3.1. Adding a Second HA-JNDI Service

It is possible to start several HA-JNDI services that use different HAPartitions. This can be used, for example, if a node is part of many logical clusters. In this case, make sure that you set a different port or IP address for each service. For instance, if you wanted to hook up HA-JNDI to the example cluster you set up and change the binding port, the bean descriptor would look as follows (properties that do not vary from the standard deployments are omitted):
   <-- Cache Handler for secondary HAPartition -->
   <bean name="SecondaryHAPartitionCacheHandler"
         class="org.jboss.ha.framework.server.HAPartitionCacheHandlerImpl">
         <property name="cacheManager"><inject bean="CacheManager"/></property>
         <property name="cacheConfigName">secondary-ha-partition</property>
   </bean>
   
   <-- The secondary HAPartition -->
   <bean name="SecondaryHAPartition" class="org.jboss.ha.framework.server.ClusterPartition">     

      <depends>jboss:service=Naming</depends>
       
      <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX
      (name="jboss:service=HAPartition,partition=SecondaryPartition", 
      exposedInterface=org.jboss.ha.framework.server.ClusterPartitionMBean.class, registerDirectly=true)</annotation>
       
      <property name="cacheHandler"><inject bean="SecondaryHAPartitionCacheHandler"/></property>
               
      <property name="partitionName">SecondaryPartition</property>
      
      ....      
   </bean>
   
   <bean name="MySpecialPartitionHAJNDI" class="org.jboss.ha.jndi.HANamingService">    

      <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX
      (name="jboss:service=HAJNDI,partitionName=SecondaryPartition", 
         exposedInterface=org.jboss.ha.jndi.HANamingServiceMBean.class)</annotation>  
      
      <property name="HAPartition"><inject bean="SecondaryHAPartition"/></property>
      
      <property name="distributedTreeManager">
         <bean class="org.jboss.ha.jndi.impl.jbc.JBossCacheDistributedTreeManager">
            <property name="cacheHandler"><inject bean="SecondaryHAPartitionPartitionCacheHandler"/></property>
         </bean>
      </property>
      
      <property name="port">56789</property>
      
      <property name="rmiPort">56790</property>
      
      <property name="autoDiscoveryGroup">56791</property>
      
      .....
   </bean>