From: <be...@jb...> - 2006-06-03 14:22:05
|
where's the list of nodes of the cluster from which you pick a singleton, e.g. ? Address pickSingleton(Collection nodes) ? View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3948876#3948876 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3948876 |
From: <bst...@jb...> - 2006-06-03 15:14:06
|
I was thingking the policy has access to the HAPartition and DRM and knows the service name, so it can find out who the nodes are. So, reduce the coupling between the singleton and the policy by not making the singleton responsible for providing the topology. But, the singleton is going to ask the policy who's been elected because it got a notification of a topology change, so it makes sense to pass the topology. If the singleton provides the topology, then I'd say: Address pickSingleton(List nodes) List because order is important to most policies. I like getting Address back instead of boolean -- that way the singleton knows who the master is. I'd keep a boolean version as well though, as a convenience, i.e. public boolean isElectedSingleton(List node) { return pickSingleton(nodes).equals(partition.getLocalAddress()); } View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3948889#3948889 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3948889 |
From: AlexFu.Novell <do-...@jb...> - 2006-06-16 20:30:10
|
OK. I will have an abstract class org.jboss.ha.singleton.HASingletonElectionPolicyBase and one implementation class org.jboss.ha.singleton.HASingletonElectionPolicySimple which elects the master node based on attribute "position" defined in the MBean descriptor. Here is how position is defined: | * 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. | The interfaces will change slightly to be consistent with ClusterPartition: InetAddress pickSingleton(Vector nodes); Also this one without parameter may remain by calling ClusterPartition.getCurrentView() to get the Vector of nodes. | /** | * Conducts an election and returns whether the managed singleton | * is the master. | */ | public boolean isElectedMaster() | { | return pickSingleton(this.mPartition.getCurrentView()). | equals(this.mPartition.getNodeAddress()); | } | I haven't figured out how to do unit test on this but am working on it. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3951387#3951387 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3951387 |
From: <bst...@jb...> - 2006-06-19 00:19:21
|
"AlexFu.Novell" wrote : one implementation class | org.jboss.ha.singleton.HASingletonElectionPolicySimple which elects the master node based on attribute "position" defined in the MBean descriptor. Here is how position is defined Good. If "position" is undefined, it should default to 0, which is the current behavior. anonymous wrote : | The interfaces will change slightly to be consistent with ClusterPartition: | | InetAddress pickSingleton(Vector nodes); The return type should be org.jboss.cluster.ha.framework.interfaces.ClusterNode -- the contents of the Vector are actually ClusterNode objects. anonymous wrote : I haven't figured out how to do unit test on this but am working on it. Take a look at org.jboss.test.cluster.test.DRMTestCase.testIsMasterReplica() and others in that class -- it uses a mock HAPartition that doesn't actually communicate over the network; the test driver then programatically changes the view. Another approach is to implement http://jira.jboss.com/jira/browse/JBAS-2560 View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3951555#3951555 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3951555 |
From: AlexFu.Novell <do-...@jb...> - 2006-06-30 20:39:52
|
The code change has been checked in. The sample configuration can be found at: testsuite/src/resources/ha/electionpolicy/META-INF/jboss-service.xml. A HASingleton mbean will look like this: | <mbean code="org.jboss.ha.singleton.examples.HASingletonMBeanExample" | name="jboss.examples:service=HASingletonMBeanExample_1"> | </mbean> | | <mbean code="org.jboss.ha.singleton.HASingletonElectionPolicySimple" | name="jboss.examples:service=HASingletonMBeanExample-HASingletonElectionPolicySimple_1"> | <attribute name="Position">0</attribute> | </mbean> | | <mbean code="org.jboss.ha.singleton.HASingletonController" | name="jboss.examples:service=HASingletonMBeanExample-HASingletonController_1"> | <depends>jboss:service=${jboss.partition.name:DefaultPartition}</depends> | <depends>jboss.examples:service=HASingletonMBeanExample_1</depends> | <depends optional-attribute-name="HASingletonElectionPolicyMBean" | proxy-type="attribute">jboss.examples:service=HASingletonMBeanExample-HASingletonElectionPolicySimple_1</depends> | <attribute name="PartitionName">${jboss.partition.name:DefaultPartition}</attribute> | <attribute name="TargetName">jboss.examples:service=HASingletonMBeanExample_1</attribute> | <attribute name="TargetStartMethod">startSingleton</attribute> | <attribute name="TargetStopMethod">stopSingleton</attribute> | <attribute name="TargetStopMethodArgument">true</attribute> | </mbean> | View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3954753#3954753 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3954753 |
From: <bst...@jb...> - 2006-06-30 21:54:46
|
Great. Thanks :-) If the user doesn't inject an HASingletonElectionPolicy, will HASingletonController default to creating an instance of HASingletonPolicySimple with a position of 0? View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3954766#3954766 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3954766 |
From: AlexFu.Novell <do-...@jb...> - 2006-07-02 01:38:48
|
No. It doesn't create a default HASingletonElectionPolicySimple. But it will use the old logic so the behavior should be equivalent to HASingletonElectionPolicySimple with position of 0. This situation is tested in the unit test. "bst...@jb..." wrote : If the user doesn't inject an HASingletonElectionPolicy, will HASingletonController default to creating an instance of HASingletonPolicySimple with a position of 0? | View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3954866#3954866 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3954866 |