[jboss-cvs] JBossAS SVN: r83126 - in branches/Branch_5_x: testsuite/src/main/org/jboss/test/cluster/defaultcfg/test and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jan 20 22:48:22 EST 2009


Author: bstansberry at jboss.com
Date: 2009-01-20 22:48:22 -0500 (Tue, 20 Jan 2009)
New Revision: 83126

Modified:
   branches/Branch_5_x/cluster/src/etc/deploy-hasingleton-jboss-beans.xml
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonDeployerTestCase.java
   branches/Branch_5_x/testsuite/src/resources/cluster/hasingleton/deployer/test-deploy-hasingleton-jboss-beans.xml
Log:
[JBAS-6363] Ensure HASingletonDeployer BarrierController gets JMX Notifications

Modified: branches/Branch_5_x/cluster/src/etc/deploy-hasingleton-jboss-beans.xml
===================================================================
--- branches/Branch_5_x/cluster/src/etc/deploy-hasingleton-jboss-beans.xml	2009-01-21 03:27:55 UTC (rev 83125)
+++ branches/Branch_5_x/cluster/src/etc/deploy-hasingleton-jboss-beans.xml	2009-01-21 03:48:22 UTC (rev 83126)
@@ -34,6 +34,9 @@
       <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.ha:service=HASingletonDeployer", exposedInterface=org.jboss.ha.singleton.HASingletonControllerMBean.class, registerDirectly=true)</annotation>       
       
       <depends>HAPartition</depends>
+      <!-- Have the BarrierController that listens for our JMX 
+           notifications start first. -->
+      <depends>HASingletonDeployerBarrierController</depends>
       
       <property name="HAPartition"><inject bean="HAPartition"/></property>
       <property name="target"><inject bean="HASingletonDeploymentScanner"/></property>
@@ -77,15 +80,16 @@
     |    <enable type="org.jboss.ha.singleton.stopped"/>
    -->
    <bean class="org.jboss.system.BarrierController"
-          name="jboss.ha:service=HASingletonDeployer,type=BarrierController">
+          name="HASingletonDeployerBarrierController">
     
       <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.ha:service=HASingletonDeployer,type=BarrierControllerMBean", exposedInterface=org.jboss.system.BarrierControllerMBean.class, registerDirectly=true)</annotation> 
             
       <!-- Dependent services will depend on this mbean -->
       <property name="barrierObjectName">jboss.ha:service=HASingletonDeployer,type=Barrier</property>
     
-      <!-- Whether to subscribe for notifications after startup -->
-      <property name="dynamicSubscriptions">false</property>    
+      <!-- Subscribe for notifications after startup since we start
+           before the HASingletonDeployer. -->
+      <property name="dynamicSubscriptions">true</property>    
       <!-- The notification subscription handback that starts the barrier -->
       <property name="startBarrierHandback">start</property>
       <!-- The notification subscription handback that stops the barrier -->

Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonDeployerTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonDeployerTestCase.java	2009-01-21 03:27:55 UTC (rev 83125)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonDeployerTestCase.java	2009-01-21 03:48:22 UTC (rev 83126)
@@ -27,6 +27,7 @@
 
 import junit.framework.Test;
 
