[jboss-cvs] JBossAS SVN: r87503 - in trunk: cluster/src/main/org/jboss/ha/singleton and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Apr 17 12:46:04 EDT 2009
Author: pferraro
Date: 2009-04-17 12:46:04 -0400 (Fri, 17 Apr 2009)
New Revision: 87503
Added:
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HAServiceUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHAService.java
trunk/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHAServiceMBean.java
trunk/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHASingleton.java
trunk/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHASingletonMBean.java
trunk/testsuite/src/resources/cluster/haservice/
trunk/testsuite/src/resources/cluster/haservice/jboss-beans.xml
Modified:
trunk/cluster/src/main/org/jboss/ha/jmx/HAServiceMBeanSupport.java
trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonSupport.java
trunk/testsuite/imports/sections/cluster.xml
Log:
[JBAS-6792] Ported fix from Branch_5_x
Modified: trunk/cluster/src/main/org/jboss/ha/jmx/HAServiceMBeanSupport.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/jmx/HAServiceMBeanSupport.java 2009-04-17 16:41:31 UTC (rev 87502)
+++ trunk/cluster/src/main/org/jboss/ha/jmx/HAServiceMBeanSupport.java 2009-04-17 16:46:04 UTC (rev 87503)
@@ -25,6 +25,7 @@
import org.jboss.ha.framework.interfaces.HAService;
import org.jboss.ha.framework.server.HAServiceImpl;
+import org.jboss.ha.framework.server.HAServiceRpcHandler;
/**
* Management Bean for an HA-Service.
@@ -47,6 +48,7 @@
*/
public class HAServiceMBeanSupport
extends AbstractHAServiceMBeanSupport<HAService<Notification>>
+ implements HAServiceRpcHandler<Notification>
{
/**
* @see org.jboss.ha.jmx.AbstractHAServiceMBeanSupport#createHAService()
@@ -54,7 +56,18 @@
@Override
protected HAService<Notification> createHAService()
{
- return new HAServiceImpl<Notification>(this, this);
+ return new HAServiceImpl<Notification>(this, this)
+ {
+ /**
+ * Expose HAServiceMBeanSupport subclass methods to rpc handler
+ * @see org.jboss.ha.framework.server.HAServiceImpl#getRpcHandler()
+ */
+ @Override
+ protected HAServiceRpcHandler<Notification> getRpcHandler()
+ {
+ return HAServiceMBeanSupport.this;
+ }
+ };
}
}
Modified: trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonSupport.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonSupport.java 2009-04-17 16:41:31 UTC (rev 87502)
+++ trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonSupport.java 2009-04-17 16:46:04 UTC (rev 87503)
@@ -26,7 +26,9 @@
import org.jboss.ha.framework.interfaces.HASingleton;
import org.jboss.ha.framework.interfaces.HASingletonElectionPolicy;
import org.jboss.ha.framework.interfaces.HASingletonLifecycle;
+import org.jboss.ha.framework.server.HAServiceRpcHandler;
import org.jboss.ha.framework.server.HASingletonImpl;
+import org.jboss.ha.framework.server.HASingletonRpcHandler;
import org.jboss.ha.jmx.AbstractHAServiceMBeanSupport;
import org.jboss.managed.api.annotation.ManagementProperty;
import org.jboss.managed.api.annotation.ViewUse;
@@ -44,7 +46,7 @@
*/
public class HASingletonSupport
extends AbstractHAServiceMBeanSupport<HASingleton<Notification>>
- implements HASingleton<Notification>
+ implements HASingleton<Notification>, HASingletonRpcHandler<Notification>
{
/**
* @see org.jboss.ha.framework.interfaces.HASingletonMBean#isMasterNode()
@@ -129,6 +131,25 @@
@Override
protected HASingleton<Notification> createHAService()
{
- return new HASingletonImpl<Notification>(this, this, this);
+ return new HASingletonImpl<Notification>(this, this, this)
+ {
+ /**
+ * Expose HASingletonSupport subclass methods to rpc handler
+ * @see org.jboss.ha.framework.server.HASingletonImpl#getRpcHandler()
+ */
+ @Override
+ protected HAServiceRpcHandler<Notification> getRpcHandler()
+ {
+ return HASingletonSupport.this;
+ }
+ };
}
+
+ /**
+ * @see org.jboss.ha.framework.server.HASingletonRpcHandler#stopOldMaster()
+ */
+ public void stopOldMaster() throws Exception
+ {
+ ((HASingletonImpl<Notification>) this.getHAService()).stopOldMaster();
+ }
}
Modified: trunk/testsuite/imports/sections/cluster.xml
===================================================================
--- trunk/testsuite/imports/sections/cluster.xml 2009-04-17 16:41:31 UTC (rev 87502)
+++ trunk/testsuite/imports/sections/cluster.xml 2009-04-17 16:46:04 UTC (rev 87503)
@@ -99,6 +99,16 @@
<copy todir="${build.lib}"
file="${build.resources}/cluster/hasingleton/ha-singleton-jboss-beans.xml"
overwrite="true"/>
+
+ <!--beans for testing HAServiceUnitTestCase, HASingletonUnitTestCase -->
+ <jar destfile="${build.lib}/ha-service.sar">
+ <metainf dir="${build.resources}/cluster/haservice">
+ <include name="*.xml"/>
+ </metainf>
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/cluster/haservice/**"/>
+ </fileset>
+ </jar>
<!-- ha-invoker adaptor sar -->
<jar destfile="${build.lib}/ha-invoker.sar">
Added: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HAServiceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HAServiceUnitTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HAServiceUnitTestCase.java 2009-04-17 16:46:04 UTC (rev 87503)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.defaultcfg.test;
+
+import java.util.List;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * Verifies that public methods of an HAServiceMBeanSupport subclass are accessible via the HAService's rpc mechanism.
+ *
+ * @author Paul Ferraro
+ */
+public class HAServiceUnitTestCase extends JBossClusteredTestCase
+{
+ public HAServiceUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return JBossClusteredTestCase.getDeploySetup(HAServiceUnitTestCase.class, "ha-service.sar");
+ }
+
+ public void testTrueEcho() throws Exception
+ {
+ MBeanServerConnection[] adaptors = this.getAdaptors();
+ ObjectName on = new ObjectName("jboss.ha:service=EchoHAService");
+ Object[] args = new Object[] {"echo", new Object[] {true}, new Class[] {boolean.class}};
+ String[] signature = new String[] {String.class.getName(), Object[].class.getName(), Class[].class.getName()};
+ List<?> responses = (List<?>) adaptors[0].invoke(on, "callMethodOnPartition", args, signature);
+ log.debug("Response list: " + responses);
+ assertEquals(1, responses.size());
+
+ if (responses.get(0) instanceof Exception)
+ {
+ throw (Exception) responses.get(0);
+ }
+
+ assertTrue(((Boolean) responses.get(0)).booleanValue());
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonUnitTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonUnitTestCase.java 2009-04-17 16:46:04 UTC (rev 87503)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.defaultcfg.test;
+
+import java.util.List;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * Verifies that public methods of an HASingletonSupport subclass are accessible via the HASingleton's rpc mechanism.
+ *
+ * @author Paul Ferraro
+ */
+public class HASingletonUnitTestCase extends JBossClusteredTestCase
+{
+ public HASingletonUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return JBossClusteredTestCase.getDeploySetup(HASingletonUnitTestCase.class, "ha-service.sar");
+ }
+
+ public void testEcho() throws Exception
+ {
+ Boolean result = this.testMethod("echo", new Object[] { true }, new Class[] { Boolean.TYPE }, Boolean.class);
+
+ assertTrue(result.booleanValue());
+ }
+
+ public void testStopOldMaster() throws Exception
+ {
+ Void result = this.testMethod("stopOldMaster", null, null, Void.class);
+
+ assertNull(result);
+ }
+
+ private <T> T testMethod(String method, Object[] parameters, Class<?>[] types, Class<T> resultType) throws Exception
+ {
+ MBeanServerConnection[] adaptors = this.getAdaptors();
+ ObjectName on = ObjectName.getInstance("jboss.ha:service=EchoHASingleton");
+ Object[] args = new Object[] { method, parameters, types };
+ String[] signature = new String[] { String.class.getName(), Object[].class.getName(), Class[].class.getName() };
+ List<?> responses = (List<?>) adaptors[0].invoke(on, "callMethodOnPartition", args, signature);
+
+ log.debug("Response list: " + responses);
+
+ assertEquals(1, responses.size());
+
+ if (responses.get(0) instanceof Exception)
+ {
+ throw (Exception) responses.get(0);
+ }
+
+ return resultType.cast(responses.get(0));
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHAService.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHAService.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHAService.java 2009-04-17 16:46:04 UTC (rev 87503)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.haservice;
+
+import org.jboss.ha.jmx.HAServiceMBeanSupport;
+
+/**
+ * A TestHAService.
+ *
+ * @author Paul Ferraro
+ */
+public class EchoHAService extends HAServiceMBeanSupport implements EchoHAServiceMBean
+{
+ /**
+ * @see org.jboss.test.cluster.haservice.EchoHAServiceMBean#echo(boolean)
+ */
+ public boolean echo(boolean echo)
+ {
+ return echo;
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHAServiceMBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHAServiceMBean.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHAServiceMBean.java 2009-04-17 16:46:04 UTC (rev 87503)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.haservice;
+
+import org.jboss.ha.jmx.HAServiceMBean;
+
+/**
+ * A TestHAServiceMBean.
+ *
+ * @author Paul Ferraro
+ */
+public interface EchoHAServiceMBean extends HAServiceMBean
+{
+ boolean echo(boolean echo);
+}
Added: trunk/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHASingleton.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHASingleton.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHASingleton.java 2009-04-17 16:46:04 UTC (rev 87503)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.haservice;
+
+import org.jboss.ha.singleton.HASingletonSupport;
+
+/**
+ * A EchoHASingleton.
+ *
+ * @author Paul Ferraro
+ */
+public class EchoHASingleton extends HASingletonSupport implements EchoHASingletonMBean
+{
+ /**
+ * @see org.jboss.test.cluster.haservice.EchoHAServiceMBean#echo(boolean)
+ */
+ public boolean echo(boolean echo)
+ {
+ return echo;
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHASingletonMBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHASingletonMBean.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHASingletonMBean.java 2009-04-17 16:46:04 UTC (rev 87503)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.haservice;
+
+import org.jboss.ha.framework.interfaces.HASingletonMBean;
+
+/**
+ * A EchoHASingletonMBean.
+ *
+ * @author Paul Ferraro
+ */
+public interface EchoHASingletonMBean extends EchoHAServiceMBean, HASingletonMBean
+{
+
+}
Added: trunk/testsuite/src/resources/cluster/haservice/jboss-beans.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/haservice/jboss-beans.xml (rev 0)
+++ trunk/testsuite/src/resources/cluster/haservice/jboss-beans.xml 2009-04-17 16:46:04 UTC (rev 87503)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="EchoHAService" class="org.jboss.test.cluster.haservice.EchoHAService">
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.ha:service=EchoHAService", exposedInterface=org.jboss.test.cluster.haservice.EchoHAServiceMBean.class, registerDirectly=true)</annotation>
+ <property name="clusterPartition"><inject bean="HAPartition"/></property>
+ </bean>
+
+ <bean name="EchoHASingleton" class="org.jboss.test.cluster.haservice.EchoHASingleton">
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.ha:service=EchoHASingleton", exposedInterface=org.jboss.test.cluster.haservice.EchoHASingletonMBean.class, registerDirectly=true)</annotation>
+ <property name="clusterPartition"><inject bean="HAPartition"/></property>
+ </bean>
+
+</deployment>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list