[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
Fri Jul 15 17:42:34 CDT 2011


branch "basecomponent" has been updated
       via  40a8238688841e9546f3b431f60533361db44e34 (commit)
      from  1fc7ab7d9ac7ceb14de49f1f9c19b8d74d68286b (commit)

Summary of changes:
 src/CMakeLists.txt                                |    2 +-
 src/{BasicRoutingServiceApp.cpp => Component.cpp} |  116 ++++++++-------------
 src/RoutingReplicationContext.cpp                 |  111 --------------------
 src/RoutingReplicationContext.h                   |    1 +
 4 files changed, 46 insertions(+), 184 deletions(-)
 rename src/{BasicRoutingServiceApp.cpp => Component.cpp} (75%)
 delete mode 100644 src/RoutingReplicationContext.cpp


- Log -----------------------------------------------------------------
commit 40a8238688841e9546f3b431f60533361db44e34
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Fri Jul 15 17:42:35 2011 -0500

    Changes for consistency among components.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2a1c1af..fc86a54 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -10,7 +10,7 @@ asterisk_scf_slice_include_directories(${API_SLICE_DIR})
 
 asterisk_scf_component_init(BasicRoutingService)
 asterisk_scf_component_add_slice(BasicRoutingService ../local-slice/BasicRoutingStateReplicationIf.ice)
-asterisk_scf_component_add_file(BasicRoutingService BasicRoutingServiceApp.cpp)
+asterisk_scf_component_add_file(BasicRoutingService Component.cpp)
 asterisk_scf_component_add_file(BasicRoutingService SessionRouter.cpp)
 asterisk_scf_component_add_file(BasicRoutingService SessionRouter.h)
 asterisk_scf_component_add_file(BasicRoutingService RoutingAdmin.cpp)
diff --git a/src/BasicRoutingServiceApp.cpp b/src/Component.cpp
similarity index 75%
rename from src/BasicRoutingServiceApp.cpp
rename to src/Component.cpp
index 9ccfef2..f672ecf 100644
--- a/src/BasicRoutingServiceApp.cpp
+++ b/src/Component.cpp
@@ -21,9 +21,7 @@
 
 #include <AsteriskSCF/Discovery/SmartProxy.h>
 #include <AsteriskSCF/Core/Routing/RoutingIf.h>
-#include <AsteriskSCF/System/Component/ReplicaIf.h>
 #include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
-#include <AsteriskSCF/System/Component/ComponentServiceIf.h>
 #include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.h>
 
 #include <AsteriskSCF/Logger/IceLogger.h>
@@ -49,7 +47,6 @@ using namespace AsteriskSCF::System::Component::V1;
 using namespace AsteriskSCF::System::Logging;
 using namespace AsteriskSCF::BasicRoutingService::V1;
 
-using namespace AsteriskSCF::Component;
 using namespace AsteriskSCF::Replication;
 using namespace AsteriskSCF::Discovery;
 
@@ -63,11 +60,10 @@ namespace AsteriskSCF
 {
 namespace BasicRoutingService
 {
-
-class BasicRoutingServiceApp : public Component
+class Component : public AsteriskSCF::Component::Component
 {
 public:
-    BasicRoutingServiceApp() 
+    Component() 
         : AsteriskSCF::Component::Component(lg, 
                                       "BasicRoutingService"),
           mSessionContext(new SessionContext()),
@@ -77,7 +73,7 @@ public:
     }
 
 private:
-    // Required Component overrides
+    // Required base Component overrides
     virtual void createPrimaryServices();
     virtual void registerPrimaryServices();
     virtual void createReplicationStateListeners();
@@ -85,14 +81,9 @@ private:
     virtual void listenToStateReplicators();
     virtual void findRemoteServices();
 
-    // Other overrides
+    // Other base Component overrides
     virtual ReplicationContextPtr createReplicationContext(ReplicationStateType state);
 
-    LocatorRegistrationWrapperPtr registerService(const Ice::ObjectPrx& proxy, 
-                 const string& category,
-                 const string& service,
-                 const string& id = "");
-
     void locateBridgeManager();
     void locateStateReplicator();
 
@@ -127,27 +118,31 @@ private:
     bool mListeningToReplicator;
     boost::shared_mutex mReplicatorLock;
 };
-typedef ::IceUtil::Handle<BasicRoutingServiceApp> BasicRoutingServiceAppPtr;
+typedef ::IceUtil::Handle<Component> ComponentPtr;
 
 static const string RegistryLocatorObjectId("RoutingServiceLocatorRegistry");
 static const string RoutingAdminObjectId("RoutingAdmin");
-static const string ComponentServiceId("BasicRoutingComponent");
 static const string SessionRouterObjectId("SessionRouter");
-static const string ReplicaServiceId("BasicRoutingServiceReplica");
 
 /** 
  * Register as a listener to our state replicator. 
  * A component in standby mode will do this to monitor state changes
  * being sent from an active component. 
  */
-void BasicRoutingServiceApp::listenToStateReplicators()
+void Component::listenToStateReplicators()
 {
     boost::unique_lock<boost::shared_mutex> lock(mReplicatorLock); 
     RoutingReplicationContextPtr routingReplicationContext = 
         static_pointer_cast<RoutingReplicationContext>(getReplicationContext());
 
-    if ((!routingReplicationContext->getReplicator().isInitialized()) || (mListeningToReplicator == true))
+    if (mListeningToReplicator == true)
+    {
+        return;
+    }
+
+    if (!routingReplicationContext->getReplicator().isInitialized())
     {
+        lg(Error) << getName() << " : State replicator could not be found. Unable to listen for state updates!";
         return;
     }
 
@@ -175,7 +170,7 @@ void BasicRoutingServiceApp::listenToStateReplicators()
  * A component in active mode doesn't neeed to listen to
  * state replication data. 
  */
-void BasicRoutingServiceApp::stopListeningToStateReplicators()
+void Component::stopListeningToStateReplicators()
 {
     boost::unique_lock<boost::shared_mutex> lock(mReplicatorLock); 
     RoutingReplicationContextPtr routingReplicationContext = 
@@ -189,7 +184,8 @@ void BasicRoutingServiceApp::stopListeningToStateReplicators()
     try
     {
         AsteriskSCF::BasicRoutingService::V1::RoutingStateReplicatorPrx oneWayStateReplicator = 
-                AsteriskSCF::BasicRoutingService::V1::RoutingStateReplicatorPrx::uncheckedCast(routingReplicationContext->getReplicator()->ice_oneway());
+                AsteriskSCF::BasicRoutingService::V1::RoutingStateReplicatorPrx::uncheckedCast(
+                   routingReplicationContext->getReplicator()->ice_oneway());
 
         oneWayStateReplicator->removeListener(mReplicatorListenerProxy);
         mListeningToReplicator = false;
@@ -202,36 +198,11 @@ void BasicRoutingServiceApp::stopListeningToStateReplicators()
 }
 
 /**
- * Helper function to wrap a service in a registration wrapper.
- */
-LocatorRegistrationWrapperPtr BasicRoutingServiceApp::registerService(const Ice::ObjectPrx& proxy, 
-                 const string& category,
-                 const string& service,
-                 const string& id)
-{
-    string guid = getName() + "." + category;
-
-    // Configure how other components look this component up.
-    ServiceLocatorParamsPtr params = new ServiceLocatorParams;
-    params->category = category;
-    params->service = service;
-    params->id = getName();
-
-    LocatorRegistrationWrapperPtr wrapper = 
-            new LocatorRegistrationWrapper(getCommunicator(), getServiceLocatorManagementProperty(), proxy, 
-                guid, params);
-
-    return wrapper;
-}
-
-/**
  * Register this component's primary public interfaces with the Service Locator.
  * This enables other Asterisk SCF components to locate the interfaces we are publishing.
  *
- * @param includeBackplaneServices If true, registers our management interfaces
- * in addition to all our other interfaces. 
  */
-void BasicRoutingServiceApp::registerPrimaryServices()
+void Component::registerPrimaryServices()
 {
     try
     {
@@ -239,27 +210,27 @@ void BasicRoutingServiceApp::registerPrimaryServices()
             getName() + ".Service", "default");
 
         // Register our RoutingAdmin interface with the Service Locator.
-        mAdminRegistration = registerService(mAdminPrx, 
-                                             Routing::V1::RoutingServiceAdminDiscoveryCategory, 
-                                             serviceName, 
-                                             getName());
-        bool registered =  registerPrimaryService(mAdminRegistration);
+        mAdminRegistration = wrapServiceForRegistration(mAdminPrx, 
+                                                        RoutingServiceAdminDiscoveryCategory, 
+                                                        serviceName, 
+                                                        getName());
+        bool registered =  managePrimaryService(mAdminRegistration);
 
 
         // Register our RegistryLocator interface with the Service Locator.
-        mRegistryLocatorRegistration = registerService(mEndpointRegistryPrx,
-                                                       Routing::V1::RoutingServiceLocatorRegistryDiscoveryCategory,
-                                                       serviceName,
-                                                       getName());
-        registered =  registerPrimaryService(mRegistryLocatorRegistration);
+        mRegistryLocatorRegistration = wrapServiceForRegistration(mEndpointRegistryPrx,
+                                                                  RoutingServiceLocatorRegistryDiscoveryCategory,
+                                                                  serviceName,
+                                                                  getName());
+        registered =  managePrimaryService(mRegistryLocatorRegistration);
                       
 
         // Register the SessionRouter interface with the Service Locator.
-        mSessionRouterRegistration = registerService(mSessionRouterPrx,
-                                                     Routing::V1::SessionRouterDiscoveryCategory,
-                                                     serviceName,
-                                                     getName());
-        registered = registerPrimaryService(mSessionRouterRegistration);
+        mSessionRouterRegistration = wrapServiceForRegistration(mSessionRouterPrx,
+                                                                SessionRouterDiscoveryCategory,
+                                                                serviceName,
+                                                                getName());
+        registered = managePrimaryService(mSessionRouterRegistration);
     }
     catch(const std::exception& e)
     {
@@ -272,7 +243,7 @@ void BasicRoutingServiceApp::registerPrimaryServices()
 /**
  * Locate the BridgeManager using the Service Locator.
  */
-void BasicRoutingServiceApp::locateBridgeManager()
+void Component::locateBridgeManager()
 {
     try
     {
@@ -295,7 +266,7 @@ void BasicRoutingServiceApp::locateBridgeManager()
 /**
  * Locate our State Replicator using the Service Locator.
  */
-void BasicRoutingServiceApp::locateStateReplicator()
+void Component::locateStateReplicator()
 {
     if (getReplicationContext()->getState() == ACTIVE_STANDALONE)
     {
@@ -307,7 +278,7 @@ void BasicRoutingServiceApp::locateStateReplicator()
     replicatorParams->service = getCommunicator()->getProperties()->getPropertyWithDefault(
           getName() + ".StateReplicatorService", "default");
     replicatorParams->id = getCommunicator()->getProperties()->getPropertyWithDefault(
-         getName() + ".StateReplicatorId", "default");
+         getName() + ".StateReplicatorId", "");
 
     try
     {
@@ -327,13 +298,13 @@ void BasicRoutingServiceApp::locateStateReplicator()
 /**
  * Override of factory method to create our replication context. 
  */
-ReplicationContextPtr BasicRoutingServiceApp::createReplicationContext(ReplicationStateType state)
+ReplicationContextPtr Component::createReplicationContext(ReplicationStateType state)
 {
     RoutingReplicationContextPtr context(new RoutingReplicationContext(state));
     return context;
 }
 
-void BasicRoutingServiceApp::createPrimaryServices()
+void Component::createPrimaryServices()
 {
     try
     {
@@ -345,7 +316,8 @@ void BasicRoutingServiceApp::createPrimaryServices()
         mEventPublisher = new RoutingServiceEventPublisher(getServiceAdapter());
 
         // Create and configure the EndpointRegistry.
-        mEndpointRegistry = new EndpointRegistry(ScriptProcessorPtr(new LuaScriptProcessor()), mEventPublisher, routingReplicationContext);
+        mEndpointRegistry = new EndpointRegistry(ScriptProcessorPtr(new LuaScriptProcessor()), 
+            mEventPublisher, routingReplicationContext);
         mEndpointRegistryPrx = LocatorRegistryPrx::uncheckedCast(getServiceAdapter()->add(
             mEndpointRegistry, getCommunicator()->stringToIdentity(RegistryLocatorObjectId)));
 
@@ -377,13 +349,14 @@ void BasicRoutingServiceApp::createPrimaryServices()
     }
 }
 
-void BasicRoutingServiceApp::createReplicationStateListeners()
+void Component::createReplicationStateListeners()
 {
     try
     {
         // Create and publish our state replicator listener interface on the backplane adapter. 
         mReplicatorListener = new RoutingStateReplicatorListenerImpl(mEndpointRegistry, mOperationReplicaCache);
-        RoutingStateReplicatorListenerPrx replicatorListener = RoutingStateReplicatorListenerPrx::uncheckedCast(getBackplaneAdapter()->addWithUUID(mReplicatorListener));
+        RoutingStateReplicatorListenerPrx replicatorListener = 
+            RoutingStateReplicatorListenerPrx::uncheckedCast(getBackplaneAdapter()->addWithUUID(mReplicatorListener));
         mReplicatorListenerProxy = RoutingStateReplicatorListenerPrx::uncheckedCast(replicatorListener->ice_oneway());
     }
     catch(const Ice::Exception &e)
@@ -393,7 +366,7 @@ void BasicRoutingServiceApp::createReplicationStateListeners()
     }
 }
 
-void BasicRoutingServiceApp::findRemoteServices() 
+void Component::findRemoteServices() 
 {
     locateBridgeManager();
     locateStateReplicator();
@@ -402,12 +375,11 @@ void BasicRoutingServiceApp::findRemoteServices()
 } // end BasicRoutingService
 } // end AsteriskSCF
 
-
 extern "C"
 {
 ASTERISK_SCF_ICEBOX_EXPORT IceBox::Service* create(::Ice::CommunicatorPtr)
 {
-    return new AsteriskSCF::BasicRoutingService::BasicRoutingServiceApp;
+    return new AsteriskSCF::BasicRoutingService::Component;
 }
 }
 
diff --git a/src/RoutingReplicationContext.cpp b/src/RoutingReplicationContext.cpp
deleted file mode 100644
index e09ae31..0000000
--- a/src/RoutingReplicationContext.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Asterisk SCF -- An open-source communications framework.
- *
- * Copyright (C) 2010-2011, Digium, Inc.
- *
- * See http://www.asterisk.org for more information about
- * the Asterisk SCF project. Please do not directly contact
- * any of the maintainers of this project for assistance;
- * the project provides a web site, mailing lists and IRC
- * channels for your use.
- *
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE.txt file
- * at the top of the source tree.
- */
-
-#include <boost/thread/locks.hpp>
-
-#include "ReplicationContext.h"
-
-using namespace ::AsteriskSCF::Discovery;
-
-namespace AsteriskSCF
-{
-namespace BasicRoutingService
-{
-
-class ReplicationContextPriv 
-{
-public:
-    ReplicationContextPriv(bool componentIsActive, bool standalone) : 
-
-
-
-                    mActive(componentIsActive),
-                    mStandalone(standalone),
-                    mTestContext(new TestContext())
-    {
-    }
-
-    ReplicatorServicePrx mReplicatorService;
-    bool mActive;
-    bool mStandalone;
-
-    TestContextPtr mTestContext;
-
-    boost::shared_mutex mLock;
-};
-
-ReplicationContext::ReplicationContext(bool componentIsActive, bool standalone)
-    :  mImpl(new ReplicationContextPriv(componentIsActive, standalone))
-{
-}
-
-bool ReplicationContext::isReplicating()
-{
-    boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
-
-    return ((mImpl->mActive) && (!mImpl->mStandalone) && (mImpl->mReplicatorService.initialize() != 0));
-}
-
-bool ReplicationContext::isComponentActive()
-{
-    boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
-
-    return mImpl->mActive;
-}
-
-bool ReplicationContext::isStandalone()
-{
-    boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
-
-    return mImpl->mStandalone;
-}
-
-void ReplicationContext::setComponentActive() 
-{
-    boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
-
-    mImpl->mActive = true;
-
-}
-
-void ReplicationContext::setComponentStandby() 
-{
-    boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
-
-    mImpl->mActive = false;
-}
-
-ReplicatorServicePrx ReplicationContext::getReplicatorService() 
-{
-    boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
-
-    return mImpl->mReplicatorService;
-}
-
-void ReplicationContext::setReplicatorService(const ReplicatorServicePrx& service) 
-{
-    boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
-
-    mImpl->mReplicatorService = service;
-}
-
-TestContextPtr ReplicationContext::getTestContext()
-{
-   return mImpl->mTestContext;
-}
-
-} // end BasicRoutingService
-} // end AsteriskSCF
diff --git a/src/RoutingReplicationContext.h b/src/RoutingReplicationContext.h
index 373c471..50c010e 100644
--- a/src/RoutingReplicationContext.h
+++ b/src/RoutingReplicationContext.h
@@ -20,6 +20,7 @@
 #include <AsteriskSCF/Discovery/SmartProxy.h>
 #include <AsteriskSCF/Replication/ReplicationContext.h>
 #include <AsteriskSCF/Component/TestContext.h>
+
 #include "BasicRoutingStateReplicationIf.h"
 
 namespace AsteriskSCF

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


-- 
asterisk-scf/integration/routing.git



More information about the asterisk-scf-commits mailing list