FileDocCategorySizeDatePackage
HASingletonElectionPolicySimple.javaAPI DocJBoss 4.2.12910Fri Jul 13 20:52:36 BST 2007org.jboss.ha.singleton

HASingletonElectionPolicySimple

public class HASingletonElectionPolicySimple extends HASingletonElectionPolicyBase implements HASingletonElectionPolicySimpleMBean
A simple concrete policy service that decides which node in the cluster should be the master node to run certain HASingleton service based on attribute "Position". The value will be divided by partition size and only remainder will be used. Let's say partition size is n: 0 means the first oldest node. 1 means the 2nd oldest node. ... n-1 means the nth oldest node. -1 means the youngest node. -2 means the 2nd youngest node. ... -n means the nth youngest node. E.g. the following attribute says the singleton will be running on the 3rd oldest node of the current partition: 2
author
Alex Fu
version
$Revision: 46010 $

Fields Summary
private int
mPosition
Constructors Summary
Methods Summary
public intgetPosition()

see
HASingletonElectionPolicySimpleMBean#getPosition()

      return this.mPosition;
   
public org.jboss.ha.framework.interfaces.ClusterNodepickSingleton()

      return pickSingleton(getHAPartition());
   
public org.jboss.ha.framework.interfaces.ClusterNodepickSingleton(org.jboss.ha.framework.interfaces.HAPartition partition)

      ClusterNode[] nodes = partition.getClusterNodes();
      
      int size = nodes.length;
      int remainder = ((this.mPosition % size) + size) % size;
      
      return nodes[remainder];
   
public voidsetPosition(int pos)

see
HASingletonElectionPolicySimpleMBean#setPosition(int)

 // Default
   
         
      
   
      this.mPosition = pos;