[asterisk-scf-commits] asterisk-scf/integration/routing.git branch "locate-with-id" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Jun 28 20:48:57 CDT 2011


branch "locate-with-id" has been updated
       via  3d8eaca0fafaf8ba7d069ca216abc9eeaf11a973 (commit)
      from  b4368b30cb08c8cbfbf38238eef109df45f47b0e (commit)

Summary of changes:
 local-slice/BasicRoutingStateReplicationIf.ice |    7 +---
 src/BasicRoutingServiceApp.cpp                 |   38 +++++++++++++++-------
 src/BasicRoutingStateReplicatorApp.cpp         |   41 +++++++-----------------
 test/CMakeLists.txt                            |    2 +-
 test/TestRouting.cpp                           |   12 ++++++-
 5 files changed, 50 insertions(+), 50 deletions(-)


- Log -----------------------------------------------------------------
commit 3d8eaca0fafaf8ba7d069ca216abc9eeaf11a973
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue Jun 28 20:48:29 2011 -0500

    Mods for changes to ServiceLocatorParams.

diff --git a/local-slice/BasicRoutingStateReplicationIf.ice b/local-slice/BasicRoutingStateReplicationIf.ice
index 4ea55c1..ed464f4 100644
--- a/local-slice/BasicRoutingStateReplicationIf.ice
+++ b/local-slice/BasicRoutingStateReplicationIf.ice
@@ -30,11 +30,6 @@ module V1
     const string StateReplicatorComponentCategory = "RoutingStateReplicatorComponent";
     const string StateReplicatorDiscoveryCategory = "RoutingStateReplicator";
 
-    unsliceable class RoutingStateReplicatorParams extends AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams
-    {
-       string name;
-    };
-
     ///////////////////////////////////////////////////////////////////////
     // These classes and interfaces implement the replication 
     // pattern of Asterisk SCF.
@@ -184,5 +179,5 @@ module V1
     };
 
 }; //module V1
-}; //module BasicRouting
+}; //module V1
 }; //module Asterisk SCF
diff --git a/src/BasicRoutingServiceApp.cpp b/src/BasicRoutingServiceApp.cpp
index 69e23b4..e5c336f 100644
--- a/src/BasicRoutingServiceApp.cpp
+++ b/src/BasicRoutingServiceApp.cpp
@@ -403,11 +403,16 @@ void BasicRoutingServiceApp::stopListeningToStateReplicator()
  * Helper function to add some parameters to one of our registered interfaces in the ServiceLocator, so that
  * other components can look up our interfaces.
  */
-void setCategory(const AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx& serviceManagement, const string& category)
+void setCategory(const AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx& serviceManagement, 
+                 const string& category,
+                 const string& service,
+                 const string& id = "")
 {
     // Add category as a parameter to enable other components look this component up.
     ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams;
     genericparams->category = category;
+    genericparams->service = service;
+    genericparams->id = id;
     serviceManagement->addLocatorParams(genericparams, "");
 }
 
