Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 75892 invoked from network); 4 Mar 2009 15:10:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Mar 2009 15:10:46 -0000 Received: (qmail 1566 invoked by uid 500); 4 Mar 2009 15:10:46 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 1541 invoked by uid 500); 4 Mar 2009 15:10:46 -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 1532 invoked by uid 99); 4 Mar 2009 15:10:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Mar 2009 07:10:46 -0800 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; Wed, 04 Mar 2009 15:10:45 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5351A23888A3; Wed, 4 Mar 2009 15:10:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r750042 - in /activemq/activemq-cpp/trunk/src: main/activemq/state/ main/activemq/transport/failover/ test/ test/activemq/transport/failover/ test/activemq/transport/mock/ test/decaf/lang/ Date: Wed, 04 Mar 2009 15:10:24 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090304151025.5351A23888A3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Wed Mar 4 15:10:23 2009 New Revision: 750042 URL: http://svn.apache.org/viewvc?rev=750042&view=rev Log: http://issues.apache.org/activemq/browse/AMQCPP-100 Some additional code needed for Failover. Added a start on a Unit test, and fixed a segfault caused by use of a Static Pointer instance that was causing APR to segfault. Added: activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/ activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/FailoverTransportTest.cpp (with props) activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/FailoverTransportTest.h (with props) Modified: activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.cpp activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.h activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransportFactory.h activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/ReconnectTask.cpp activemq/activemq-cpp/trunk/src/test/Makefile.am activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/MockTransportFactoryTest.cpp activemq/activemq-cpp/trunk/src/test/decaf/lang/PointerTest.cpp activemq/activemq-cpp/trunk/src/test/testRegistry.cpp Modified: activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.cpp?rev=750042&r1=750041&r2=750042&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.cpp (original) +++ activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.cpp Wed Mar 4 15:10:23 2009 @@ -30,7 +30,6 @@ using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// -const Pointer ConnectionStateTracker::TRACKED_RESPONSE_MARKER( new Tracked() ); //////////////////////////////////////////////////////////////////////////////// namespace activemq { @@ -60,7 +59,7 @@ }} //////////////////////////////////////////////////////////////////////////////// -ConnectionStateTracker::ConnectionStateTracker() { +ConnectionStateTracker::ConnectionStateTracker() : TRACKED_RESPONSE_MARKER( new Tracked() ) { this->trackTransactions = false; this->restoreSessions = true; Modified: activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.h?rev=750042&r1=750041&r2=750042&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.h (original) +++ activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.h Wed Mar 4 15:10:23 2009 @@ -42,7 +42,8 @@ class AMQCPP_API ConnectionStateTracker : public CommandVisitorAdapter { private: - static const Pointer TRACKED_RESPONSE_MARKER; + /** Creates a unique marker for this state tracker */ + const Pointer TRACKED_RESPONSE_MARKER; // TODO - Create a Thread Safe impl of Map. decaf::util::StlMap< Pointer, Pointer, Modified: activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransportFactory.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransportFactory.h?rev=750042&r1=750041&r2=750042&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransportFactory.h (original) +++ activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/FailoverTransportFactory.h Wed Mar 4 15:10:23 2009 @@ -41,8 +41,7 @@ class AMQCPP_API FailoverTransportFactory : public AbstractTransportFactory { public: - FailoverTransportFactory(); - virtual ~FailoverTransportFactory(); + virtual ~FailoverTransportFactory() {} /** * Creates a slimed down Transport instance which can be used in composite Modified: activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/ReconnectTask.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/ReconnectTask.cpp?rev=750042&r1=750041&r2=750042&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/ReconnectTask.cpp (original) +++ activemq/activemq-cpp/trunk/src/main/activemq/transport/failover/ReconnectTask.cpp Wed Mar 4 15:10:23 2009 @@ -104,3 +104,44 @@ return result; } + +//////////////////////////////////////////////////////////////////////////////// +void ReconnectTask::run() { + + try { + + while( true ) { + + synchronized( &mutex ) { + pending = false; + if( shutDown ) { + return; + } + } + + if( !this->iterate() ) { + + // wait to be notified. + synchronized( &mutex ) { + if( shutDown ) { + return; + } + while( !pending ) { + mutex.wait(); + } + } + } + + } + } + AMQ_CATCH_NOTHROW( Exception ) + AMQ_CATCHALL_NOTHROW() + + // Make sure we notify any waiting threads that thread + // has terminated. + synchronized( &mutex ) { + threadTerminated = true; + mutex.notifyAll(); + } + +} Modified: activemq/activemq-cpp/trunk/src/test/Makefile.am URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/Makefile.am?rev=750042&r1=750041&r2=750042&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/Makefile.am (original) +++ activemq/activemq-cpp/trunk/src/test/Makefile.am Wed Mar 4 15:10:23 2009 @@ -40,6 +40,7 @@ activemq/transport/IOTransportTest.cpp \ activemq/transport/correlator/ResponseCorrelatorTest.cpp \ activemq/transport/mock/MockTransportFactoryTest.cpp \ + activemq/transport/failover/FailoverTransportTest.cpp \ activemq/util/PrimitiveValueNodeTest.cpp \ activemq/util/PrimitiveListTest.cpp \ activemq/util/PrimitiveMapTest.cpp \ @@ -139,6 +140,7 @@ activemq/transport/IOTransportTest.h \ activemq/transport/correlator/ResponseCorrelatorTest.h \ activemq/transport/mock/MockTransportFactoryTest.h \ + activemq/transport/failover/FailoverTransportTest.h \ activemq/util/PrimitiveValueNodeTest.h \ activemq/util/PrimitiveListTest.h \ activemq/util/PrimitiveMapTest.h \ Added: activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/FailoverTransportTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/FailoverTransportTest.cpp?rev=750042&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/FailoverTransportTest.cpp (added) +++ activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/FailoverTransportTest.cpp Wed Mar 4 15:10:23 2009 @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "FailoverTransportTest.h" + +#include +#include +#include +#include + +using namespace activemq; +using namespace activemq::transport; +using namespace activemq::transport::failover; +using namespace activemq::exceptions; +using namespace decaf::util; + +//////////////////////////////////////////////////////////////////////////////// +FailoverTransportTest::FailoverTransportTest() { +} + +//////////////////////////////////////////////////////////////////////////////// +FailoverTransportTest::~FailoverTransportTest() { +} + +//////////////////////////////////////////////////////////////////////////////// +void FailoverTransportTest::testTransportCreate() { + + std::string uri = "failover://(mock://localhost:61616)?randomize=false"; + + FailoverTransportFactory factory; + + Pointer transport( factory.create( uri ) ); + + CPPUNIT_ASSERT( transport != NULL ); + + FailoverTransport* failover = dynamic_cast( + transport->narrow( typeid( FailoverTransport ) ) ); + + CPPUNIT_ASSERT( failover != NULL ); + CPPUNIT_ASSERT( failover->isRandomize() == false ); + + transport->close(); +} + Propchange: activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/FailoverTransportTest.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/FailoverTransportTest.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/FailoverTransportTest.h?rev=750042&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/FailoverTransportTest.h (added) +++ activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/FailoverTransportTest.h Wed Mar 4 15:10:23 2009 @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _ACTIVEMQ_TRANSPORT_FAILOVER_FAILOVERTRANSPORTTEST_H_ +#define _ACTIVEMQ_TRANSPORT_FAILOVER_FAILOVERTRANSPORTTEST_H_ + +#include +#include +#include + +namespace activemq { +namespace transport { +namespace failover { + + class FailoverTransportTest : public CppUnit::TestFixture { + + CPPUNIT_TEST_SUITE( FailoverTransportTest ); + CPPUNIT_TEST( testTransportCreate ); + CPPUNIT_TEST_SUITE_END(); + + public: + + FailoverTransportTest(); + virtual ~FailoverTransportTest(); + + void testTransportCreate(); + + }; + +}}} + +#endif /*_ACTIVEMQ_TRANSPORT_FAILOVER_FAILOVERTRANSPORTTEST_H_*/ Propchange: activemq/activemq-cpp/trunk/src/test/activemq/transport/failover/FailoverTransportTest.h ------------------------------------------------------------------------------ svn:eol-style = native Modified: activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/MockTransportFactoryTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/MockTransportFactoryTest.cpp?rev=750042&r1=750041&r2=750042&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/MockTransportFactoryTest.cpp (original) +++ activemq/activemq-cpp/trunk/src/test/activemq/transport/mock/MockTransportFactoryTest.cpp Wed Mar 4 15:10:23 2009 @@ -46,4 +46,6 @@ CPPUNIT_ASSERT( transport.get() != NULL ); + transport.reset( NULL ); + } Modified: activemq/activemq-cpp/trunk/src/test/decaf/lang/PointerTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/decaf/lang/PointerTest.cpp?rev=750042&r1=750041&r2=750042&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/decaf/lang/PointerTest.cpp (original) +++ activemq/activemq-cpp/trunk/src/test/decaf/lang/PointerTest.cpp Wed Mar 4 15:10:23 2009 @@ -125,7 +125,6 @@ Pointer ex( new ExceptionThrowingClass() ); CPPUNIT_FAIL( "Should Have Thrown." ); } catch(...) {} - } //////////////////////////////////////////////////////////////////////////////// Modified: activemq/activemq-cpp/trunk/src/test/testRegistry.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/testRegistry.cpp?rev=750042&r1=750041&r2=750042&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/testRegistry.cpp (original) +++ activemq/activemq-cpp/trunk/src/test/testRegistry.cpp Wed Mar 4 15:10:23 2009 @@ -18,28 +18,28 @@ // All CPP Unit tests are registered in here so we can disable them and // enable them easily in one place. -#include -CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::BrokerInfoTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::BrokerIdTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQTopicTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQTextMessageTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQTempTopicTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQTempQueueTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQQueueTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQMessageTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQMapMessageTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQDestinationTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQBytesMessageTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::BrokerInfoTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::BrokerIdTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQTopicTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQTextMessageTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQTempTopicTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQTempQueueTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQQueueTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQMessageTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQMapMessageTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQDestinationTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::commands::ActiveMQBytesMessageTest ); // //#include //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::wireformat::openwire::marshal::BaseDataStreamMarshallerTest ); @@ -68,14 +68,17 @@ //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::cmsutil::DynamicDestinationResolverTest ); //#include //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::cmsutil::SessionPoolTest ); +// +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::core::ActiveMQConnectionFactoryTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::core::ActiveMQConnectionTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::core::ActiveMQSessionTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( activemq::core::ActiveMQConnectionFactoryTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( activemq::core::ActiveMQConnectionTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( activemq::core::ActiveMQSessionTest ); - +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::failover::FailoverTransportTest ); +// //#include //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::correlator::ResponseCorrelatorTest ); // @@ -86,10 +89,10 @@ //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::TransportRegistryTest ); //#include //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::IOTransportTest ); - -#include -CPPUNIT_TEST_SUITE_REGISTRATION( activemq::exceptions::ActiveMQExceptionTest ); - +// +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::exceptions::ActiveMQExceptionTest ); +// //#include //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::LongSequenceGeneratorTest ); //#include @@ -178,13 +181,13 @@ //CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::SystemTest ); #include CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::PointerTest ); -// + //#include //CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::SocketFactoryTest ); //#include //CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::SocketTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::URITest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::URITest ); //#include //CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::URISyntaxExceptionTest ); //#include @@ -192,8 +195,8 @@ //#include //CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::URLDecoderTest ); // -#include -CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::concurrent::ConcurrentStlMapTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::concurrent::ConcurrentStlMapTest ); //#include //CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::concurrent::CountDownLatchTest ); //#include @@ -214,15 +217,15 @@ //CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::DateTest ); //#include //CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::UUIDTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::ListTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::StlMapTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::QueueTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::ListTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::StlMapTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::QueueTest ); //#include //CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::RandomTest ); -#include -CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::SetTest ); +//#include +//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::SetTest ); //#include //CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::StringTokenizerTest );