Document Version 1.0
JBoss HA Service, HA Singleton, JBoss Cluster, load migration, load distribution, HA Service deployment
Deployment of "TestHASingleton" MBean
Put the "TestHASingleton.sar in "JBOSS_HOME/server/node1/farm/".
You will see following information in the console of node1 :
10:28:09,752 INFO [STDOUT] ### Starting JbHaSingletonSvcSample Singleton Service..
From the above text we can see that the "startSingletonService" method of "JbHaSingletonSvcSample" is called, i.e. the singleton is started on node1.
We check the console output of node2, nothing about the singleton is shown. This is correct.
Now, we will shut down node1. Now we will see following info in the console of node2:
10:40:05,383 INFO [STDOUT] ### Starting JbHaSingletonSvcSample Singleton Service..
Find out service on which node will the singleton be active?
step1. shutdown node1 and node2
step2. remove the "TestHASingleton.sar" from farms of both nodes
step3. start node1
step4. start node2
step5. deploy "TestHASingleton.sar" in farm of node2.
The console of node2 shows:
10:48:34,880 INFO [STDOUT] ### Starting JbHaSingletonSvcSample Singleton Service..
10:48:37,657 INFO [STDOUT] ### Stopping JbHaSingletonSvcSample Singleton Service..
The console of node1 shows:
10:48:37,658 INFO [STDOUT] ### Starting JbHaSingletonSvcSample Singleton Service..
This is because, via default, a HA singleton will only active on the "master" node of a cluster (JBoss mainains a sorted list of all active nodes, sorted by the time it joins the cluster. The first node in the list will be choosen as master... ). A HA singleton is active only on the MASTER node.
We could also customize the HA singleton behavior when deciding service on which node should be made active. In such case customized "HA selection policy" is needed...