[jboss-cvs] JBoss Messaging SVN: r5546 - in trunk: src/main/org/jboss/messaging/core/management/impl and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Dec 19 05:37:50 EST 2008
Author: jmesnil
Date: 2008-12-19 05:37:49 -0500 (Fri, 19 Dec 2008)
New Revision: 5546
Modified:
trunk/src/main/org/jboss/messaging/core/management/ManagementService.java
trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/RandomFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java
Log:
make sure all resources are unregistered when the management service is stopped
ManagementService implements MessagingComponent and is started (resp. stopped) from MessagingServer.start() (resp. stop()) method
reenabled JMX management for the random failover tests
Modified: trunk/src/main/org/jboss/messaging/core/management/ManagementService.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/ManagementService.java 2008-12-19 10:34:38 UTC (rev 5545)
+++ trunk/src/main/org/jboss/messaging/core/management/ManagementService.java 2008-12-19 10:37:49 UTC (rev 5546)
@@ -40,6 +40,7 @@
import org.jboss.messaging.core.remoting.RemotingService;
import org.jboss.messaging.core.remoting.spi.Acceptor;
import org.jboss.messaging.core.security.Role;
+import org.jboss.messaging.core.server.MessagingComponent;
import org.jboss.messaging.core.server.MessagingServer;
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.cluster.BroadcastGroup;
@@ -56,7 +57,7 @@
* @version <tt>$Revision$</tt>
*
*/
-public interface ManagementService
+public interface ManagementService extends MessagingComponent
{
MessageCounterManager getMessageCounterManager();
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java 2008-12-19 10:34:38 UTC (rev 5545)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java 2008-12-19 10:37:49 UTC (rev 5546)
@@ -31,6 +31,7 @@
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -118,6 +119,7 @@
private SimpleString managementNotificationAddress;
+ private boolean started = false;
// Static --------------------------------------------------------
@@ -432,6 +434,29 @@
registry.put(objectName, managedResource);
}
+ // MessagingComponent implementation -----------------------------
+
+ public void start() throws Exception
+ {
+ started = true;
+ }
+
+ public synchronized void stop() throws Exception
+ {
+ Set<ObjectName> objectNames = new HashSet<ObjectName>(registry.keySet());
+
+ for (ObjectName objectName : objectNames)
+ {
+ unregisterResource(objectName);
+ }
+ started = false;
+ }
+
+ public boolean isStarted()
+ {
+ return started;
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2008-12-19 10:34:38 UTC (rev 5545)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2008-12-19 10:37:49 UTC (rev 5546)
@@ -200,6 +200,8 @@
throw new IllegalStateException("RemotingService must be started before MessagingServer is started");
}
+ managementService.start();
+
// The rest of the components are not pluggable and created and started
// here
@@ -351,6 +353,7 @@
resourceManager = null;
serverManagement = null;
+ managementService.stop();
started = false;
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTest.java 2008-12-19 10:34:38 UTC (rev 5545)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTest.java 2008-12-19 10:37:49 UTC (rev 5546)
@@ -1342,8 +1342,6 @@
.add(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory",
backupParams));
backupConf.setBackup(true);
- // This will make GC easier since it won't hang references to MessageCounters and other objects. (This will make debug easier in certain situations also)
- backupConf.setJMXManagementEnabled(false);
backupService = MessagingServiceImpl.newNullStorageMessagingService(backupConf);
backupService.start();
@@ -1361,8 +1359,6 @@
"backup-connector");
connectors.put(backupTC.getName(), backupTC);
liveConf.setConnectorConfigurations(connectors);
- // This will make GC easier since it won't hang references to MessageCounters and other objects. (This will make debug easier in certain situations also)
- liveConf.setJMXManagementEnabled(false);
liveConf.setBackupConnectorName(backupTC.getName());
liveService = MessagingServiceImpl.newNullStorageMessagingService(liveConf);
liveService.start();
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/RandomFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/RandomFailoverTest.java 2008-12-19 10:34:38 UTC (rev 5545)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/RandomFailoverTest.java 2008-12-19 10:37:49 UTC (rev 5546)
@@ -1478,8 +1478,6 @@
.add(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory",
backupParams));
backupConf.setBackup(true);
- // This will make GC easier since it won't hang references to MessageCounters and other objects. (This will make debug easier in certain situations also)
- backupConf.setJMXManagementEnabled(false);
backupService = MessagingServiceImpl.newNullStorageMessagingService(backupConf);
backupService.start();
@@ -1489,8 +1487,6 @@
Configuration liveConf = new ConfigurationImpl();
liveConf.setSecurityEnabled(false);
- // This will make GC easier since it won't hang references to MessageCounters and other objects. (This will make debug easier in certain situations also)
- liveConf.setJMXManagementEnabled(false);
liveConf.getAcceptorConfigurations()
.add(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory"));
Map<String, TransportConfiguration> connectors = new HashMap<String, TransportConfiguration>();
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java 2008-12-19 10:34:38 UTC (rev 5545)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java 2008-12-19 10:37:49 UTC (rev 5546)
@@ -32,11 +32,13 @@
import static org.jboss.messaging.core.security.CheckType.READ;
import static org.jboss.messaging.core.security.CheckType.WRITE;
import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
import static org.jboss.messaging.tests.util.RandomUtil.randomString;
import java.lang.management.ManagementFactory;
import java.nio.ByteBuffer;
+import javax.management.MBeanServer;
import javax.management.ObjectName;
import junit.framework.TestCase;
@@ -72,7 +74,7 @@
public void testHandleManagementMessageWithAttribute() throws Exception
{
- ManagementService managementService = new ManagementServiceImpl(ManagementFactory.getPlatformMBeanServer(), true);
+ ManagementService managementService = new ManagementServiceImpl(ManagementFactory.getPlatformMBeanServer(), false);
assertNotNull(managementService);
SimpleString address = RandomUtil.randomSimpleString();
@@ -89,7 +91,6 @@
SimpleString value = (SimpleString)message.getProperty(new SimpleString("Address"));
assertNotNull(value);
assertEquals(address, value);
-
}
public void testHandleManagementMessageWithOperation() throws Exception
@@ -166,9 +167,34 @@
verify(resource);
}
+
+ public void testStop() throws Exception
+ {
+ MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
+
+ ManagementService managementService = new ManagementServiceImpl(mbeanServer, true);
+ assertNotNull(managementService);
+ managementService.registerAddress(randomSimpleString());
+
+ assertEquals(1, mbeanServer.queryMBeans(ObjectName.getInstance(ManagementServiceImpl.DOMAIN + ":*"), null).size());
+
+ managementService.stop();
+
+ assertEquals(0, mbeanServer.queryMBeans(ObjectName.getInstance(ManagementServiceImpl.DOMAIN + ":*"), null).size());
+ }
+
// Package protected ---------------------------------------------
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
+ assertEquals(0, mbeanServer.queryMBeans(ObjectName.getInstance(ManagementServiceImpl.DOMAIN + ":*"), null).size());
+ super.tearDown();
+ }
+
// Protected -----------------------------------------------------
// Private -------------------------------------------------------
More information about the jboss-cvs-commits
mailing list