Chapter 11. Clustering Configuration
Prev |  | Next

## Chapter 11. Clustering Configuration

### Roy Russo

`<roy@jboss.org>`

### Julien Viet

`<julien.viet@jboss.com>`

This section covers configuring JBoss Portal to function in a clustered environment.

### Warning

As of JBoss Portal 2.2.1RC2, the CMS feature is not reliably clustered. Look for future versions for full clustering capabilities in the CMS.

## 11.1. Introduction

JBoss Portal leverages various clustered services that are found in JBoss Application Server. This section briefly details how each is leveraged:

- JBoss Cache: Used to replicate data among the different hibernate session factories that are deployed in each node of the cluster. It is also used by the authorization framework to replicate data among the different policies.

- JBoss HA Singleton:

  1. Used to make the deployer a singleton on the cluster, in order to avoid concurrency issues when deploying the various *-object.xml files. Without that, each node would try to create the same objects in the database.
  2. Used with JCR. The jackrabbit server is not able to run in a cluster by itself, therefore we make a singleton on the cluster. This provides HA-CMS, which is similar to the current HA JBossMQ provided in JBoss AS.

- HA-JNDI: Used to replicate a proxy that will talk to the HA CMS on the cluster.

### Note

JBoss Clustering details can be found in the Wiki or the clustering documentation .

## 11.2. Configuring from Source

If you have obtained the JBoss Portal source files, you can build JBoss Portal to work on a cluster in a simple process:

- Edit the file build/local.properties and set the property portal.clustered to true, then you build JBoss Portal as you normally would .

      # Build the portal for single or clustered environment
      portal.clustered=false

- Deploy the jboss-portal.sar and the appropriate datasource descriptor to JBOSS_HOME/server/all/deploy/*

## 11.3. Configuring from Binary

If you have the binary version of JBoss Portal, you will need to edit several files manually that would normally be editted for you by the build. The list below details the files and code blocks that need to be modified in each:

- jboss-portal.sar/META-INF/jboss-service.xml

         <!--
            | Uncomment in cluster mode : have the deployment of objects run as a clustered singleton
            @portal.single.xml.close@
         <mbean
            code="org.jboss.ha.singleton.HASingletonController"
            name="portal:service=Controller,target=ObjectDeploymentFactory">
            <depends>jboss:service=${jboss.partition.name:DefaultPartition}</depends>
            <depends>portal:deploymentFactory=Object</depends>
            <attribute name="TargetName">portal:deploymentFactory=Object</attribute>
            <attribute name="TargetStartMethod">registerFactory</attribute>
            <attribute name="TargetStopMethod">unregisterFactory</attribute>
         </mbean>
         @portal.single.xml.open@
         -->

- jboss-portal.sar/portal-cms.sar/META-INF/jboss-service.xml

         <!--
            | Uncomment in clustered mode : replicated cache for hibernate
            @portal.single.xml.close@
         <mbean
            code="org.jboss.invocation.jrmp.server.JRMPProxyFactory"
            name="portal:service=ProxyFactory,type=CMS">
            <depends optional-attribute-name="InvokerName">jboss:service=invoker,type=jrmp</depends>
            <attribute name="TargetName">portal:service=CMS</attribute>
            <attribute name="ExportedInterfaces">org.jboss.portal.cms.ha.HASingletonInvokerMBean$Proxy</attribute>
            <attribute name="InvokeTargetMethod">true</attribute>
            <attribute name="ClientInterceptors">
              <interceptors>
                <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
                <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
              </interceptors>
            </attribute>
         </mbean>

         <mbean
            code="org.jboss.portal.cms.ha.HASingletonInvoker"
            name="portal:service=HASingletonInvoker,type=CMS">
            <depends>jboss:service=${jboss.partition.name:DefaultPartition}</depends>
            <attribute name="RetryWaitingTimeMS">2000</attribute>
            <attribute name="MaxRetries">5</attribute>
            <attribute name="JNDIName">MyServiceInvokeTarget</attribute>
            <attribute name="JNDIProperties">
               java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
               java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
               java.naming.provider.url=${jboss.bind.address:localhost}:1100
               jnp.disableDiscovery=false
               jnp.partitionName=${jboss.partition.name:DefaultPartition}
               jnp.discoveryGroup=${jboss.partition.udpGroup:230.0.0.4}
               jnp.discoveryPort=1102
               jnp.discoveryTTL=16
               jnp.discoveryTimeout=5000
               jnp.maxRetries=1
            </attribute>
            <depends optional-attribute-name="Callback" proxy-type="attribute">portal:service=CMS</depends>
            <depends optional-attribute-name="ProxyFactory">portal:service=ProxyFactory,type=CMS</depends>
         </mbean>
         @portal.single.xml.open@
         -->

- jboss-portal.sar/portal-server.war/WEB-INF/web.xml

         <!--
            | Uncomment in clustered mode : use http session replication
            @portal.single.xml.close@
         <distributable/>
         @portal.single.xml.open@
         -->

- jboss-portal.sar/conf/hibernate/instance/hibernate.cfg.xml, jboss-portal.sar/conf/hibernate/portal/hibernate.cfg.xml, and jboss-portal.sar/conf/hibernate/user/hibernate.cfg.xml

            <!--
               | Uncomment in clustered mode : use transactional replicated cache
               @portal.single.xml.close@
            <property name="cache.provider_class">org.jboss.portal.core.hibernate.JMXTreeCacheProvider</property>
            <property name="cache.object_name">portal:service=TreeCacheProvider,type=hibernate</property>
            @portal.single.xml.open@
            -->

            <!--
               | Comment in clustered mode
               @portal.clustered.xml.close@
            <property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
            @portal.clustered.xml.open@
            -->

            <!-- Force the dialect instead of using autodetection -->
            <!--
            <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
            -->

After modifying the above files, you can deploy the jboss-portal.sar and the appropriate datasource descriptor to JBOSS_HOME/server/all/deploy/*

Prev | Up | Next
Chapter 10. Security | Home | Chapter 12. Troubleshooting and FAQ