[jboss-cvs] JBossAS SVN: r62917 - branches/Branch_4_2/cluster/src/main/org/jboss/ha/framework/server.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 8 19:20:09 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-05-08 19:20:09 -0400 (Tue, 08 May 2007)
New Revision: 62917
Modified:
branches/Branch_4_2/cluster/src/main/org/jboss/ha/framework/server/ClusterPartition.java
Log:
[JBAS-4406] Register Channel in JMX if not from ChannelFactory
Modified: branches/Branch_4_2/cluster/src/main/org/jboss/ha/framework/server/ClusterPartition.java
===================================================================
--- branches/Branch_4_2/cluster/src/main/org/jboss/ha/framework/server/ClusterPartition.java 2007-05-08 23:18:20 UTC (rev 62916)
+++ branches/Branch_4_2/cluster/src/main/org/jboss/ha/framework/server/ClusterPartition.java 2007-05-08 23:20:09 UTC (rev 62917)
@@ -26,6 +26,8 @@
import java.net.InetAddress;
import java.rmi.dgc.VMID;
import java.rmi.server.UID;
+import java.util.Iterator;
+import java.util.Set;
import java.util.Vector;
import javax.management.Attribute;
@@ -46,6 +48,7 @@
import org.jgroups.Version;
import org.jgroups.debug.Debugger;
import org.jgroups.jmx.JChannelFactoryMBean;
+import org.jgroups.jmx.JmxConfigurator;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@@ -66,6 +69,10 @@
{
// Constants -----------------------------------------------------
+ public static final String JGROUPS_JMX_DOMAIN = "jgroups.mux";
+ public static final String CHANNEL_JMX_ATTRIBUTES = "type=channel,cluster=";
+ public static final String PROTOCOL_JMX_ATTRIBUTES = "type=protocol,cluster=";
+
// Attributes ----------------------------------------------------
protected String partitionName = ServerConfigUtil.getDefaultPartitionName();
@@ -103,6 +110,9 @@
protected long method_call_timeout=60000;
+
+ protected boolean channelRegistered;
+ protected boolean protocolsRegistered;
// Static --------------------------------------------------------
@@ -327,6 +337,8 @@
else
{
this.channel = new org.jgroups.JChannel(jgProps);
+ // JBAS-4406 Hack to register the channel
+ registerChannelInJmx();
}
if(use_debugger && debugger == null)
@@ -410,7 +422,9 @@
protected void destroyService() throws Exception
{
log.debug("Destroying ClusterPartition: " + partitionName);
- partition.destroyPartition();
+ partition.destroyPartition();
+ // JBAS-4406 Hack
+ unregisterChannelFromJmx();
log.debug("Destroyed ClusterPartition: " + partitionName);
}
@@ -528,4 +542,68 @@
debugger=null;
}
}
+
+ protected void registerChannelInJmx()
+ {
+ if (server != null)
+ {
+ try
+ {
+ String protocolPrefix = JGROUPS_JMX_DOMAIN + ":" + PROTOCOL_JMX_ATTRIBUTES + getPartitionName();
+ JmxConfigurator.registerProtocols(server, channel, protocolPrefix);
+ protocolsRegistered = true;
+
+ String name = JGROUPS_JMX_DOMAIN + ":" + CHANNEL_JMX_ATTRIBUTES + getPartitionName();
+ JmxConfigurator.registerChannel(channel, server, name);
+ channelRegistered = true;
+ }
+ catch (Exception e)
+ {
+ log.error("Caught exception registering channel in JXM", e);
+ }
+ }
+ }
+
+ protected void unregisterChannelFromJmx()
+ {
+ ObjectName on = null;
+ if (channelRegistered)
+ {
+ // Unregister the channel itself
+ try
+ {
+ on = new ObjectName(JGROUPS_JMX_DOMAIN + ":" + CHANNEL_JMX_ATTRIBUTES + getPartitionName());
+ server.unregisterMBean(on);
+ }
+ catch (Exception e)
+ {
+ if (on != null)
+ log.error("Caught exception unregistering channel at " + on, e);
+ else
+ log.error("Caught exception unregistering channel", e);
+ }
+ }
+
+ if (protocolsRegistered)
+ {
+ // Unregister the protocols
+ try
+ {
+ on = new ObjectName(JGROUPS_JMX_DOMAIN + ":*," + PROTOCOL_JMX_ATTRIBUTES + getPartitionName());
+ Set mbeans=server.queryNames(on, null);
+ if(mbeans != null) {
+ for(Iterator it=mbeans.iterator(); it.hasNext();) {
+ server.unregisterMBean((ObjectName)it.next());
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ if (on != null)
+ log.error("Caught exception unregistering protocols at " + on, e);
+ else
+ log.error("Caught exception unregistering protocols", e);
+ }
+ }
+ }
}
More information about the jboss-cvs-commits
mailing list