Jboss AS 6.0.0-Final - HASingleton Service Restart fail on cluster merge
jojopotatoe Jun 29, 2011 2:15 AMHi,
we are using JBoss 6.0.0-Final version.
We deployed a HASingleton Service as described in this document : http://community.jboss.org/wiki/WritingAClusteredHASingletonService
All goes fine in singleton start/stop for the case : server shutdown.
But when with this test case :
- server 1 master and server 2 slave
- we cut network on server 1
- server 2 is now master and server 1 is still master too
- we reconnect server 1
- we saw ClusterMerges messages (refresh view ... bridge connection ...)
- but the two HASingleton are started and none of them went into the restart procedure http://community.jboss.org/wiki/HASingletonAndClusterMerges
(start and stop invoke)
I can observe this on my beans but also on yours : if you look at HASingletonDeployer service in JMX Console it seems that MasterNode attribute is set to True on each cluster instance after my test case.
Is this a problem in my code or the normal HAController implmentation ?
Will Service and HA fonction support continue on next version ? (7.0.0)
Here is my code :
IHATest.java
@Remote @RemoteBinding(jndiBinding = HATest.JNDI_NAME) public interface IHATest { public void create () throws Exception; public void destroy () throws Exception; public void start () throws Exception; public void stop () throws Exception; boolean isMasterNode(); void startSingleton() throws NamingException; void stopSingleton() throws NamingException; }
HATest.java
@Service(objectName = HATest.OBJECT_NAME) @Management(IHATest.class) public class HATest implements IHATest { /** Variable de journalisation. */ private static Logger log = LoggerFactory.getLogger(HATest.class); /** NOM JNDI. */ public static final String JNDI_NAME = "myn/HATest/remote"; /** Nom JNDI de l'EJB (pour les invocations de type lookup jndi). */ public static final String OBJECT_NAME = "myn:service=HATest"; /** Indique si le singleton est démaré en tant que MASTER. */ public boolean masterNode = false; /** Reference interne. */ private IHATest reference; // MANAGEMENT public void start() throws NamingException { log.info("MANAGEMENT START HATest"); // Remove from local JNDI until started as a singleton, // but keep the reference locally so it could be restored later. Context ctx = new InitialContext(); reference = (IHATest) ctx.lookup(JNDI_NAME); Util.unbind(ctx, JNDI_NAME); } public void stop() { log.info("MANAGEMENT STOP HATest"); } public void startSingleton() throws NamingException { log.info("SINGLETON STARTED !!!"); masterNode = true; /* * Rebind to JNDI when started as singleton */ Context ctx = new InitialContext(); Util.rebind(ctx, JNDI_NAME, reference); } public void stopSingleton() throws NamingException { log.info("SINGLETON STOPPED !!!"); masterNode = false; /* * Unbind from local JNDI when stopped */ Context ctx = new InitialContext(); Util.unbind(ctx, JNDI_NAME); } /* * (non-Javadoc) * * @see fr.dcns.ha.IMan#create() */ @Override public void create() throws Exception { // TODO Auto-generated method stub } /* * (non-Javadoc) * * @see fr.dcns.ha.IMan#destroy() */ @Override public void destroy() throws Exception { // TODO Auto-generated method stub } /* * (non-Javadoc) * * @see fr.dcns.ha.IMan#isStarted() */ public boolean isMasterNode() { return masterNode; }
jboss-service.xml
<server> <mbean name="myn:service=HATest-Controller" code="org.jboss.ha.singleton.HASingletonController"> <depends>myn:service=HATest</depends> <depends>HASingletonDeployerBarrierController</depends> <attribute name="HAPartition"><inject bean="HAPartition" /></attribute> <attribute name="TargetName">myn:service=HATest</attribute> <attribute name="TargetStartMethod">startSingleton</attribute> <attribute name="TargetStopMethod">stopSingleton</attribute> <attribute name="RestartOnMerge">true</attribute> </mbean> </server>