4 Replies Latest reply on Jan 31, 2008 6:50 PM by Brian Stansberry

    JBAS-3532 Design

    Jerry Gauthier Apprentice

      This issue notes that DRM and DS should be injected into ClusterPartition.

      This work has been previously accomplished for DS. For DRM, it doesn't look like this is possible until further ground work is done. The issue indicates that DRM is now an independent service but this isn't the case as it has a dependency on ClusterPartition for RPC support, membership services, and state transfer support (at first glance anyways).

      A separate issue (JBAS-3499) notes that DRM should be refactored to use JBossCache. Maybe this would reduce or eliminate DRM dependencies on ClusterPartition. Another possibility might be to inject JChannelFactory into DRM and have it implement whatever services it requires independently of ClusterPartition.

        • 1. Re: JBAS-3532 Design
          Brian Stansberry Master

          As you said, the issue with DRM/ClusterPartition is that it's a circular dependency, making it a wee bit complex for dependency injection. That should be solvable by adding "whenRequired" attributes to the inject elements.

          I.e in pseudo-xml in cluster-beans.xml:

          <bean name="HAPartition" ...>
           <property name="distributedReplicantManager"><inject bean="DRM" whenRequired="Create"/></property>
          <bean name="DRM" ...>
           <property name="HAPartition"><inject bean="HAPartition" whenRequired="Instantiated"/></property>

          The above example could be wrong; it's more there to give you the concept. Idea is you inject the DRM into the HAPartition just before it needs it in create(). You inject HAPartition into DRM early, since a DRM without an HAPartition is basically useless. The MC can analyze this situation and properly instantiate both objects.

          The schema for beans.xml explains this stuff fairly well; it's in the Microcontainer source at https://svn.jboss.org//repos/jbossas/projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_2_0.xsd . Valid values for "whenRequired" are the various states the MC moves a bean through as it deploys it:


          I didn't have a chance to properly explore this last Nov when I was looking at this. If you have bandwidth to play with it a bit and try to get it sorted, that would be great. (Note I'm leaving on 2 week vacation in a few hours, so will not be in touch.)

          Re: JBAS-3499, that's still really low priority. DRM works now, except for a couple JIRAs we need to track down. DRM is mission critical, and with all the stuff there is to do, I have a "if it ain't broke don't fix it" attitude toward making DRM use JBoss Cache.

          • 2. Re: JBAS-3532 Design
            Jerry Gauthier Apprentice

            I'll take a look at the circular dependency issue using "whenRequired." I won't pursue JBAS-3499; I only mentioned it in case that's what you had in mind as a prerequisite here.

            • 3. Re: JBAS-3532 Design
              Jerry Gauthier Apprentice

              Brian - I'm documenting my progress here as I'll be away on vacation when you return.

              The required dependencies are as follows. The dependency states are reversed from your example.

              <bean name="DistributedReplicantManager" ...
              <property name="HAPartition"><inject bean="HAPartition" state="Create"/></property>
              <bean name="HAPartition" ...
              <property name="distributedReplicantManager"><inject bean="DistributedReplicantManager" state="Instantiated"/></property>

              I've checked in the changes necessary to provide dependency injection and I've removed the logic that supported usage of ClusterPartition without DI of DRM (as it appears that was your intent).

              This implementation differs from DI of DistributedState where DS was injected into ClusterPartitionConfig which was then passed into the ClusterPartition constructor. My implementation injects DRM directly into ClusterPartition as I couldn't resolve the circular dependencies between DRM and ClusterPartition when injecting into the Config object. I'm going to revisit this as I may have missed something when trying it earlier.

              • 4. Re: JBAS-3532 Design
                Brian Stansberry Master

                Just a follow up on what I did here.

                DRM and DS are really just subcomponents of HAPartition. So, I changed them so they no longer expose create()/start()/stop()/deploy(). This means the microcontainer will no longer to manage a 4 stage lifecycle for them.

                They now simply get injected into HAPartition. HAPartition manages their lifecycle, and injects itself into DRM.