1 package org.jboss.ha.singleton;
2
3 import org.jboss.ha.framework.interfaces.ClusterNode;
4 import org.jboss.ha.framework.interfaces.HAPartition;
5
6 /**
7 * HASingletonElectionPolicy.
8 *
9 * @author <a href="mailto:Alex.Fu@novell.com">Alex Fu</a>
10 * @author Brian Stansberry
11 * @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
12 */
13 public interface HASingletonElectionPolicy
14 {
15 /**
16 * Called by the HASingleton, during the create service phase, to set the
17 * name with which the singleton is registered with the HAPartition.
18 *
19 * @param serviceName the singleton service name.
20 */
21 void setSingletonName(String serviceName);
22
23 /**
24 * Get the singleton name for this election policy.
25 *
26 * @return the singleton service name.
27 */
28 String getSingletonName();
29
30 /**
31 * Called by the HASingleton, during the create service phase to sets the
32 * HAPartition; from this the election policy can gain access to the
33 * DistributedReplicantManager for tracking the deployment topology for
34 * the singleton service and to the HAPartition for making group RPC calls.
35 */
36 void setHAPartition(HAPartition partition);
37
38 /**
39 * Get the HA partition where the singleton is deployed, which can be used,
40 * amongst other things, to find out which nodes is the singleton available
41 * in.
42 *
43 * @return the HA partition.
44 */
45 HAPartition getHAPartition();
46
47 /**
48 * Return the elected master node.
49 * @return the master node or null if there're no possible master nodes.
50 */
51 ClusterNode elect();
52 }