[asterisk-scf-commits] asterisk-scf/integration/routing.git branch "basecomponent" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Jul 19 10:01:36 CDT 2011


branch "basecomponent" has been updated
       via  4400ee5984d48652fbd844d8be6f59bfd35c2bab (commit)
      from  40a8238688841e9546f3b431f60533361db44e34 (commit)

Summary of changes:
 config/routingtest.conf         |    7 ++++---
 src/Component.cpp               |   39 +++++++++++++++------------------------
 src/RoutingReplicationContext.h |    5 +++--
 test/TestRouting.cpp            |   35 ++---------------------------------
 4 files changed, 24 insertions(+), 62 deletions(-)


- Log -----------------------------------------------------------------
commit 4400ee5984d48652fbd844d8be6f59bfd35c2bab
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue Jul 19 10:01:09 2011 -0500

    Updates for changes to the Component class.

diff --git a/config/routingtest.conf b/config/routingtest.conf
index fd4bfde..0c503c9 100644
--- a/config/routingtest.conf
+++ b/config/routingtest.conf
@@ -83,10 +83,11 @@ BackupLocatorRegistry.Proxy=RoutingServiceLocatorRegistry:tcp -p 10052
 SessionRouter.Proxy=SessionRouter:tcp -p 10050
 BackupSessionRouter.Proxy=SessionRouter:tcp -p 10052
 
-Replica.Proxy=BasicRoutingServiceReplica:tcp -p 10051
-BackupReplica.Proxy=BasicRoutingServiceReplica:tcp -p 10053
+Replica.Proxy=Replica:tcp -p 10051
+BackupReplica.Proxy=Replica:tcp -p 10053
 
-RoutingComponent.Proxy=BasicRoutingComponent:tcp -p 10051
+# Proxy to the Component Service inteface
+RoutingComponent.Proxy=ComponentService:tcp -p 10051
 
 TestRoutingAdapterIn.ThreadPool.Size=8
 TestRoutingAdapterIn.ThreadPool.SizeMax=14
diff --git a/src/Component.cpp b/src/Component.cpp
index f672ecf..5f1b88c 100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@ -65,7 +65,7 @@ class Component : public AsteriskSCF::Component::Component
 public:
     Component() 
         : AsteriskSCF::Component::Component(lg, 
-                                      "BasicRoutingService"),
+                                      ComponentServiceDiscoveryCategory),
           mSessionContext(new SessionContext()),
           mWorkQueue( new AsteriskSCF::Threading::SimpleWorkQueue("SessionRouterWorkQueue")),
           mListeningToReplicator(false)
@@ -75,7 +75,7 @@ public:
 private:
     // Required base Component overrides
     virtual void createPrimaryServices();
-    virtual void registerPrimaryServices();
+    virtual void preparePrimaryServicesForDiscovery();
     virtual void createReplicationStateListeners();
     virtual void stopListeningToStateReplicators();
     virtual void listenToStateReplicators();
@@ -149,12 +149,9 @@ void Component::listenToStateReplicators()
     try
     {
         // Are we in standby mode?
-        if (routingReplicationContext->getState() == ACTIVE_IN_REPLICA_GROUP)
+        if (routingReplicationContext->getState() == STANDBY_IN_REPLICA_GROUP)
         {
-            AsteriskSCF::BasicRoutingService::V1::RoutingStateReplicatorPrx oneWayStateReplicator = 
-                 RoutingStateReplicatorPrx::uncheckedCast(routingReplicationContext->getReplicator()->ice_oneway());
-
-            oneWayStateReplicator->addListener(mReplicatorListenerProxy);
+            routingReplicationContext->getReplicator().tryOneWay()->addListener(mReplicatorListenerProxy);
             mListeningToReplicator = true;
         }
     }
@@ -183,11 +180,7 @@ void Component::stopListeningToStateReplicators()
 
     try
     {
-        AsteriskSCF::BasicRoutingService::V1::RoutingStateReplicatorPrx oneWayStateReplicator = 
-                AsteriskSCF::BasicRoutingService::V1::RoutingStateReplicatorPrx::uncheckedCast(
-                   routingReplicationContext->getReplicator()->ice_oneway());
-
-        oneWayStateReplicator->removeListener(mReplicatorListenerProxy);
+        routingReplicationContext->getReplicator().tryOneWay()->removeListener(mReplicatorListenerProxy);
         mListeningToReplicator = false;
     }
     catch (const Ice::Exception& e)
@@ -198,39 +191,38 @@ void Component::stopListeningToStateReplicators()
 }
 
 /**
- * Register this component's primary public interfaces with the Service Locator.
+ * Prepare this component's public interfaces for discovery via the Service Locator.
  * This enables other Asterisk SCF components to locate the interfaces we are publishing.
- *
  */
