2 Replies Latest reply on Nov 5, 2012 4:09 AM by nami_30

    [ HASingleton ] Configuring Preferred Master Node

    hushen.savani

      Hi Community,

       

           I am using JBossAS-5.1.0.GA. I have setup application server clustering with two nodes - node0 and node1. My application ears are deployed in HASingleton mode. I have a certain requirement that node0 should always be the Master node if available.

       

           I.e.

       

                1) When both nodes are up, if node0 is killed, then node1 should become master node.

                2) Now when node0 is started then, node1 should become slave node and node0 should become master node.

       

           I have refered to JBoss Clustering Docs, it talks about PreferredMasterElectionPolicy as following:

       

      This policy extends HASingletonElectionPolicySimple, allowing the configuration of a
      preferred node. The preferredMaster property, specified as host:port or address:port,
      identifies a specific node that should become master, if available. If the preferred node is not
      available, the election policy will behave as described above.
      
      <bean class="org.jboss.ha.singleton.PreferredMasterElectionPolicy">
      <property name="preferredMaster">server1:12345</property>
      </bean>
      
           
      

       

           But the document dosen't mention where to configure the PreferredMasterElectionPolicy.

       

           Please suggest where/how to configure Preferred Master node.

       

           Thank you.

       

      Best Regards,

      Hushen Savani

        • 1. Re: [ HASingleton ] Configuring Preferred Master Node
          hushen.savani

          I found the solution anyway, I hope the same would be useful to other members as well:

           

           

          Edit the file 'deploy-hasingleton-jboss-beans.xml'found in $Profile/deploy/cluster folder

           

           

                 Add the bean 

           

                 <bean class="org.jboss.ha.singleton.PreferredMasterElectionPolicy" name="PreferredMasterElectionPolicy_1">

                 <property name="preferredMaster">0.0.0.0:1299</property>

                 </bean>

            

                   Note Here 0.0.0.0 is the IP address and 1299 is the jnp port.

                 replace with the appropriate IP and port

           

                 Also , add the property, <property name="electionPolicy"><inject bean="PreferredMasterElectionPolicy_1"/></property> to the bean HASingletonDeployer

             

          For Example :

           

           

                                               <bean name="HASingletonDeployer"

                                                     class="org.jboss.ha.singleton.HASingletonController"> 

                                             

                                                  <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.ha:service=HASingletonDeployer",    

           

           

                                         exposedInterface=org.jboss.ha.singleton.HASingletonControllerMBean.class, registerDirectly=true)</annotation>      

                                             

                                              <depends>HAPartition</depends>

                                              <!-- Have the BarrierController that listens for our JMX

                                                     notifications start first. -->

                                              <depends>HASingletonDeployerBarrierController</depends>

                                             

                                              <property name="HAPartition"><inject bean="HAPartition"/></property>

                                              <property name="target"><inject bean="HASingletonProfileManager"/></property>

                                              <property name="electionPolicy"><inject bean="PreferredMasterElectionPolicy_1"/></property>

                                              <property name="targetStartMethod">activateProfile</property>

                                              <property name="targetStopMethod">releaseProfile</property>

                                             

                                              <!-- whether to register thread context classloader for the RPC handler, default is false -->

                                              <!--<property name="registerThreadContextClassLoader">false</property>-->

                                             

                                              <!-- Whether the singleton should be restarted (i.e. invoke the TargetStopMethod and then the

                                                  TargetStartMethod) if a cluster merge occurs while this node is the singleton master.

                                                  A cluster merge means there may have been more than one singleton master during the period

                                                  when communication between some or all of the nodes in the cluster was disrupted; hence the

                                                  surviving master may not be aware of state changes made by another master. Restarting the

                                                  singleton gives it a signal that it should refresh its internal state from any external

                                                  store.

                                                  By default this is set to true.

                                              -->

                                              <property name="restartOnMerge">true</property> 

                                             

                                              </bean>                

           

           

          Best Regards,

          Hushen Savani

          • 2. Re: [ HASingleton ] Configuring Preferred Master Node
            nami_30

            Hi Hushen,

             

            When i followed ur solution.

            If the master is stopped, then the war files in other nodes are getting undeployed.

             

            Example: Say A and B are 2 nodes. A is made master node with configurations you have told.

            So i can access through browser. But if i stop A , then B should serve the request. But as i see the war file present under all/deploy-hasingleton

            is getting undeployed when i stop A.(I cannot see war file there).

            And so the request is not serviced.

             

            What might be the problem and how to solve this.