18.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
The core clustering service used to manage HA-JNDI's clustered proxies and to make the group RPCs that find locally-bound objects on other nodes. See Section 17.1.4, “The HAPartition Service” for more details.
distributedTreeManager
A handler for the replicated tree. The standard handler uses JBoss Cache to manage the replicated tree. The cache instance is retrieved by the injected HAPartitionCacheHandler bean. See Section 17.1.4, “The HAPartition Service” for more details.
localNamingInstance
A reference to the local JNDI service.
lookupPool
The thread pool used to provide threads to handle the bootstrap and automatic discoveery lookups.
Besides the above dependency injected services, the available configuration attributes for the HA-JNDI bean are as follows:
bindAddress
The address to which the HA-JNDI server binds to listen for naming proxy requests from JNP clients. The default value is the value of the jboss.bind.address system property, if set with the -b switch at server startup.
port
Specifies the port to which HA-JNDI binds to listen for naming proxy download requests from JNP clients. The default value is obtained from the ServiceBindingManager bean configured in conf/bootstrap/bindings.xml. The default value is 100.
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 binds to listen for RMI requests from naming proxies. The default value is the value of the jboss.bind.address system property, if set with the -b switch on server startup. If the property is not set, the default value is localhost.
rmiPort
Specifies the port to which the server binds 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
A Boolean flaga that disables configuration of the automatic discovery multicast listener. The default value is false.
autoDiscoveryAddress
Specifies the multicast address on which to listen for JNDI automatic discovery. The default value is the value of the jboss.partition.udpGroup system property, if set with the -u switch on server startup; otherwise, the default is 230.0.0.4.
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 listens for auto-discovery request packets. If this attribute is not specified and a bindAddress is specified, the bindAddress will be used.
autoDiscoveryTTL
Specifies the time-to-live (TTL) for automatic discovery IP multicast packets. This value represents the number of network hops that a multicast packet is allowed to make before networking equipment drops the packet.
loadBalancePolicy
Specifies the class name of the LoadBalancePolicy implementation to be included in the client proxy.
clientSocketFactory
An optional attribute that specifies the fully-qualified class name of the java.rmi.server.RMIServerSocketFactory used to create client sockets. The default value is null.
serverSocketFactory
An optional attribute that specifies the fully qualified class name of the java.rmi.server.RMIServerSocketFactory used to create server sockets. The default value is null.

18.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>