[jboss-cvs] JBoss Messaging SVN: r8194 - in branches/JBM1842/src/main/org/jboss/messaging/core: jmx and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 26 00:01:50 EST 2011
Author: gaohoward
Date: 2011-01-26 00:01:50 -0500 (Wed, 26 Jan 2011)
New Revision: 8194
Modified:
branches/JBM1842/src/main/org/jboss/messaging/core/impl/postoffice/GroupMember.java
branches/JBM1842/src/main/org/jboss/messaging/core/impl/postoffice/MessagingPostOffice.java
branches/JBM1842/src/main/org/jboss/messaging/core/jmx/MessagingPostOfficeService.java
Log:
add jmx
Modified: branches/JBM1842/src/main/org/jboss/messaging/core/impl/postoffice/GroupMember.java
===================================================================
--- branches/JBM1842/src/main/org/jboss/messaging/core/impl/postoffice/GroupMember.java 2011-01-25 17:18:59 UTC (rev 8193)
+++ branches/JBM1842/src/main/org/jboss/messaging/core/impl/postoffice/GroupMember.java 2011-01-26 05:01:50 UTC (rev 8194)
@@ -27,6 +27,7 @@
import org.jgroups.blocks.GroupRequest;
import org.jgroups.blocks.MessageDispatcher;
import org.jgroups.blocks.RequestHandler;
+import org.jgroups.jmx.JmxConfigurator;
import org.jgroups.util.Rsp;
import org.jgroups.util.RspList;
@@ -37,6 +38,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import java.util.Vector;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
@@ -46,6 +48,9 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
/**
*
* This class handles the interface with JGroups
@@ -58,6 +63,10 @@
*/
public class GroupMember
{
+ public static final String JGROUPS_JMX_DOMAIN = "jboss.jgroups";
+ public static final String CHANNEL_JMX_ATTRIBUTES = "type=channel,cluster=";
+ public static final String PROTOCOL_JMX_ATTRIBUTES = "type=protocol,cluster=";
+
public static final String DATA_SUFFIX = "-DATA";
public static final String CONTROL_SUFFIX = "-CTRL";
@@ -94,6 +103,11 @@
private volatile boolean starting;
+ //jmx
+ protected boolean channelRegistered;
+ protected boolean protocolsRegistered;
+
+
//We need to process view changes on a different thread, since if we have more than one node running
//in the same VM then the thread that sends the leave message ends up executing the view change on the other node
//We probably don't need this if all nodes are in different VMs
@@ -679,5 +693,70 @@
}
}
}
+
+ public void registerChannelInJmx(MBeanServer server, String channelPartitionName)
+ {
+ try
+ {
+ String protocolPrefix = JGROUPS_JMX_DOMAIN + ":" + PROTOCOL_JMX_ATTRIBUTES + channelPartitionName;
+ JmxConfigurator.registerProtocols(server, (JChannel)controlChannel, protocolPrefix);
+ protocolsRegistered = true;
+
+ log.debug("Registed protocol: " + protocolPrefix);
+
+ String name = JGROUPS_JMX_DOMAIN + ":" + CHANNEL_JMX_ATTRIBUTES + channelPartitionName;
+ JmxConfigurator.registerChannel((JChannel)controlChannel, server, name);
+ channelRegistered = true;
+
+ log.debug("Registed channel: " + name);
+ }
+ catch (Exception e)
+ {
+ log.error("Caught exception registering channel in JXM", e);
+ }
+ }
+
+ public void unregisterChannelInJmx(MBeanServer server, String channelPartitionName)
+ {
+ ObjectName on = null;
+ if (channelRegistered)
+ {
+ // Unregister the channel itself
+ try
+ {
+ on = new ObjectName(JGROUPS_JMX_DOMAIN + ":" + CHANNEL_JMX_ATTRIBUTES + channelPartitionName);
+ 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 + channelPartitionName);
+ 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);
+ }
+ }
+ }
}
Modified: branches/JBM1842/src/main/org/jboss/messaging/core/impl/postoffice/MessagingPostOffice.java
===================================================================
--- branches/JBM1842/src/main/org/jboss/messaging/core/impl/postoffice/MessagingPostOffice.java 2011-01-25 17:18:59 UTC (rev 8193)
+++ branches/JBM1842/src/main/org/jboss/messaging/core/impl/postoffice/MessagingPostOffice.java 2011-01-26 05:01:50 UTC (rev 8194)
@@ -41,6 +41,7 @@
import javax.management.ListenerNotFoundException;
import javax.management.MBeanNotificationInfo;
+import javax.management.MBeanServer;
import javax.management.Notification;
import javax.management.NotificationBroadcasterSupport;
import javax.management.NotificationFilter;
@@ -447,7 +448,7 @@
started = true;
- log.debug(this + " started");
+ log.debug(this + " started");
}
//this method will trigger a dedicated thread to write time stamp
@@ -4163,4 +4164,15 @@
nodeStateRefreshInterval = newValue;
}
+ public void registerChannelInJmx(MBeanServer server, String channelPartitionName)
+ {
+ groupMember.registerChannelInJmx(server, channelPartitionName);
+ }
+
+ public void unregisterChannelInJmx(MBeanServer server, String channelPartitionName)
+ {
+ groupMember.unregisterChannelInJmx(server, channelPartitionName);
+ }
+
+
}
Modified: branches/JBM1842/src/main/org/jboss/messaging/core/jmx/MessagingPostOfficeService.java
===================================================================
--- branches/JBM1842/src/main/org/jboss/messaging/core/jmx/MessagingPostOfficeService.java 2011-01-25 17:18:59 UTC (rev 8193)
+++ branches/JBM1842/src/main/org/jboss/messaging/core/jmx/MessagingPostOfficeService.java 2011-01-26 05:01:50 UTC (rev 8194)
@@ -47,6 +47,7 @@
import org.jboss.messaging.core.impl.tx.TransactionRepository;
import org.jboss.messaging.util.ExceptionUtil;
import org.jboss.messaging.util.JMXAccessor;
+import org.jgroups.jmx.JmxConfigurator;
import org.w3c.dom.Element;
/**
@@ -515,6 +516,18 @@
postOffice.start();
started = true;
+
+ if (clustered)
+ {
+ try
+ {
+ postOffice.registerChannelInJmx(server, channelPartitionName);
+ }
+ catch (Exception e)
+ {
+ log.error("Caught exception registering channel in JXM", e);
+ }
+ }
}
catch (Throwable t)
{
@@ -528,6 +541,11 @@
{
throw new IllegalStateException("Service is not started");
}
+
+ if (clustered)
+ {
+ postOffice.unregisterChannelInJmx(server, channelPartitionName);
+ }
super.stopService();
More information about the jboss-cvs-commits
mailing list