+import org.jboss.system.ServiceMBean;
 import org.jboss.test.JBossClusteredTestCase;
 
 /**
@@ -38,7 +39,14 @@
    public static final String SINGLETON_DEPLOYER_ONAME = "jboss.ha:service=TestHASingletonDeployer";
    public static final String SINGLETON_DEPLOYMENT = "jboss.system:service=HASingletonTestThreadPool";
    public static final String SINGLETON_DEPLOYER = "test-deploy-hasingleton-jboss-beans.xml";
+   public static final String SINGLETON_BARRIER_ONAME = "jboss.ha:service=TestHASingletonDeployer,type=Barrier";
+   public static final Integer CREATED_STATE = new Integer(ServiceMBean.CREATED);
+   public static final Integer STARTED_STATE = new Integer(ServiceMBean.STARTED);
+   public static final Integer STOPPED_STATE = new Integer(ServiceMBean.STOPPED);
    
+   public static final String STD_SINGLETON_DEPLOYER_ONAME = "jboss.ha:service=HASingletonDeployer";
+   public static final String STD_SINGLETON_BARRIER_ONAME = "jboss.ha:service=HASingletonDeployer,type=Barrier";
+   
    /**
     * Create a new ProfileRepositoryHASingletonDeployerTestCase.
     * 
@@ -54,59 +62,106 @@
       return getDeploySetup(HASingletonDeployerTestCase.class, SINGLETON_DEPLOYER);
    }
    
+   /**
+    * Accesses the test HASingletonDeployer beans deployed by the test wrapper
+    * and validates that deployments are done on the master node and not on
+    * the non-master.  Also validates that a Barrier has reached the start
+    * state on the master and not on the non-master.  Then undeploys
+    * the deployer on the master node and checks service failover. Then undeploys
+    * on the other node and redeploys on node1, checking node1 became master
+    * with the target services deployed and the Barrier started.  Then deploys 
+    * on node0, confirming that node1 remained the master and node0 didn't
+    * deploy the target services or bring a BARRIER to STARTED state. 
+    * 
+    * @throws Exception
+    */
    public void testHASingletonDeployer() throws Exception
    {
       MBeanServerConnection[] adaptors = getAdaptors();
       
-      boolean node0Master = isMaster(adaptors[0]);
-      assertFalse(node0Master == isMaster(adaptors[1]));
+      boolean node0Master = isMaster(adaptors[0], false);
+      assertFalse(node0Master == isMaster(adaptors[1], false));
       int origMasterIndex = node0Master ? 0 : 1;
       int origNonMasterIndex = node0Master ? 1 : 0;
       
       assertTrue("singleton is not deployed on node " + origMasterIndex, isDeployed(SINGLETON_DEPLOYMENT, adaptors[origMasterIndex]));
       assertFalse("singleton is deployed on node " + origNonMasterIndex, isDeployed(SINGLETON_DEPLOYMENT, adaptors[origNonMasterIndex]));
       
+      assertBarrierStatus(adaptors[0], node0Master, false);
+      assertBarrierStatus(adaptors[1], !node0Master, false);
+      
       undeploy(adaptors[origMasterIndex], SINGLETON_DEPLOYER);
       
       // The singleton is triggered asynchronously, so give it time to work
-      sleep(1000);
+      sleep(2000);
       
       assertTrue(isDeployed(SINGLETON_DEPLOYMENT, adaptors[origNonMasterIndex]));
       assertFalse(isDeployed(SINGLETON_DEPLOYMENT, adaptors[origMasterIndex]));
       
+      assertBarrierStatus(adaptors[origNonMasterIndex], true, false);
+      assertFalse(isDeployed(SINGLETON_BARRIER_ONAME, adaptors[origMasterIndex]));
+      
       undeploy(adaptors[origNonMasterIndex], SINGLETON_DEPLOYER);
       
-      sleep(1000);
+      sleep(2000);
       
       assertFalse(isDeployed(SINGLETON_DEPLOYMENT, adaptors[0]));
       assertFalse(isDeployed(SINGLETON_DEPLOYMENT, adaptors[1]));
       
+      assertFalse(isDeployed(SINGLETON_BARRIER_ONAME, adaptors[0]));
+      assertFalse(isDeployed(SINGLETON_BARRIER_ONAME, adaptors[1]));
+      
       deploy(adaptors[1], SINGLETON_DEPLOYER);
       
-      sleep(1000);
+      sleep(2000);
       
       assertTrue(isDeployed(SINGLETON_DEPLOYMENT, adaptors[1]));
       assertFalse(isDeployed(SINGLETON_DEPLOYMENT, adaptors[0]));
       
+      assertBarrierStatus(adaptors[1], true, false);
+      assertFalse(isDeployed(SINGLETON_BARRIER_ONAME, adaptors[0]));
+      
       deploy(adaptors[0], SINGLETON_DEPLOYER);
       
-      sleep(1000);
+      sleep(2000);
       
       // per policy, node0 takes over as master
       assertTrue(isDeployed(SINGLETON_DEPLOYMENT, adaptors[origMasterIndex]));
       assertFalse(isDeployed(SINGLETON_DEPLOYMENT, adaptors[origNonMasterIndex]));
+      
+      assertBarrierStatus(adaptors[0], true, false);
+      assertBarrierStatus(adaptors[1], false, false);
    }
    
+   /**
+    * Accesses the standard HASingletonDeployer beans, validating that one node
+    * is the master and the other isn't, and that the HASingleto Barrier is 
+    * STARTED on the master and CREATED on the non-master. A basic check that
+    * the "all" config is correct. JBAS-6363. 
+    * 
+    * @throws Exception
+    */
+   public void testAllConfiguration() throws Exception
+   {
+      MBeanServerConnection[] adaptors = getAdaptors();
+      
+      boolean node0Master = isMaster(adaptors[0], true);
+      assertFalse(node0Master == isMaster(adaptors[1], true));
+      
+      assertBarrierStatus(adaptors[0], node0Master, true);
+      assertBarrierStatus(adaptors[1], !node0Master, true);      
+   }
+   
    protected boolean isDeployed(String deployment, MBeanServerConnection server) throws Exception
    {
       return server.isRegistered(new ObjectName(deployment));
    }
    
