[asterisk-scf-commits] asterisk-scf/integration/media_rtp_pjmedia.git branch "retry_deux" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Apr 30 18:30:49 CDT 2012


branch "retry_deux" has been updated
       via  2b61f1f7caa988753eb8847671ab0527b844eb83 (commit)
      from  62a6b9f75cc1ce2ac25923e6c67b0b1fcb18eca1 (commit)

Summary of changes:
 config/.test_component.conf.swp    |  Bin 0 -> 12288 bytes
 config/test_component.conf         |    3 +++
 config/test_component_v6.conf      |    3 +++
 config/test_rtp_ice.conf           |   10 +++++++---
 src/Component.cpp                  |   12 ++++++++++++
 src/RTPStateReplicatorListener.cpp |   13 +++++++++----
 test/TestRTPICE.cpp                |   30 ++++++++++++++++++++++++++++++
 test/TestRTPpjmedia.cpp            |   22 +++++++++++++++++++++-
 8 files changed, 85 insertions(+), 8 deletions(-)
 create mode 100644 config/.test_component.conf.swp


- Log -----------------------------------------------------------------
commit 2b61f1f7caa988753eb8847671ab0527b844eb83
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Mon Apr 30 18:30:19 2012 -0500

    Some fixes for the media component to allow starting up in standy mode. Also
    updates to the tests, including activating the component.

diff --git a/config/.test_component.conf.swp b/config/.test_component.conf.swp
new file mode 100644
index 0000000..61f276e
Binary files /dev/null and b/config/.test_component.conf.swp differ
diff --git a/config/test_component.conf b/config/test_component.conf
index 8b7b63b..c6fe6db 100644
--- a/config/test_component.conf
+++ b/config/test_component.conf
@@ -15,6 +15,9 @@ Ice.Override.Timeout=5000
 
 IceBox.Service.ServiceDiscovery=ServiceLocator:create
 
+# For unit test we run without state replication.
+ServiceDiscovery.Standalone = true
+
 ServiceDiscovery.IceStorm.InstanceName=ServiceDiscovery
 
 ServiceDiscovery.IceStorm.TopicManager.Endpoints=tcp -h 127.0.0.1 -p 4421
diff --git a/config/test_component_v6.conf b/config/test_component_v6.conf
index 6c991c6..1b4655f 100644
--- a/config/test_component_v6.conf
+++ b/config/test_component_v6.conf
@@ -15,6 +15,9 @@ Ice.Override.Timeout=5000
 
 IceBox.Service.ServiceDiscovery=ServiceLocator:create
 
+# For unit test we run without state replication.
+ServiceDiscovery.Standalone=true
+
 ServiceDiscovery.IceStorm.InstanceName=ServiceDiscovery
 
 ServiceDiscovery.IceStorm.TopicManager.Endpoints=tcp -h 127.0.0.1 -p 4421
diff --git a/config/test_rtp_ice.conf b/config/test_rtp_ice.conf
index 4edbeca..6984eec 100644
--- a/config/test_rtp_ice.conf
+++ b/config/test_rtp_ice.conf
@@ -24,10 +24,11 @@ LocatorService.Proxy=LocatorService:tcp -h 127.0.0.1 -p 4411
 
 IceBox.Service.MediaRTPpjmedia=MediaRTPPJMEDIA:create
 
+MediaRTPpjmedia.ServiceName=test
+
 # Adapter parameters for this component
-MediaRTPpjmediaAdapter.Endpoints=default -h 127.0.0.1
-MediaRTPpjmediaAdapterLocal.Endpoints=default -h 127.0.0.1
-MediaRTPpjmediaAdapterLogger.Endpoints=default -h 127.0.0.1
+MediaRTPpjmedia.ServiceAdapter.Endpoints=default -h 127.0.0.1 -p 4471
+MediaRTPpjmedia.BackplaneAdapter.Endpoints=default -h 127.0.0.1 -p 4472
 
 # A proxy to the service locator management service
 ServiceLocatorManagementProxy=LocatorServiceManagement:tcp -h 127.0.0.1 -p 4422
