[mod_cluster-dev] Enabling mod_cluster by default in AS6

Bela Ban bban at redhat.com
Tue May 4 03:57:35 EDT 2010



Paul Ferraro wrote:
>>
>> Why ? Can't we simply grab the deployed contexts from JBossWeb ? If
>> mod-cluster is started before jbossweb, we'll get the deployed contexts
>> later, once jbossweb has been started. Do we get notifications about
>> when beans have been started ? If so we could listen for
>> jbossweb-started, and *then* grab all contexts...
>
> Right.  Scrap that old idea.  Here's what I think we should do (I spent
> this morning validating that this works):
>
> Edit mod_cluster MC config such that it depends on the WebServer bean
> and is no longer "On Demand".  e.g.
> <bean name="ModClusterListener" class="org.jboss.modcluster.catalina.CatalinaEventHandlerAdapter">
>   <constructor>
>     <!-- To use the HA singleton version of mod_cluster, change this injection to HAModClusterService -->
>     <parameter><inject bean="ModClusterService"/></parameter>
>     <parameter><inject bean="JMXKernel" property="mbeanServer"/></parameter>
>   </constructor>
>   <depends>WebServer</depends>
> </bean>
>
> Add a start() MC lifecycle method to CatalinaEventHandlerAdapter that
> looks like:
>
> public void start() throws JMException
> {
>    try
>    {
>       // If the catalina server is already registered, init/start mod_cluster
>       Service[] services = (Service[]) this.mbeanServer.invoke(this.serverObjectName, "findServices", null, null);
>       if (services.length > 0)
>       {
>          Server server = (Server) services[0].getServer();
>          if (server instanceof Lifecycle)
>          {
>             Lifecycle lifecycle = (Lifecycle) server;
>             for (LifecycleListener listener: lifecycle.findLifecycleListeners())
>             {
>                // Test if listener is already registered
>                if (listener.equals(this)) return;
>             }
>             lifecycle.addLifecycleListener(this);               
>             if (this.init.compareAndSet(false, true))
>             {
>                this.init(server);
>                if (this.start.compareAndSet(false, true))
>                {
>                   this.eventHandler.start(new CatalinaServer(server, this.mbeanServer));
>                }
>             }
>          }
>       }
>    }
>    catch (InstanceNotFoundException e)
>    {
>       // Ignore
>    }
> }
>
>   

TBH, I'm not a 100% sure what the code above does... is it adding a 
lifecycle listener dynamically if mod_cluster is started after JBossWeb 
? Actually, I guess this will always be the case as you have a 
dependency from mod-cluster to JBossWeb.

> This requires a small modification to the
> MicrocontainerIntegrationLifecycleListener, which will need to delegate
> equals(Object) to its non-null delegate listener if the argument is a
> LifecycleListener, but not an instanceof MCILL.
>
> So, this essentially does what you described. There are couple other
> advantages:
> 1. We no longer need to define a <Listener/> in server.xml (closes 
> MODCLUSTER-20 !!!).

Because you're adding the listener dynamically, a la MODCLUSTER-20, right ?

Wow, that would be great !

> 2. We no longer rely on the finicky 
> MicrocontainerIntegrationLifecycleListener, which requires (so to avoid
> a call to JBossWebMicrocontainerBeanLocator.getInstalledBean(...) on
> every lifecycle event) that the delegate listener is deployed prior to
> the start() of the WebServer service.

OK

> 3. There is no longer any manual step to enable mod_cluster (e.g.
> uncommenting <depends>ModClusterListener</depends>) - the existence of
> mod_cluster.sar is enough.

Cool ! So the mod-cluster SAR has a dependency on WebServer, and when 
you dynamically deploy mod-cluster.sar, JBossWeb will already be 
running, good !

> 4. It is still compatible with the mod_cluster configuration bundled 
> with AS 6.0.0.M1-M3.

OK

> 5. mod_cluster is now hot-deployable, independently of jbossweb. The
> addition of a corresponding stop() that removes the lifecycle listener
> will allow mod_cluster to be hot-undeployable.

Great !

> Thoughts?

Excellent ! I like this a lot, because it simplifies things a lot and 
reduces the amount of configuration to be done.

So when this is done, what will the configuration steps be (on the JBoss 
AS side) ?

   1. Add a jvmRoute to server.xml [optional, as jvmRoute is generated
      if absent]
   2. mod-cluster.sar:
         1. Set the proxy list (jboss.mod_cluster.proxyList) [optional
            if IP multicasting works, as advertise is enabled by default]
         2. Set the domain [optional if we use a system prop, or the
            default domain]
         3. Use HAModClusterService instead of ModClusterService: for
            the mod-cluster.sar located in 'all', can we make this the
            default ?

WDYT ?

-- 
Bela Ban
Lead JGroups / Clustering Team
JBoss



More information about the mod_cluster-dev mailing list