You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2009/06/26 18:38:01 UTC

svn commit: r788757 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/ft/MasterBroker.java test/java/org/apache/activemq/broker/ft/MasterSlaveSlaveDieTest.java

Author: gtully
Date: Fri Jun 26 16:38:01 2009
New Revision: 788757

URL: http://svn.apache.org/viewvc?rev=788757&view=rev
Log:
resolve: https://issues.apache.org/activemq/browse/AMQ-2305 - think the correct fix is to have the masterBroker stop but not propagate the stop through the filter chain. if it does not stop then it will have a bunch of failures on sync with the slave. the issues is visible when a plugin is the next brokerfilter in the chain

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/ft/MasterSlaveSlaveDieTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java?rev=788757&r1=788756&r2=788757&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterBroker.java Fri Jun 26 16:38:01 2009
@@ -105,7 +105,6 @@
      * @throws Exception
      */
     public void stop() throws Exception {
-        super.stop();
         stopProcessing();
     }
 

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/ft/MasterSlaveSlaveDieTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/ft/MasterSlaveSlaveDieTest.java?rev=788757&r1=788756&r2=788757&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/ft/MasterSlaveSlaveDieTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/ft/MasterSlaveSlaveDieTest.java Fri Jun 26 16:38:01 2009
@@ -18,27 +18,52 @@
 
 import java.net.URI;
 import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import junit.framework.TestCase;
 
+import org.apache.activemq.broker.BrokerPlugin;
+import org.apache.activemq.broker.BrokerPluginSupport;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.util.SocketProxy;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public class MasterSlaveSlaveDieTest extends TestCase {
+    
+    private static final Log LOG = LogFactory.getLog(MasterSlaveSlaveDieTest.class);
 
+    private final AtomicBoolean pluginStopped = new AtomicBoolean(false);
+    class Plugin extends BrokerPluginSupport {
+
+        @Override
+        public void start() throws Exception {
+            LOG.info("plugin start");
+            super.start();
+        }
+
+        @Override
+        public void stop() throws Exception {
+            LOG.info("plugin stop");
+            pluginStopped.set(true);
+            super.stop();
+        }
+        
+    }
     public void testSlaveDieMasterStays() throws Exception {
         final BrokerService master = new BrokerService();
         master.setBrokerName("master");
         master.setPersistent(false);
         master.addConnector("tcp://localhost:0");
         master.setWaitForSlave(true);
-
+        master.setPlugins(new BrokerPlugin[] { new Plugin() });
+        
         final BrokerService slave = new BrokerService();
         slave.setBrokerName("slave");
         slave.setPersistent(false);
         URI masterUri = master.getTransportConnectors().get(0).getConnectUri();
-        SocketProxy masterProxy = new SocketProxy(masterUri);
-        slave.setMasterConnectorURI(masterProxy.getUrl().toString());
+        //SocketProxy masterProxy = new SocketProxy(masterUri);
+        slave.setMasterConnectorURI(masterUri.toString());
         
         slave.setUseJmx(false);
         slave.getManagementContext().setCreateConnector(false);
@@ -57,14 +82,12 @@
         
         master.waitUntilStarted();
         
-        // kill socket to master
-        masterProxy.close();
-        
-        // in case a stop is too controlled an exit
-        //slave.stop();
-        Thread.sleep(5000);
-
-        assertTrue(master.isStarted());
-
+        LOG.info("killing slave..");
+        slave.stop();
+        slave.waitUntilStopped();
+
+        LOG.info("checking master still alive");
+        assertTrue("master is still alive", master.isStarted());
+        assertFalse("plugin was not yet stopped", pluginStopped.get());
     }
 }
\ No newline at end of file