[jboss-user] [Clustering/JBoss] - Re: Sever Failover

bstansberry@jboss.com do-not-reply at jboss.com
Thu May 17 18:19:09 EDT 2007


Best thing to do is to have a look at the 4.2 codebase, cluster module, package org.jboss.ha.singleton.  HASingletonElectionPolicy is the interface; HASingletonElectionPolicySimple is the default implementation.

What you do is you deploy your policy as an mbean.  Your policy can take whatever config attributes you want; just expose them in the mbean interface. Then in the mbean descriptor for the HASingletonController you inject the policy. E.g.:


  | <server>
  |    <!-- First the service being controlled -->
  |    <mbean code="org.jboss.ha.singleton.examples.HASingletonMBeanExample" 
  |           name="jboss.examples:service=HASingletonMBeanExample_1">
  |    </mbean>
  | 
  |    <mbean code="org.jboss.ha.singleton.PreferredMasterHASingletonElectionPolicy"
  |           name="jboss.examples:service=HASingletonMBeanExample-HASingletonElectionPolicy_1">
  |      <attribute name="PreferredServer">foo:1099</attribute>
  |    </mbean>
  | 
  |    <mbean code="org.jboss.ha.singleton.HASingletonController" 
  |           name="jboss.examples:service=HASingletonMBeanExample-HASingletonController_1">
  |       
  |       <depends optional-attribute-name="ClusterPartition"
  |          proxy-type="attribute">jboss:service=DefaultPartition</depends>
  |       <depends>jboss.examples:service=HASingletonMBeanExample_1</depends>
  |       <depends optional-attribute-name="ElectionPolicy"
  |          proxy-type="attribute">jboss.examples:service=HASingletonMBeanExample-HASingletonElectionPolicy_1</depends>
  |       <attribute name="TargetName">jboss.examples:service=HASingletonMBeanExample_1</attribute>
  |       <attribute name="TargetStartMethod">startSingleton</attribute>
  |       <attribute name="TargetStopMethod">stopSingleton</attribute>
  |       <attribute name="TargetStopMethodArgument">true</attribute>
  |    </mbean>
  | </server>

Your election policy will have a ref to the HAPartition passed into it as an arg to pickSingleton when it needs to decide if it is the master. From that you can determine who the members are.  You then compare the value of your PreferredServer attribute to the addresses in the view. If one matches, return that member.  If none match, delegate to HASingletonElectionPolicySimple (which should be the superclass of your policy).

The tricky bit is "PreferredServer" is a string, while the members are objects of type ClusterNode.  As the JIRA says, we need to come up with a good, user-friendly way to compare those.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4046661#4046661

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4046661



More information about the jboss-user mailing list