User: slaboure Date: 02/01/12 08:52:53 Modified: src/main/org/jboss/ha/framework/server DistributedReplicantManagerImpl.java Log: - DRM service is now registered as an MBEAN (but not started as an MBEAN: the start is still managed by the HAPartition) - Provide a listContent and listXmlContent for debugging purposes (useful with HTTP/JMX) Revision Changes Path 1.11 +112 -4 jbossmx/src/main/org/jboss/ha/framework/server/DistributedReplicantManagerImpl.java Index: DistributedReplicantManagerImpl.java =================================================================== RCS file: /cvsroot/jboss/jbossmx/src/main/org/jboss/ha/framework/server/DistributedReplicantManagerImpl.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- DistributedReplicantManagerImpl.java 2002/01/05 01:12:46 1.10 +++ DistributedReplicantManagerImpl.java 2002/01/12 16:52:53 1.11 @@ -13,6 +13,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Collection; +import java.util.HashSet; import java.io.Serializable; @@ -27,7 +28,7 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Bill Burke</a>. * @author <a href="mailto:[EMAIL PROTECTED]">Sacha Labourey</a>. - * @version $Revision: 1.10 $ + * @version $Revision: 1.11 $ * * <p><b>Revisions:</b><br> * <p><b>2001/10/31: marcf</b> @@ -46,7 +47,7 @@ */ public class DistributedReplicantManagerImpl - implements DistributedReplicantManager, + implements DistributedReplicantManagerImplMBean, HAPartition.HAMembershipListener { // Constants ----------------------------------------------------- @@ -62,6 +63,9 @@ protected Logger log = null; + protected javax.management.MBeanServer mbeanserver = null; + protected javax.management.ObjectName jmxName = null; + // Static -------------------------------------------------------- // Constructors -------------------------------------------------- @@ -71,9 +75,10 @@ * * @param partition {@link HAPartition} through which replicated objects will be exchanged */ - public DistributedReplicantManagerImpl(HAPartition partition) + public DistributedReplicantManagerImpl(HAPartition partition, javax.management.MBeanServer server) { this.partition = partition; + this.mbeanserver = server; this.log = Logger.getLogger(partition.getPartitionName() + ":ReplicantManager"); } @@ -85,7 +90,17 @@ partition.registerRPCHandler(SERVICE_NAME, this); log.debug("registerMembershipListener"); partition.registerMembershipListener(this); - } + + // subscribed this "sub-service" of HAPartition with JMX + // TODO: In the future (when state transfer issues will be completed), + // we will need to redesign the way HAPartitions and its sub-protocols are + // registered with JMX. They will most probably be independant JMX services. + // + String name = "jboss:service=" + SERVICE_NAME + + ",partitionName=" + this.partition.getPartitionName(); + this.jmxName = new javax.management.ObjectName(name); + this.mbeanserver.registerMBean(this, jmxName); + } public void start() throws Exception { @@ -95,10 +110,103 @@ public void stop() throws Exception { + this.mbeanserver.unregisterMBean (this.jmxName); + } + + public String listContent () throws Exception + { + // we merge all replicants services: local only or not + // + java.util.Collection services = this.getAllServices (); + + StringBuffer result = new StringBuffer (); + java.util.Iterator catsIter = services.iterator (); + + result.append ("<pre>"); + + while (catsIter.hasNext ()) + { + String category = (String)catsIter.next (); + java.util.Iterator keysIter = ((HashMap)this.replicants.get (category)).keySet ().iterator (); + + result.append ("-----------------------------------------------\n"); + result.append ("Service : ").append (category).append ("\n\n"); + + Serializable local = lookupLocalReplicant(category); + if (local == null) + result.append ("\t- Service is *not* available locally\n"); + else + result.append ("\t- Service *is* also available locally\n"); + + while (keysIter.hasNext ()) + { + String location = (String)keysIter.next (); + result.append ("\t- ").append(location).append ("\n"); + } + + result.append ("\n"); + + } + + result.append ("</pre>"); + + return result.toString (); } + public String listXmlContent () throws Exception + { + // we merge all replicants services: local only or not + // + java.util.Collection services = this.getAllServices (); + StringBuffer result = new StringBuffer (); + + result.append ("<ReplicantManager>\n"); + + java.util.Iterator catsIter = services.iterator (); + while (catsIter.hasNext ()) + { + String category = (String)catsIter.next (); + java.util.Iterator keysIter = ((HashMap)this.replicants.get (category)).keySet ().iterator (); + + result.append ("\t<Service>\n"); + result.append ("\t\t<ServiceName>").append (category).append ("</ServiceName>\n"); + + + Serializable local = lookupLocalReplicant(category); + if (local != null) + { + result.append ("\t\t<Location>\n"); + result.append ("\t\t\t<Name local=\"True\">").append (this.partition.getNodeName ()).append ("</Name>\n"); + result.append ("\t\t</Location>\n"); + } + + while (keysIter.hasNext ()) + { + String location = (String)keysIter.next (); + result.append ("\t\t<Location>\n"); + result.append ("\t\t\t<Name local=\"False\">").append (location).append ("</Name>\n"); + result.append ("\t\t</Location>\n"); + } + + result.append ("\t<Service>\n"); + + } + + result.append ("<ReplicantManager>\n"); + + return result.toString (); + } + // HAPartition.HAMembershipListener implementation ---------------------------------------------- + public Collection getAllServices () + { + HashSet services = new HashSet(); + services.addAll (localReplicants.keySet ()); + services.addAll (replicants.keySet ()); + return services; + } + public void membershipChanged(Vector deadMembers, Vector newMembers, Vector allMembers) { // Here we only care about deadMembers. Purge all replicant lists of deadMembers
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development