JBAS-2499 Configurable Policy to Elect HASingleton Master
brian.stansberry Jun 2, 2006 3:57 PMDiscussion forum for http://jira.jboss.com/jira/browse/JBAS-2499 .
See also http://www.jboss.com/index.html?module=bb&op=viewtopic&t=78336.
Some very brief and rough thoughts on configurable policies for determining an HASingleton master.
The policy would be dependency injected into the target HA singleton. Would need to expose an interface; let's say "org.jboss.ha.singleton.HASingletonElectionPolicy". Not picky about names, that's one I'm tossing out.
Things I imagine in the interface, again names are just rough ideas:
/** * Called by the HASingleton to provide the election policy a reference to * itself. A policy that was designed to elect a particular kind of singleton * could downcast this object to a particular type and then access the * singleton for state information needed for the election decision. */ public void setManagedSingleton(Object singleton); public Object getManagedSingleton(); /** * Called by the HASingleton to set the name with which the singleton * service is registered with the HAPartition. */ public void setServiceName(String serviceName); public String getServiceName(); /** * Sets the ClusterPartition; from this the election policy can gain * access to the DistributedReplicantManager for tracking the * deployment topology for the singleton service and to the HAPartition * for making group RPC calls. */ public void setClusterPartition(ClusterPartition partition); /** * Conducts an election and returns whether the managed singleton * is the master. */ public boolean isElectedMaster();
Any other configuration options would be exposed by the policy implementation and would be set as part of configuring the policy before injecting it into the HASingleton.
HASingletonSupport would include the necessary code to call setManagedSingleton() and setServiceName() after the policy is injected.
We'd want a default implementation that works like the current election process -- i.e. call DistributedReplicantManager.isMasterReplica(). In HASingletonSupport.createService() we should check if an election policy has been configured, and if not, create an instance of this default policy.