-void Component::registerPrimaryServices()
+void Component::preparePrimaryServicesForDiscovery()
 {
     try
     {
         std::string serviceName = getCommunicator()->getProperties()->getPropertyWithDefault(
             getName() + ".Service", "default");
 
-        // Register our RoutingAdmin interface with the Service Locator.
+        // Wrap our RoutingAdmin interface for the Service Locator.
         mAdminRegistration = wrapServiceForRegistration(mAdminPrx, 
                                                         RoutingServiceAdminDiscoveryCategory, 
                                                         serviceName, 
                                                         getName());
-        bool registered =  managePrimaryService(mAdminRegistration);
+        managePrimaryService(mAdminRegistration);
 
 
-        // Register our RegistryLocator interface with the Service Locator.
+        // Wrap our RegistryLocator interface for the Service Locator.
         mRegistryLocatorRegistration = wrapServiceForRegistration(mEndpointRegistryPrx,
                                                                   RoutingServiceLocatorRegistryDiscoveryCategory,
                                                                   serviceName,
                                                                   getName());
-        registered =  managePrimaryService(mRegistryLocatorRegistration);
+        managePrimaryService(mRegistryLocatorRegistration);
                       
 
-        // Register the SessionRouter interface with the Service Locator.
+        // Wrap the SessionRouter interface for the Service Locator.
         mSessionRouterRegistration = wrapServiceForRegistration(mSessionRouterPrx,
                                                                 SessionRouterDiscoveryCategory,
                                                                 serviceName,
                                                                 getName());
-        registered = managePrimaryService(mSessionRouterRegistration);
+        managePrimaryService(mSessionRouterRegistration);
     }
     catch(const std::exception& e)
     {
@@ -300,7 +292,7 @@ void Component::locateStateReplicator()
  */
 ReplicationContextPtr Component::createReplicationContext(ReplicationStateType state)
 {
-    RoutingReplicationContextPtr context(new RoutingReplicationContext(state));
+    RoutingReplicationContextPtr context(new RoutingReplicationContext(state, getTestContext()));
     return context;
 }
 
@@ -355,9 +347,8 @@ void Component::createReplicationStateListeners()
     {
         // Create and publish our state replicator listener interface on the backplane adapter. 
         mReplicatorListener = new RoutingStateReplicatorListenerImpl(mEndpointRegistry, mOperationReplicaCache);
-        RoutingStateReplicatorListenerPrx replicatorListener = 
+        mReplicatorListenerProxy = 
             RoutingStateReplicatorListenerPrx::uncheckedCast(getBackplaneAdapter()->addWithUUID(mReplicatorListener));
-        mReplicatorListenerProxy = RoutingStateReplicatorListenerPrx::uncheckedCast(replicatorListener->ice_oneway());
     }
     catch(const Ice::Exception &e)
     {
diff --git a/src/RoutingReplicationContext.h b/src/RoutingReplicationContext.h
index 50c010e..bc12b95 100644
--- a/src/RoutingReplicationContext.h
+++ b/src/RoutingReplicationContext.h
@@ -35,8 +35,9 @@ typedef AsteriskSCF::Discovery::SmartProxy<AsteriskSCF::BasicRoutingService::V1:
 class RoutingReplicationContext : public AsteriskSCF::Replication::ReplicationContext
 {
 public:
-    RoutingReplicationContext(AsteriskSCF::Replication::ReplicationStateType state) : 
-        AsteriskSCF::Replication::ReplicationContext(state)
+    RoutingReplicationContext(AsteriskSCF::Replication::ReplicationStateType state,  const AsteriskSCF::Component::TestContextPtr& testContext) : 
+        AsteriskSCF::Replication::ReplicationContext(state),
+        mTestContext(testContext)
     {
     }
 
diff --git a/test/TestRouting.cpp b/test/TestRouting.cpp
index ab3252c..14398ac 100644
--- a/test/TestRouting.cpp
+++ b/test/TestRouting.cpp
@@ -247,6 +247,8 @@ public:
         {
             PopulateEndpoints();
 
+            SharedTestData::instance.componentTest->clearTestModes();
+
             SharedTestData::instance.locatorRegistry->addEndpointLocator("TestChannel", SharedTestData::instance.regExIds, SharedTestData::instance.endpointLocatorPrx);
         }
         catch (...)
@@ -604,39 +606,6 @@ BOOST_FIXTURE_TEST_CASE(ChangeLocatorIds, PerTestFixture)
 
 /**
  * See if we can do a lookup of the endpoint locator on the backup
- * service while it is still in standby mode. 
- * There's nothing to prevent this from working, although in practice, 
- * we'd expect other components to not have a proxy to the backup component's interfaces. 
- */
-BOOST_FIXTURE_TEST_CASE(BackupEndpointLocatorInStandby, PerTestFixture)
-{
-    try
-    {
-        // Give the state replicator time to push the EndpointLocator to the standby component. 
-        // (The EndpointLocator is added by the PerTestFixture)
-        IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500));
-
-        // Do a lookup on the backup while it is in standby mode. 
-        // There's nothing to prevent this from working, although in practice, 
-        // we'd expect other components to not have a proxy to the backup component's interfaces. 
-        BOOST_TEST_MESSAGE("Looking up endpoint via the Backup Routing Service...");
-        string lookupVal = "101";
-
-        AsteriskSCF::Core::Endpoint::V1::EndpointSeq seq = SharedTestData::instance.backupLocatorRegistry->lookup(lookupVal);
-
-        BOOST_CHECK(seq.size() > 0);
-        BOOST_CHECK(seq[0]->getId() == lookupVal);
-    }
-    catch(const std::exception &e)
-    {
-        string msg = "Exception looking up endpoint via Backup Service Locator: ";
-        msg += e.what();
-        BOOST_FAIL(msg);
-    }
-}
-
-/**
- * See if we can do a lookup of the endpoint locator on the backup
  * after it's activated.
  */
 BOOST_FIXTURE_TEST_CASE(BackupEndpointLocatorActive, PerTestFixture)

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


-- 
asterisk-scf/integration/routing.git



More information about the asterisk-scf-commits mailing list