2 Replies Latest reply on Jun 23, 2004 1:33 AM by maroni

    several singleton MBeans: can master node for each one be di

    maroni Newbie

      Hi,
      In our cluster, we want to use several different singleton MBeans, let´s say MBean A and MBean B should only be active on one node (master node) in the cluster. I have declared the following in my hasingleton-example-service.xml file:

       <mbean code="org.jboss.ha.singleton.HASingletonController"
       name="jboss:service=HASingletonMBeanExample-HASingletonController">
       <depends>jboss:service=DefaultPartition</depends>
       <depends>myservice:service=MBeanA</depends>
       <attribute name="TargetName">myservice:service=MBeanA</attribute>
       <attribute name="TargetStartMethod">startSingleton</attribute>
       <attribute name="TargetStopMethod">stopSingleton</attribute>
       </mbean>
      
       <mbean code="org.jboss.ha.singleton.HASingletonController"
       name="jboss:service=HASingletonMBeanExample2-HASingletonController">
       <depends>jboss:service=DefaultPartition</depends>
       <depends>myservice:service=MBeanB</depends>
       <attribute name="TargetName">myservice:service=MBeanB</attribute>
       <attribute name="TargetStartMethod">startSingleton</attribute>
       <attribute name="TargetStopMethod">stopSingleton</attribute>
       </mbean>
      


      Both services are set to active state on the master node, and when the master node comes down, another master node is elected, that´s okay.

      But what if there are multiple nodes in the cluster? Can I be sure that active MBeanA and MBeanB reside always on the same node??
      Or does the notion of master node only refer to one singleton for sure?

      Please tell me, does anybody know? Because I don´t want to get bad surprises later.
      Thanks
      Marion


        • 1. Re: several singleton MBeans: can master node for each one b
          David Budworth Newbie

          In master elections (at least in 3.2.3), it is always the host that's been up longest.

          So A and B will always be on the same node assuming your deployment is symmetrical.


          This feature was actually causing my problems, so i had to write my own singleton support to do elections differently so they didn't have to all be on the same node.

          I have a service that takes 30+ seconds to start, it was killing us that whenever we re-deployed code on the master, the singlton switched to host2 and then immediately back to host1 once the redeploy happened. It was effectively taking us out of service for a full minute every time we re-deployed.

          In our case, we used the replicant manager to perform elections. Basically means that the code that's been deployed longest is master. Not the host that's been up longest.

          • 2. Re: several singleton MBeans: can master node for each one b
            maroni Newbie

            Thanks for your reply.
            But what if you have three nodes, and MBean A is only deployed on Node 1 and 2, and MBean B is deployed only on Node 2 and 3? When node 1 comes up first, then MBean B will not become active at all because it´s not running on the master node?