From commits-return-11654-apmail-activemq-commits-archive=activemq.apache.org@activemq.apache.org Fri Sep 04 12:47:33 2009 Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 42068 invoked from network); 4 Sep 2009 12:47:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Sep 2009 12:47:33 -0000 Received: (qmail 96391 invoked by uid 500); 4 Sep 2009 12:47:33 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 96342 invoked by uid 500); 4 Sep 2009 12:47:32 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 96333 invoked by uid 99); 4 Sep 2009 12:47:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Sep 2009 12:47:32 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Sep 2009 12:47:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 32CCF2388901; Fri, 4 Sep 2009 12:47:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r811371 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java test/java/org/apache/activemq/transport/discovery/DiscoveryNetworkReconnectTest.java Date: Fri, 04 Sep 2009 12:47:01 -0000 To: commits@activemq.apache.org From: gtully@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090904124701.32CCF2388901@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gtully Date: Fri Sep 4 12:47:00 2009 New Revision: 811371 URL: http://svn.apache.org/viewvc?rev=811371&view=rev Log: resolve some timing issues that caused intermittent failure of the test for: https://issues.apache.org/activemq/browse/AMQ-1855 - also wait a little longer for a close to complete before restarting Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/discovery/DiscoveryNetworkReconnectTest.java Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java?rev=811371&r1=811370&r2=811371&view=diff ============================================================================== --- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java (original) +++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java Fri Sep 4 12:47:00 2009 @@ -377,8 +377,8 @@ } }); - if( !sendShutdown.await(5, TimeUnit.SECONDS) ) { - LOG.debug("Network Could not shutdown in a timely manner"); + if( !sendShutdown.await(10, TimeUnit.SECONDS) ) { + LOG.info("Network Could not shutdown in a timely manner"); } } finally { ServiceStopper ss = new ServiceStopper(); Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/discovery/DiscoveryNetworkReconnectTest.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/discovery/DiscoveryNetworkReconnectTest.java?rev=811371&r1=811370&r2=811371&view=diff ============================================================================== --- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/discovery/DiscoveryNetworkReconnectTest.java (original) +++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/discovery/DiscoveryNetworkReconnectTest.java Fri Sep 4 12:47:00 2009 @@ -16,10 +16,13 @@ */ package org.apache.activemq.transport.discovery; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; import java.net.URI; +import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; +import javax.management.ObjectInstance; import javax.management.ObjectName; import org.apache.activemq.broker.BrokerService; @@ -31,8 +34,10 @@ import org.apache.commons.logging.LogFactory; import org.jmock.Expectations; import org.jmock.Mockery; +import org.jmock.api.Invocation; import org.jmock.integration.junit4.JMock; import org.jmock.integration.junit4.JUnit4Mockery; +import org.jmock.lib.action.CustomAction; import org.jmock.lib.legacy.ClassImposteriser; import org.junit.After; import org.junit.Before; @@ -51,7 +56,10 @@ final String groupName = "GroupID-" + "DiscoveryNetworkReconnectTest"; final String discoveryAddress = "multicast://default?group=" + groupName + "&initialReconnectDelay=1000"; + final Semaphore mbeanRegistered = new Semaphore(0); + final Semaphore mbeanUnregistered = new Semaphore(0); + private DiscoveryAgent agent; SocketProxy proxy; @@ -68,15 +76,12 @@ brokerA.start(); proxy = new SocketProxy(brokerA.getTransportConnectors().get(0).getConnectUri()); - //new SocketProxy(new URI("tcp://localhost:61617")); - managementContext = context.mock(ManagementContext.class); context.checking(new Expectations(){{ allowing (managementContext).getJmxDomainName(); will (returnValue("Test")); allowing (managementContext).start(); allowing (managementContext).stop(); - allowing (managementContext).unregisterMBean(with(any(ObjectName.class))); // expected MBeans allowing (managementContext).registerMBean(with(any(Object.class)), with(equal( @@ -86,10 +91,31 @@ allowing (managementContext).registerMBean(with(any(Object.class)), with(equal( new ObjectName("Test:BrokerName=BrokerNC,Type=Topic,Destination=ActiveMQ.Advisory.Connection")))); - // due to reconnect we get two registrations atLeast(maxReconnects - 1).of (managementContext).registerMBean(with(any(Object.class)), with(equal( + new ObjectName("Test:BrokerName=BrokerNC,Type=NetworkBridge,NetworkConnectorName=localhost,Name=localhost/127.0.0.1_" + + proxy.getUrl().getPort())))); will(new CustomAction("signal register network mbean") { + public Object invoke(Invocation invocation) throws Throwable { + LOG.info("Mbean Registered: " + invocation.getParameter(0)); + mbeanRegistered.release(); + return new ObjectInstance((ObjectName)invocation.getParameter(0), "dscription"); + } + }); + atLeast(maxReconnects - 1).of (managementContext).unregisterMBean(with(equal( new ObjectName("Test:BrokerName=BrokerNC,Type=NetworkBridge,NetworkConnectorName=localhost,Name=localhost/127.0.0.1_" - + proxy.getUrl().getPort())))); + + proxy.getUrl().getPort())))); will(new CustomAction("signal unregister network mbean") { + public Object invoke(Invocation invocation) throws Throwable { + LOG.info("Mbean Unregistered: " + invocation.getParameter(0)); + mbeanUnregistered.release(); + return null; + } + }); + + allowing (managementContext).unregisterMBean(with(equal( + new ObjectName("Test:BrokerName=BrokerNC,Type=Broker")))); + allowing (managementContext).unregisterMBean(with(equal( + new ObjectName("Test:BrokerName=BrokerNC,Type=NetworkConnector,NetworkConnectorName=localhost")))); + allowing (managementContext).unregisterMBean(with(equal( + new ObjectName("Test:BrokerName=BrokerNC,Type=Topic,Destination=ActiveMQ.Advisory.Connection")))); }}); brokerB = new BrokerService(); @@ -102,6 +128,7 @@ public void tearDown() throws Exception { brokerA.stop(); brokerB.stop(); + proxy.close(); } private void configure(BrokerService broker) { @@ -138,17 +165,19 @@ // Wait for connection assertTrue("we got a network connection in a timely manner", Wait.waitFor(new Wait.Condition() { public boolean isSatisified() throws Exception { - return proxy.connections.size() == 1; + return proxy.connections.size() >= 1; } })); - Thread.sleep(3000); - // force an inactivity timeout timeout + // wait for network connector + assertTrue("network connector mbean registered within 1 minute", mbeanRegistered.tryAcquire(60, TimeUnit.SECONDS)); + + // force an inactivity timeout via the proxy proxy.pause(); - // wait for the inactivity timeout - Thread.sleep(6000); - + // wait for the inactivity timeout and network shutdown + assertTrue("network connector mbean unregistered within 1 minute", mbeanUnregistered.tryAcquire(60, TimeUnit.SECONDS)); + // let a reconnect succeed proxy.goOn(); }