@@ -422,20 +427,23 @@ void BasicRoutingServiceApp::registerWithServiceLocator(bool includeBackplaneSer
 {
     try
     {
+       std::string serviceName = mCommunicator->getProperties()->getPropertyWithDefault(
+          mAppName + ".Service", "default");
+
         // Register our RoutingAdmin interface with the Service Locator.
         string adminServiceGuid(mImplementationId + "." + Routing::V1::RoutingServiceAdminDiscoveryCategory); // Should be unique for reporting.
         mAdminManagement = mServiceLocatorManagement->addService(mAdminPrx, adminServiceGuid);
-        setCategory(mAdminManagement, Routing::V1::RoutingServiceAdminDiscoveryCategory);
+        setCategory(mAdminManagement, Routing::V1::RoutingServiceAdminDiscoveryCategory, serviceName);
 
         // Register our RegistryLocator interface with the Service Locator.
         string locatorServiceGuid(mImplementationId + "." + Routing::V1::RoutingServiceLocatorRegistryDiscoveryCategory);  // Should be unique for reporting.
         mRegistryLocatorManagement = mServiceLocatorManagement->addService(mEndpointRegistryPrx, locatorServiceGuid);
-        setCategory(mRegistryLocatorManagement, Routing::V1::RoutingServiceLocatorRegistryDiscoveryCategory);
+        setCategory(mRegistryLocatorManagement, Routing::V1::RoutingServiceLocatorRegistryDiscoveryCategory, serviceName);
 
         // Register the SessionRouter interface with the Service Locator.
         string sessionRouterGuid(mImplementationId + "." + Routing::V1::SessionRouterDiscoveryCategory);   // Should be unique
         mSessionRouterManagement = mServiceLocatorManagement->addService(mSessionRouterPrx, sessionRouterGuid);
-        setCategory(mSessionRouterManagement, Routing::V1::SessionRouterDiscoveryCategory);
+        setCategory(mSessionRouterManagement, Routing::V1::SessionRouterDiscoveryCategory, serviceName);
 
         if (includeBackplaneServices)
         {
@@ -443,7 +451,7 @@ void BasicRoutingServiceApp::registerWithServiceLocator(bool includeBackplaneSer
             // Note that this interface goes on the management adapter.
             string componentServiceGuid(mImplementationId + "." + Routing::V1::ComponentServiceDiscoveryCategory);   // Should be unique for reporting.
             mComponentServiceManagement = mServiceLocatorManagement->addService(mComponentServicePrx, componentServiceGuid);
-            setCategory(mComponentServiceManagement, ComponentServiceId); // This really needs a custom comparator.
+            setCategory(mComponentServiceManagement, ComponentServiceId, serviceName, mImplementationId); 
 
             if (mPublishTestInterface)
             {
@@ -455,9 +463,8 @@ void BasicRoutingServiceApp::registerWithServiceLocator(bool includeBackplaneSer
             }
 
             // Register the Replica interface with the Service Locator.
-            string replicaServiceGuid(mImplementationId + "." + "ReplicaControl");   // Should be unique for reporting.
-            mReplicaManagement = mServiceLocatorManagement->addService(mReplicaPrx, replicaServiceGuid);
-            setCategory(mReplicaManagement, ReplicaServiceId);  // This really needs a custom comparator.
+            mReplicaManagement = mServiceLocatorManagement->addService(mReplicaPrx, mImplementationId + ".Replica");
+            setCategory(mReplicaManagement, ReplicaServiceId, serviceName, mImplementationId + ".Replica");  
         }
     }
     catch(const std::exception& e)
@@ -558,9 +565,12 @@ void BasicRoutingServiceApp::locateBridgeManager()
 {
     try
     {
+       std::string serviceName = mCommunicator->getProperties()->getPropertyWithDefault(
+          mAppName + ".BridgeServiceName", "default");
+
         mBridgeManager = AsteriskSCF::Discovery::SmartProxy<BridgeManagerPrx>(
             mServiceLocator,
-            new ServiceLocatorParams(BridgeServiceDiscoveryCategory, ""),
+            new ServiceLocatorParams(BridgeServiceDiscoveryCategory, serviceName, ""),
             lg);
     }
     catch(const AsteriskSCF::Core::Discovery::V1::ServiceNotFound&)
@@ -576,9 +586,13 @@ void BasicRoutingServiceApp::locateBridgeManager()
  */
 void BasicRoutingServiceApp::locateStateReplicator()
 {
-    BasicRoutingService::V1::RoutingStateReplicatorParamsPtr replicatorParams = new BasicRoutingService::V1::RoutingStateReplicatorParams();
-    replicatorParams->category = BasicRoutingService::V1::StateReplicatorDiscoveryCategory;
-    replicatorParams->name = mCommunicator->getProperties()->getPropertyWithDefault(mAppName + ".StateReplicatorName", "default");
+    std::string serviceName = mCommunicator->getProperties()->getPropertyWithDefault(
+          mAppName + ".ReplicatorServiceName", "default");
+
+    ServiceLocatorParamsPtr replicatorParams = new ServiceLocatorParams;
+    replicatorParams->category = BasicRoutingService::V1::StateReplicatorDiscoveryCategory;    
+    replicatorParams->service = serviceName;
+    replicatorParams->id = mCommunicator->getProperties()->getPropertyWithDefault(mAppName + ".StateReplicatorName", "default");
 
     try
     {
diff --git a/src/BasicRoutingStateReplicatorApp.cpp b/src/BasicRoutingStateReplicatorApp.cpp
index 22fdab0..15809fc 100644
--- a/src/BasicRoutingStateReplicatorApp.cpp
+++ b/src/BasicRoutingStateReplicatorApp.cpp
@@ -125,34 +125,21 @@ private:
     BasicRoutingStateReplicatorServicePtr mService;
 };
 
-class BasicRoutingStateReplicatorCompare : public ServiceLocatorParamsCompare
-{
-public:
-    BasicRoutingStateReplicatorCompare(const std::string& name) : mName(name) {}
-    bool isSupported(const ServiceLocatorParamsPtr &params, const Ice::Current &)
-    {
-        RoutingStateReplicatorParamsPtr routingParams = RoutingStateReplicatorParamsPtr::dynamicCast(params);
-        if (routingParams->name == mName)
-        {
-            return true;
-        }
-        return false;
-    }
-private:
-    string mName;
-};
-
-typedef IceUtil::Handle<BasicRoutingStateReplicatorCompare> BasicRoutingStateReplicatorComparePtr;
-
 /**
  * Helper function to add some parameters to one of our registered interfaces in the ServiceLocator, so that
  * other components can look up our interfaces.
  */
-void setCategory(const Discovery::V1::ServiceManagementPrx& serviceManagement, const string& category)
+void setCategory(const Discovery::V1::ServiceManagementPrx& serviceManagement, 
+                 const string& category,
+                 const string& serviceName,
+                 const string& id="")
 {
     // Add category as a parameter to enable other components look this component up.
     ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams;
     genericparams->category = category;
+    genericparams->service = serviceName;
+    genericparams->id = id;
+
     serviceManagement->addLocatorParams(genericparams, "");
 }
 
@@ -164,26 +151,22 @@ void BasicRoutingStateReplicatorService::registerWithServiceLocator()
 {
     try
     {
+        std::string serviceName = mCommunicator->getProperties()->getPropertyWithDefault(
+              mAppName + ".ServiceName", "default");
+
         // Add our ComponentService interface and add it to the Service Locator.
         // Note that this interface has its own adapter.
         string componentServiceGuid(AsteriskSCF::BasicRoutingService::V1::StateReplicatorComponentCategory);
         mComponentServiceManagement = mServiceLocatorManagement->addService(mComponentServicePrx, componentServiceGuid);
-        setCategory(mComponentServiceManagement,  AsteriskSCF::BasicRoutingService::V1::StateReplicatorComponentCategory);
+        setCategory(mComponentServiceManagement,  AsteriskSCF::BasicRoutingService::V1::StateReplicatorComponentCategory, serviceName);
 
         // Add our Replicator interface and add it to the Service Locator.
         string stateReplicationGuid(AsteriskSCF::BasicRoutingService::V1::StateReplicatorDiscoveryCategory);
         mStateReplicationManagement = mServiceLocatorManagement->addService(mStateReplicatorPrx, stateReplicationGuid);
 
-        ServiceLocatorParamsPtr discoveryParams = new ServiceLocatorParams();
-        discoveryParams->category = AsteriskSCF::BasicRoutingService::V1::StateReplicatorDiscoveryCategory;
-
         string replicatorName = mCommunicator->getProperties()->getPropertyWithDefault(mAppName + ".InstanceName", "default");
-        ServiceLocatorParamsComparePrx compareProxy = ServiceLocatorParamsComparePrx::uncheckedCast(
-                                                    mServiceAdapter->addWithUUID(new BasicRoutingStateReplicatorCompare(replicatorName)));
 
-        string compareGuid = IceUtil::generateUUID();
-        mServiceLocatorManagement->addCompare(compareGuid, compareProxy);
-        mStateReplicationManagement->addLocatorParams(discoveryParams, compareGuid);
+        setCategory(mStateReplicationManagement, AsteriskSCF::BasicRoutingService::V1::StateReplicatorDiscoveryCategory, serviceName, replicatorName);
     }
     catch(...)
     {
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 9eaa29e..3ba5a37 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -18,4 +18,4 @@ asterisk_scf_component_add_ice_libraries(RoutingTest IceStorm)
 asterisk_scf_component_add_boost_libraries(RoutingTest unit_test_framework)
 asterisk_scf_component_build_icebox(RoutingTest)
 target_link_libraries(RoutingTest asterisk-scf-api)
-asterisk_scf_test_icebox(RoutingTest config/routingtest-integ.config)
+asterisk_scf_test_icebox(RoutingTest config/routingtest.conf) 
diff --git a/test/TestRouting.cpp b/test/TestRouting.cpp
index edc04e3..67f94e2 100644
--- a/test/TestRouting.cpp
+++ b/test/TestRouting.cpp
@@ -198,12 +198,20 @@ struct GlobalIceFixture
 
         SharedTestData::instance.bridgeManager = new MockBridgeManager();
 
-        Ice::ObjectPrx bridgeManagerObject = SharedTestData::instance.adapterIn->add(SharedTestData::instance.bridgeManager, SharedTestData::instance.communicatorIn->stringToIdentity(SharedTestData::instance.communicatorIn->getProperties()->getProperty("BridgeManager.ServiceLocatorId")));
+        Ice::ObjectPrx bridgeManagerObject = SharedTestData::instance.adapterIn->add(
+            SharedTestData::instance.bridgeManager, 
+            SharedTestData::instance.communicatorIn->stringToIdentity(
+               SharedTestData::instance.communicatorIn->getProperties()->getProperty("BridgeManager.ServiceLocatorId")));
         BridgeManagerPrx bridgeManagerPrx = BridgeManagerPrx::checkedCast(bridgeManagerObject);
-        ServiceManagementPrx management = ServiceManagementPrx::uncheckedCast(SharedTestData::instance.serviceLocatorManagement->addService(bridgeManagerPrx, "BridgeService"));
+        ServiceManagementPrx management = ServiceManagementPrx::uncheckedCast(
+            SharedTestData::instance.serviceLocatorManagement->addService(bridgeManagerPrx, "BridgeService"));
 
+
+        std::string serviceName =SharedTestData::instance.communicatorIn->getProperties()->getPropertyWithDefault(
+              "RoutingService.BridgeServiceName", "default");
         ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
         genericparams->category = BridgeServiceDiscoveryCategory;
+        genericparams->service = serviceName;
         management->addLocatorParams(genericparams, "");
     }
 

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


-- 
asterisk-scf/integration/routing.git



More information about the asterisk-scf-commits mailing list