-   private boolean isMaster(MBeanServerConnection server)
+   private boolean isMaster(MBeanServerConnection server, boolean stdTest)
    {
       try
       {
-         ObjectName oname = new ObjectName(SINGLETON_DEPLOYER_ONAME);
+         ObjectName oname = new ObjectName(stdTest ? STD_SINGLETON_DEPLOYER_ONAME : SINGLETON_DEPLOYER_ONAME);
          return ((Boolean) server.invoke(oname, "isMasterNode", new Object[]{}, new String[]{})).booleanValue();
       }
       catch (Exception e)
@@ -114,5 +169,19 @@
          throw new RuntimeException(e);
       }
    }
+   
+   private void assertBarrierStatus(MBeanServerConnection server, boolean isMaster, boolean stdTest) throws Exception
+   {
+      ObjectName oname = new ObjectName(stdTest ? STD_SINGLETON_BARRIER_ONAME : SINGLETON_BARRIER_ONAME);
+      Integer state = (Integer) server.getAttribute(oname, "State");
+      if (isMaster)
+      {
+         assertEquals(STARTED_STATE, state);
+      }
+      else
+      {
+         assertTrue("State " + state + " is valid", CREATED_STATE.equals(state) || STOPPED_STATE.equals(state));
+      }
+   }
 
 }

Modified: branches/Branch_5_x/testsuite/src/resources/cluster/hasingleton/deployer/test-deploy-hasingleton-jboss-beans.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/cluster/hasingleton/deployer/test-deploy-hasingleton-jboss-beans.xml	2009-01-21 03:27:55 UTC (rev 83125)
+++ branches/Branch_5_x/testsuite/src/resources/cluster/hasingleton/deployer/test-deploy-hasingleton-jboss-beans.xml	2009-01-21 03:48:22 UTC (rev 83126)
@@ -24,6 +24,7 @@
       <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.ha:service=TestHASingletonDeployer", exposedInterface=org.jboss.ha.singleton.HASingletonControllerMBean.class, registerDirectly=true)</annotation>       
       
       <depends>HAPartition</depends>
+      <depends>TestHASingletonDeploymentBarrierController</depends>  
       
       <property name="HAPartition"><inject bean="HAPartition"/></property>
       <property name="target"><inject bean="TestHASingletonDeploymentScanner"/></property>
@@ -48,4 +49,56 @@
       
    </bean>
    
+   <bean class="org.jboss.system.BarrierController"
+          name="TestHASingletonDeploymentBarrierController">
+    
+      <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.ha:service=TestHASingletonDeployerBarrierControllerMBean", exposedInterface=org.jboss.system.BarrierControllerMBean.class, registerDirectly=true)</annotation> 
+      
+      <!-- Dependent services will depend on this mbean -->
+      <property name="barrierObjectName">jboss.ha:service=TestHASingletonDeployer,type=Barrier</property>
+    
+      <!-- Whether to subscribe for notifications after startup -->
+      <property name="dynamicSubscriptions">true</property>    
+      <!-- The notification subscription handback that starts the barrier -->
+      <property name="startBarrierHandback">start</property>
+      <!-- The notification subscription handback that stops the barrier -->
+      <property name="stopBarrierHandback">stop</property>
+    
+      <!-- The notifications to subscribe for, along with their handbacks -->
+      <property name="subscriptions">
+         <list>
+            <!--value-->
+               <bean class="org.jboss.system.ListenerServiceMBeanSupport$SubscriptionInfo">
+                     <constructor>
+                        <parameter>jboss.ha:service=TestHASingletonDeployer</parameter>
+                        <parameter>start</parameter>
+                        <parameter>
+                           <bean class="javax.management.NotificationFilterSupport">
+                              <install method="enableType">
+                                 <parameter>org.jboss.ha.singleton.started</parameter>
+                              </install>
+                           </bean>
+                        </parameter>
+                     </constructor>
+               </bean>
+            <!--/value>
+            <value-->
+               <bean class="org.jboss.system.ListenerServiceMBeanSupport$SubscriptionInfo">
+                     <constructor>
+                        <parameter>jboss.ha:service=TestHASingletonDeployer</parameter>
+                        <parameter>stop</parameter>
+                        <parameter>
+                           <bean  class="javax.management.NotificationFilterSupport">
+                              <install method="enableType">
+                                 <parameter>org.jboss.ha.singleton.stopping</parameter>
+                              </install>
+                           </bean>
+                        </parameter>
+                     </constructor>
+               </bean>
+            <!--/value-->        
+         </list>
+      </property>
+   </bean>
+   
 </deployment>




More information about the jboss-cvs-commits mailing list