@@ -47,6 +48,9 @@ IceBox.Service.MediaRTPpjmediaTest=MediaRTPPJMEDIAIceTest:create
 
 IceBox.Service.ServiceDiscovery=ServiceLocator:create
 
+# For unit test we run without state replication.
+ServiceDiscovery.Standalone = true
+
 ServiceDiscovery.IceStorm.InstanceName=ServiceDiscovery
 
 ServiceDiscovery.IceStorm.TopicManager.Endpoints=tcp -h 127.0.0.1 -p 4421
diff --git a/src/Component.cpp b/src/Component.cpp
index 55bb668..e1956dc 100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@ -211,6 +211,7 @@ private:
     virtual void onPreInitialize();
     virtual void onStop();
     virtual void onStart();
+    virtual void onActivated();
 
     // Other base Component overrides
     virtual void prepareBackplaneServicesForDiscovery();
@@ -571,6 +572,17 @@ void Component::onRegisterPrimaryServices()
         mRTPOverIceLocatorParams, getName() + ".RTP.Comparator");
 }
 
+void Component::onActivated()
+{
+    RTPReplicationContextPtr rtpReplicationContext =
+        boost::static_pointer_cast<RTPReplicationContext>(getReplicationContext());
+
+    RTPStateItemSeq items;
+    items.push_back(mGeneralState);
+    RTPStateReplicatorPrx oneway = RTPStateReplicatorPrx::uncheckedCast(rtpReplicationContext->getReplicator()->ice_oneway());
+    oneway->setState(AsteriskSCF::Operations::createContext(), items);
+}
+
 void Component::onStart()
 {
     if (getReplicationContext()->isReplicating() == true)
diff --git a/src/RTPStateReplicatorListener.cpp b/src/RTPStateReplicatorListener.cpp
index 4b5de4b..6b8f14a 100644
--- a/src/RTPStateReplicatorListener.cpp
+++ b/src/RTPStateReplicatorListener.cpp
@@ -22,6 +22,7 @@
 
 #include <AsteriskSCF/System/Component/ReplicaIf.h>
 #include <AsteriskSCF/Operations/OperationContextCache.h>
+#include <AsteriskSCF/Logger.h>
 
 #include "RTPStateReplicator.h"
 #include "ReplicationAdapter.h"
@@ -31,8 +32,14 @@ using namespace AsteriskSCF::Media::RTP::V1;
 using namespace AsteriskSCF::Operations;
 using namespace AsteriskSCF::PJMEDIARTP;
 using namespace AsteriskSCF::Replication::MediaRTPPJMEDIA::V1;
+using namespace AsteriskSCF::System::Logging;
 using namespace std;
 
+namespace
+{
+Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaRTP");
+}
+
 class RTPStateReplicatorItem
 {
 public:
@@ -132,11 +139,9 @@ public:
                             AsteriskSCF::PJMEDIARTP::RTPSession::create(mImpl->mAdapter, mImpl->mEnvironment, item,
                                 mImpl->mReplicationContext, mImpl->mConfigurationService, item->options, outputs));
                     }
-                    catch (const std::exception&)
+                    catch (const std::exception& e)
                     {
-                        //
-                        // TODO: logging would not go awry here.
-                        //
+                        lg(Error) << "Exception in " << BOOST_CURRENT_FUNCTION <<  " : " << e.what();
                         assert(false);
                         return;
                     }
diff --git a/test/TestRTPICE.cpp b/test/TestRTPICE.cpp
index 35984c4..45aae7b 100644
--- a/test/TestRTPICE.cpp
+++ b/test/TestRTPICE.cpp
@@ -34,6 +34,7 @@
 #include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
 #include <AsteriskSCF/Media/MediaIf.h>
 #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
