org.jboss.ha.singleton
public class: HASingletonElectionPolicySimple [javadoc |
source]
java.lang.Object
org.jboss.ha.singleton.HASingletonElectionPolicySimple
All Implemented Interfaces:
HASingletonElectionPolicy, HASingletonElectionPolicySimpleMBean
Direct Known Subclasses:
PreferredMasterElectionPolicy
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
If no election policy is defined, the oldest node in the cluster runs the
singleton. This behaivour can be achieved with this policy when "position"
is set to 0.
| Methods from java.lang.Object: |
|---|
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from org.jboss.ha.singleton.HASingletonElectionPolicySimple Detail: |
public ClusterNode elect(List<ClusterNode> candidates) {
int size = candidates.size();
int remainder = ((this.mPosition % size) + size) % size;
return candidates.get(remainder);
}
|
public int getPosition() {
return this.mPosition;
}
|
public void setPosition(int pos) {
this.mPosition = pos;
}
|