1 22 package org.jboss.ha.singleton; 23 24 25 import org.jboss.ha.framework.interfaces.ClusterNode; 26 import org.jboss.ha.framework.interfaces.HAPartition; 27 28 51 public class HASingletonElectionPolicySimple 52 extends HASingletonElectionPolicyBase 53 implements HASingletonElectionPolicySimpleMBean 54 { 55 private int mPosition = 0; 58 61 public void setPosition(int pos) 62 { 63 this.mPosition = pos; 64 } 65 66 69 public int getPosition() 70 { 71 return this.mPosition; 72 } 73 74 public ClusterNode pickSingleton() 75 { 76 return pickSingleton(getHAPartition()); 77 } 78 79 public ClusterNode pickSingleton(HAPartition partition) 80 { 81 ClusterNode[] nodes = partition.getClusterNodes(); 82 83 int size = nodes.length; 84 int remainder = ((this.mPosition % size) + size) % size; 85 86 return nodes[remainder]; 87 } 88 } 89 | Popular Tags |