+#include <AsteriskSCF/System/Component/ReplicaIf.h>
 
 //
 // An attempt to get some reasonable code coverage and verify that the basic *premise* of the functionality works as
@@ -49,6 +50,8 @@ using namespace AsteriskSCF::Media::RTP::V1;
 using namespace AsteriskSCF::System::Configuration::V1;
 using namespace AsteriskSCF::Replication::MediaRTPPJMEDIA::V1;
 using namespace AsteriskSCF::Configuration::MediaRTPPJMEDIA::V1;
+using namespace AsteriskSCF::System::Component::V1;
+using namespace AsteriskSCF::Core::Discovery::V1;
 
 namespace
 {
@@ -115,6 +118,33 @@ public:
         BOOST_TEST_MESSAGE("Creating test fixture");
         ::boost::debug::detect_memory_leaks(false);
         ::boost::unit_test::unit_test_log.set_stream(cout);
+
+        IceEnvironment iceEnv;
+
+        ServiceLocatorPrx locator = ServiceLocatorPrx::checkedCast(iceEnv.getCommunicator()->stringToProxy("LocatorService:tcp -h 127.0.0.1 -p 4411"));
+
+        if (!locator) 
+        {
+            throw "Invalid service locator proxy";
+        }
+
+        ServiceLocatorParamsPtr primaryReplicaParams(new ServiceLocatorParams);
+        primaryReplicaParams->category = "MediaRTPService.Replica";
+        primaryReplicaParams->service = "test";
+        primaryReplicaParams->id = "MediaRTPpjmedia";
+
+        ReplicaPrx mPrimaryReplica;
+        try
+        {
+            mPrimaryReplica = ReplicaPrx::uncheckedCast(locator->locate(primaryReplicaParams));
+        }
+        catch(const AsteriskSCF::Core::Discovery::V1::ServiceNotFound&)
+        {
+            throw;
+        }
+
+        mPrimaryReplica->activate(AsteriskSCF::Operations::createContext());
+
     }
 
     ~TestFixture()
diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index 7894031..6419848 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -37,6 +37,7 @@
 #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
 #include <AsteriskSCF/Media/RTP/MediaRTCPIf.h>
 #include <AsteriskSCF/Operations/OperationContext.h>
+#include <AsteriskSCF/System/Component/ReplicaIf.h>
 
 #include "RTPStateReplicationIf.h"
 #include "TestRTPpjmediaIf.h"
@@ -48,6 +49,7 @@ using namespace AsteriskSCF::Media;
 using namespace AsteriskSCF::Operations;
 using namespace AsteriskSCF::Replication::MediaRTPPJMEDIA::V1;
 using namespace AsteriskSCF::System::V1;
+using namespace AsteriskSCF::System::Component::V1;
 using namespace std;
 
 /**
@@ -332,9 +334,27 @@ struct GlobalIceFixture
 
             Testbed.locator = ServiceLocatorPrx::checkedCast(Testbed.communicator->stringToProxy("LocatorService:tcp -h 127.0.0.1 -p 4411"));
 
-            if (!Testbed.locator) {
+            if (!Testbed.locator) 
+            {
                 throw "Invalid service locator proxy";
             }
+
+            ServiceLocatorParamsPtr primaryReplicaParams(new ServiceLocatorParams);
+            primaryReplicaParams->category = "MediaRTPService.Replica";
+            primaryReplicaParams->service = "test";
+            primaryReplicaParams->id = "MediaServiceRTP";
+
+            ReplicaPrx mPrimaryReplica;
+            try
+            {
+                mPrimaryReplica = ReplicaPrx::uncheckedCast(Testbed.locator->locate(primaryReplicaParams));
+            }
+            catch(const AsteriskSCF::Core::Discovery::V1::ServiceNotFound&)
+            {
+                throw;
+            }
+
+            mPrimaryReplica->activate(AsteriskSCF::Operations::createContext());
         }
         catch (const Ice::Exception& ex)
         {

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list