01: package org.jboss.ha.singleton;
02:
03: import org.jboss.ha.framework.interfaces.ClusterNode;
04: import org.jboss.ha.framework.interfaces.HAPartition;
05:
06: public interface HASingletonElectionPolicy {
07:
08: /**
09: * Called by the HASingleton to provide the election policy a reference to
10: * itself. A policy that was designed to elect a particular kind of singleton
11: * could downcast this object to a particular type and then access the
12: * singleton for state information needed for the election decision.
13: */
14: void setManagedSingleton(Object singleton);
15:
16: Object getManagedSingleton();
17:
18: /**
19: * Sets the HAPartition; from this the election policy can gain
20: * access to the DistributedReplicantManager for tracking the
21: * deployment topology for the singleton service and to the HAPartition
22: * for making group RPC calls.
23: */
24: void setHAPartition(HAPartition partition);
25:
26: HAPartition getHAPartition();
27:
28: /**
29: * Return the elected master node.
30: * @return the master node
31: */
32: ClusterNode pickSingleton();
33:
34: /**
35: * Given the HAPartition, return the elected master node.
36: * @param partition
37: * @return the master node
38: */
39: ClusterNode pickSingleton(HAPartition partition);
40:
41: /**
42: * Conducts an election and returns whether the managed service
43: * is the master, based on the current view of partition.
44: * @return true only if the managed service is the master
45: */
46: boolean isElectedMaster();
47:
48: /**
49: * Given the HAPartition, return whether the managed service is the master.
50: * @param partition
51: * @return true only if the managed service is the master
52: */
53: boolean isElectedMaster(HAPartition partition);
54:
55: }
|