[asterisk-scf-commits] asterisk-scf/integration/routing.git branch "refactor_startup" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed May 18 10:27:28 CDT 2011


branch "refactor_startup" has been created
        at  6c2629eca0196ffd38384f6bd3b165d20330a495 (commit)

- Log -----------------------------------------------------------------
commit 6c2629eca0196ffd38384f6bd3b165d20330a495
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Wed May 18 10:22:27 2011 -0500

    Cleanup of startup process.
     - Renamed the adapter to PrimaryAdapter to match wiki doc.
     - Renamed the ComponentServiceAdapter to ManagementAdapter to match wiki doc.
     - Moved Replica and StateReplicatorListener interfaces to the Management adapter.
     - Use the suspend()/unsuspend() operators on the interfaces published to the ServiceLocator, rather than unregistering and reregistering them as a result of a suspend()/resume() from the ComponentService interface.

diff --git a/src/BasicRoutingServiceApp.cpp b/src/BasicRoutingServiceApp.cpp
index 08e2572..46dd274 100644
--- a/src/BasicRoutingServiceApp.cpp
+++ b/src/BasicRoutingServiceApp.cpp
@@ -61,6 +61,12 @@ namespace AsteriskSCF
 namespace BasicRoutingService
 {
 
+enum ServiceManagementType
+{
+    SUSPEND_SERVICE,
+    RESUME_SERVICE
+};
+
 class ComponentServiceImpl;
 typedef ::IceUtil::Handle<ComponentServiceImpl> ComponentServiceImplPtr;
 
@@ -101,6 +107,7 @@ private:
     void locateStateReplicator();
     void registerWithServiceLocator(bool includeComponentService);
     void deregisterFromServiceLocator(bool includeComponentService);
+    void manageRegisteredServants(ServiceManagementType type, bool includeComponentService);
 
     void listenToStateReplicator();
     void stopListeningToStateReplicator();
@@ -146,8 +153,9 @@ private:
     bool mListeningToReplicator;
 
     // Implementation
-    ::Ice::ObjectAdapterPtr mAdapter;
-    ::Ice::ObjectAdapterPtr mComponentServiceAdapter;
+    ::Ice::ObjectAdapterPtr mPrimaryAdapter;
+    ::Ice::ObjectAdapterPtr mManagementAdapter;
+
     ::Ice::CommunicatorPtr mCommunicator;
 
     boost::shared_mutex mReplicatorLock;
@@ -246,7 +254,7 @@ public:
      *  @param app 
      *  @param adapter The adapter is assumed to have been activated. 
      */
-    ReplicaManagement(BasicRoutingServiceApp* app, ::Ice::ObjectAdapterPtr adapter) : mApp(app), mAdapter(adapter)
+    ReplicaManagement(BasicRoutingServiceApp* app, ::Ice::ObjectAdapterPtr adapter) : mApp(app), mManagementAdapter(adapter)
     { 
     }
 
@@ -261,7 +269,7 @@ public:
 
         for (vector<AsteriskSCF::System::Component::V1::ReplicaListenerPrx>::const_iterator listener = mListeners.begin(); listener != mListeners.end(); ++listener)
         {
-            (*listener)->activated(ReplicaPrx::uncheckedCast(mAdapter->createDirectProxy(mAdapter->getCommunicator()->stringToIdentity(ReplicaServiceId))));
+            (*listener)->activated(ReplicaPrx::uncheckedCast(mManagementAdapter->createDirectProxy(mManagementAdapter->getCommunicator()->stringToIdentity(ReplicaServiceId))));
         }
 
         return true;
@@ -274,7 +282,7 @@ public:
         for (vector<AsteriskSCF::System::Component::V1::ReplicaListenerPrx>::const_iterator listener = mListeners.begin(); 
              listener != mListeners.end(); ++listener)
         {
-            (*listener)->onStandby(ReplicaPrx::uncheckedCast(mAdapter->createDirectProxy(mAdapter->getCommunicator()->stringToIdentity(ReplicaServiceId))));
+            (*listener)->onStandby(ReplicaPrx::uncheckedCast(mManagementAdapter->createDirectProxy(mManagementAdapter->getCommunicator()->stringToIdentity(ReplicaServiceId))));
         }
     }
 
@@ -294,7 +302,7 @@ private:
     /**
      * Pointer to the object adapter we exist on.
      */
-    ::Ice::ObjectAdapterPtr mAdapter;
+    ::Ice::ObjectAdapterPtr mManagementAdapter;
 
     /**
      * Listeners that we need to push state change notifications out to.
@@ -399,18 +407,15 @@ void setCategory(const Discovery::V1::ServiceManagementPrx& serviceManagement, c
  * 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 includeComponentService If true, registers our ComponentService interface
- * in addition to all our other interfaces. While it is not uncommon to need to 
- * re-register most of our interfaces due to a pause()/resume(), we only deregister
- * the ComponentService during shutdown. So this variable would typically be true only 
- * during initial startup. 
+ * @param includeManagementServices If true, registers our management interfaces
+ * in addition to all our other interfaces. 
  */
-void BasicRoutingServiceApp::registerWithServiceLocator(bool includeComponentService)
+void BasicRoutingServiceApp::registerWithServiceLocator(bool includeManagementServices)
 {
     try
     {
         // Register our RoutingAdmin interface with the Service Locator.
-        ::Ice::ObjectPrx adminObjectPrx = mAdapter->createDirectProxy(mCommunicator->stringToIdentity(RoutingAdminObjectId));
+        ::Ice::ObjectPrx adminObjectPrx = mPrimaryAdapter->createDirectProxy(mCommunicator->stringToIdentity(RoutingAdminObjectId));
         RoutingServiceAdminPrx adminPrx = RoutingServiceAdminPrx::checkedCast(adminObjectPrx);
         string adminServiceGuid(mImplementationId + "." + Routing::V1::RoutingServiceAdminDiscoveryCategory); // Should be unique for reporting.
         mAdminManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(adminPrx, adminServiceGuid));
@@ -418,7 +423,7 @@ void BasicRoutingServiceApp::registerWithServiceLocator(bool includeComponentSer
         setCategory(mAdminManagement, Routing::V1::RoutingServiceAdminDiscoveryCategory);
 
         // Register our RegistryLocator interface with the Service Locator.
-        ::Ice::ObjectPrx locatorObjectPrx = mAdapter->createDirectProxy(mCommunicator->stringToIdentity(RegistryLocatorObjectId));
+        ::Ice::ObjectPrx locatorObjectPrx = mPrimaryAdapter->createDirectProxy(mCommunicator->stringToIdentity(RegistryLocatorObjectId));
         LocatorRegistryPrx locatorRegistryPrx = LocatorRegistryPrx::checkedCast(locatorObjectPrx);
         string locatorServiceGuid(mImplementationId + "." + Routing::V1::RoutingServiceLocatorRegistryDiscoveryCategory);  // Should be unique for reporting.
         mRegistryLocatorManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(locatorRegistryPrx, locatorServiceGuid));
@@ -426,7 +431,7 @@ void BasicRoutingServiceApp::registerWithServiceLocator(bool includeComponentSer
         setCategory(mRegistryLocatorManagement, Routing::V1::RoutingServiceLocatorRegistryDiscoveryCategory);
 
         // Register the SessionRouter interface with the Service Locator.
-        ::Ice::ObjectPrx sessionRouterObjectPrx = mAdapter->createDirectProxy(mCommunicator->stringToIdentity(SessionRouterObjectId));
+        ::Ice::ObjectPrx sessionRouterObjectPrx = mPrimaryAdapter->createDirectProxy(mCommunicator->stringToIdentity(SessionRouterObjectId));
         AsteriskSCF::SessionCommunications::V1::SessionRouterPrx sessionRouterPrx = 
             AsteriskSCF::SessionCommunications::V1::SessionRouterPrx::checkedCast(sessionRouterObjectPrx);
         string sessionRouterGuid(mImplementationId + "." + Routing::V1::SessionRouterDiscoveryCategory);   // Should be unique
@@ -434,11 +439,11 @@ void BasicRoutingServiceApp::registerWithServiceLocator(bool includeComponentSer
 
         setCategory(mSessionRouterManagement, Routing::V1::SessionRouterDiscoveryCategory);
 
-        if (includeComponentService)
+        if (includeManagementServices)
         {
             // Register the ComponentService interface with the Service Locator.
-            // Note that this interface has it's own adapter.
-            ::Ice::ObjectPrx componentServiceObjectPrx = mComponentServiceAdapter->createDirectProxy(mCommunicator->stringToIdentity(ComponentServiceId));
+            // Note that this interface goes on the management adapter.
+            ::Ice::ObjectPrx componentServiceObjectPrx = mManagementAdapter->createDirectProxy(mCommunicator->stringToIdentity(ComponentServiceId));
             ComponentServicePrx componentServicePrx = ComponentServicePrx::checkedCast(componentServiceObjectPrx);
             string componentServiceGuid(mImplementationId + "." + Routing::V1::ComponentServiceDiscoveryCategory);   // Should be unique for reporting.
             mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(componentServicePrx, componentServiceGuid));
@@ -448,7 +453,7 @@ void BasicRoutingServiceApp::registerWithServiceLocator(bool includeComponentSer
             if (mPublishTestInterface)
             {
                 // Register our test servant as a facet of the ComponentService interface.
-                mComponentServiceAdapter->addFacet(mComponentTest, componentServicePrx->ice_getIdentity(), AsteriskSCF::System::Component::V1::ComponentTestFacet);
+                mManagementAdapter->addFacet(mComponentTest, componentServicePrx->ice_getIdentity(), AsteriskSCF::System::Component::V1::ComponentTestFacet);
             }
         }
     }
@@ -460,15 +465,13 @@ void BasicRoutingServiceApp::registerWithServiceLocator(bool includeComponentSer
 }
 
 /**
- * Deregister this component's primary public interfaces from the Service Locator.
- * This is done at shutdown, and whenever we want to keep other services from locating
- * our interfaces.
+ * Deregister this component's interfaces from the Service Locator.
  *
- * @param includeComponentService If true, deregisters our ComponentService interface
+ * @param includeManagementServices If true, deregisters our management interfaces
  * in addition to all our other interfaces, making this component unreachable from the 
- * rest of Asterisk SCF. Should only be done during shutdown.
+ * rest of Asterisk SCF. 
  */
-void BasicRoutingServiceApp::deregisterFromServiceLocator(bool includeComponentService)
+void BasicRoutingServiceApp::deregisterFromServiceLocator(bool includeManagementServices)
 {
     try
     {
@@ -476,14 +479,57 @@ void BasicRoutingServiceApp::deregisterFromServiceLocator(bool includeComponentS
         mAdminManagement->unregister();
         mSessionRouterManagement->unregister();
 
-        if (includeComponentService)
+        if (includeManagementServices)
         {
             mComponentServiceManagement->unregister();
         }
     }
     catch(...)
     {
-        lg(Error) << "Had trouble in deregisterFromServiceLocator().";
+        lg(Error) << BOOST_CURRENT_FUNCTION << e.what();
+    }
+}
+
+/**
+ * Suspends or unsuspends this component's primary public interfaces 
+ * within the Service Locator. When suspended in this manner, the ServiceLocator
+ * will not consider the component during lookup requests. 
+ *
+ * @param type Type of management operation. 
+ *
+ * @param includeManagementServices If true, affects our management interfaces
+ * in addition to all our other interfaces.
+ */
+void BasicRoutingServiceApp::manageRegisteredServants(ServiceManagementType type, bool includeManagementServices)
+{
+    try
+    {
+        if (type == SUSPEND_SERVICE)
+        {
+            mRegistryLocatorManagement->suspend();
+            mAdminManagement->suspend();
+            mSessionRouterManagement->suspend();
+
+            if (includeManagementServices)
+            {
+                mComponentServiceManagement->suspend();
+            }
+        }
+        else if (type == RESUME_SERVICE)
+        {
+            mRegistryLocatorManagement->unsuspend();
+            mAdminManagement->unsuspend();
+            mSessionRouterManagement->unsuspend();
+
+            if (includeManagementServices)
+            {
+                mComponentServiceManagement->unsuspend();
+            }
+        }
+    }
+    catch(const std::exception& e)
+    {
+        lg(Error) << BOOST_CURRENT_FUNCTION << e.what();
     }
 }
 
@@ -537,29 +583,27 @@ void BasicRoutingServiceApp::initialize()
     try
     {
         // Create the primary adapter.
-        mAdapter = mCommunicator->createObjectAdapter(mAppName);
+        mPrimaryAdapter = mCommunicator->createObjectAdapter(mAppName);
 
-        // Create a separate adapter just for the component service. This is 
-        // to make it easy to deactivate all of our interfaces other than the
-        // component service for suspend()/resume().  
-        mComponentServiceAdapter = mCommunicator->createObjectAdapter(mAppName + ".ComponentService");
+        // Create an adapter that is bound to the dedicated (non-movable) address of this component. 
+        mManagementAdapter = mCommunicator->createObjectAdapter(mAppName + ".Management");
 
         bool active = !(mCommunicator->getProperties()->getPropertyWithDefault(mAppName + ".Standby", "no") == "yes");
 
         // Create the replication context.
         mReplicationContext = ReplicationContextPtr(new ReplicationContext(active));
 
-        mEventPublisher = new RoutingServiceEventPublisher(mAdapter);
+        mEventPublisher = new RoutingServiceEventPublisher(mPrimaryAdapter);
 
         // setup the logger
-        ConfiguredIceLoggerPtr mIceLogger = createIceLogger(mAdapter);
+        ConfiguredIceLoggerPtr mIceLogger = createIceLogger(mPrimaryAdapter);
         getLoggerFactory().setLogOutput(mIceLogger->getLogger());
 
         // Create and configure the EndpointRegistry.
          mEndpointRegistry = new EndpointRegistry(ScriptProcessorPtr(new LuaScriptProcessor()), mEventPublisher, mReplicationContext);
 
         // Publish the LocatorRegistry interface.
-        mAdapter->add(mEndpointRegistry, mCommunicator->stringToIdentity(RegistryLocatorObjectId));
+        mPrimaryAdapter->add(mEndpointRegistry, mCommunicator->stringToIdentity(RegistryLocatorObjectId));
 
         // Check to see if we're configured to publish a test interface.
         mPublishTestInterface = (mCommunicator->getProperties()->getPropertyWithDefault(mAppName + ".ComponentTest", "no") == "yes");
@@ -572,7 +616,7 @@ void BasicRoutingServiceApp::initialize()
         }
 
         // Create the session context needed to construct operations.
-        mSessionContext = SessionContextPtr(new SessionContext(mAdapter, 
+        mSessionContext = SessionContextPtr(new SessionContext(mPrimaryAdapter, 
                                                              mEndpointRegistry, 
                                                              mEventPublisher, 
                                                              mWorkQueue,
@@ -583,24 +627,24 @@ void BasicRoutingServiceApp::initialize()
 
         // Create publish the SessionRouter interface.
         mSessionRouter = new SessionRouter(mSessionContext, mOperationReplicaCache);
-        mAdapter->add(mSessionRouter, mCommunicator->stringToIdentity(SessionRouterObjectId));
+        mPrimaryAdapter->add(mSessionRouter, mCommunicator->stringToIdentity(SessionRouterObjectId));
 
         // Create and publish the Admin interface support.
         mAdminInteface = new RoutingAdmin(mEndpointRegistry);
-        mAdapter->add(mAdminInteface, mCommunicator->stringToIdentity(RoutingAdminObjectId));
+        mPrimaryAdapter->add(mAdminInteface, mCommunicator->stringToIdentity(RoutingAdminObjectId));
 
-        // Create and publish the ComponentService interface on it's own dedicated adapter. 
+        // Create and publish the ComponentService interface on the management adapter. 
         mComponentService = new ComponentServiceImpl(this);
-        mComponentServiceAdapter->add(mComponentService, mCommunicator->stringToIdentity(ComponentServiceId));
+        mManagementAdapter->add(mComponentService, mCommunicator->stringToIdentity(ComponentServiceId));
 
-        // Create and publish our Replica interface support. This interface allows this component
+        // Create and publish our Replica interface on the management adapter. This interface allows this component
         // to be activated or placed in standby mode. 
-        mReplicaManagement = new ReplicaManagement(this, mAdapter);
-        mAdapter->add(mReplicaManagement, mCommunicator->stringToIdentity(ReplicaServiceId));
+        mReplicaManagement = new ReplicaManagement(this, mManagementAdapter);
+        mManagementAdapter->add(mReplicaManagement, mCommunicator->stringToIdentity(ReplicaServiceId));
 
-        // Create and publish our state replicator listener interface.
+        // Create and publish our state replicator listener interface on the management adapter. 
         mReplicatorListener = new RoutingStateReplicatorListenerImpl(mEndpointRegistry, mOperationReplicaCache);
-        RoutingStateReplicatorListenerPrx replicatorListener = RoutingStateReplicatorListenerPrx::uncheckedCast(mAdapter->addWithUUID(mReplicatorListener));
+        RoutingStateReplicatorListenerPrx replicatorListener = RoutingStateReplicatorListenerPrx::uncheckedCast(mManagementAdapter->addWithUUID(mReplicatorListener));
         mReplicatorListenerProxy = RoutingStateReplicatorListenerPrx::uncheckedCast(replicatorListener->ice_oneway());
 
         if (active)
@@ -612,8 +656,8 @@ void BasicRoutingServiceApp::initialize()
             onStandby();
         }
 
-        mAdapter->activate();
-        mComponentServiceAdapter->activate();
+        mPrimaryAdapter->activate();
+        mManagementAdapter->activate();
 
         // Get a proxy to the management interface for the Service Locator manager.
         // This isso we can add ourselves into the system discovery mechanisms.
@@ -652,8 +696,8 @@ void BasicRoutingServiceApp::start(const string& name, const ::Ice::Communicator
     }
     else
     {
-        mAdapter->activate();
-        mComponentServiceAdapter->activate();
+        mPrimaryAdapter->activate();
+        mManagementAdapter->activate();
     }
 
     // Plug into the Asterisk SCF discovery system so that the interfaces we provide
@@ -677,12 +721,11 @@ void BasicRoutingServiceApp::resume()
         // If we're in standby by mode, listen for state replication.
        listenToStateReplicator();
 
-        // Plug back into the Asterisk SCF discovery system so that the interfaces we provide
-        // can be located.
-        registerWithServiceLocator(false);
-
         // Reactivate the primary adapter. 
-        mAdapter->activate();
+        mPrimaryAdapter->activate();
+
+        // Re-enable lookups of our interfaces in the ServiceLocator. 
+        manageRegisteredServants(RESUME_SERVICE, false);
     }
 
     mRunning = true;
@@ -695,15 +738,20 @@ void BasicRoutingServiceApp::suspendService(bool shuttingDown)
 {
     if (mRunning)
     {
-        // Deregister our servants.
-        deregisterFromServiceLocator(shuttingDown);
+        // Suspend lookups of our interfaces in the ServiceLocator. If shutting down,
+        // we'll be deregestering our interfaces with the ServiceLocator,
+        // so don't waste the bandwidth. 
+        if (!shuttingDown)
+        {
+            manageRegisteredServants(SUSPEND_SERVICE, false);
+        }
 
         // Remove our interfaces from the state replicator.
         stopListeningToStateReplicator();
 
         // Deactive the primary adapter. 
         // The adapter that services the ComponentService stays active. 
-        mAdapter->deactivate();
+        mPrimaryAdapter->deactivate();
     }
 
     mRunning = false;
@@ -730,12 +778,11 @@ void BasicRoutingServiceApp::stop()
 
     suspendService(true);
 
-    // Just in case we were in suspend() mode when told to stop.
-    mComponentServiceManagement->unregister();
+    deregisterFromServiceLocator(true);
 
-    // Turn off our ComponentService interface. 
+    // Turn off our management interface. 
     // Only a start() directly from IceBox can restart us now. 
-    mComponentServiceAdapter->deactivate();
+    mManagementAdapter->deactivate();
 
     lg(Info) << "Stopped.";
 }

commit 2e28c01e8ddf5bcb0de714290344df7c2efa7dee
Author: David M. Lee <dlee at digium.com>
Date:   Tue May 10 09:55:17 2011 -0500

    Corrected closing >'s for nested argument list

diff --git a/src/OperationReplicaCache.h b/src/OperationReplicaCache.h
index 6a06e98..5d207fb 100644
--- a/src/OperationReplicaCache.h
+++ b/src/OperationReplicaCache.h
@@ -64,7 +64,7 @@ class OperationCache
 {
 public:
 
-    typedef std::map<std::string, OperationReplicaItem<boost::shared_ptr<O>>> OpMapType;
+    typedef std::map<std::string, OperationReplicaItem<boost::shared_ptr<O> > > OpMapType;
 
     OperationCache(const SessionContextPtr& sessionContext) 
                       : mSessionContext(sessionContext)

commit a6c250edee3612162b4c78d3a72296b58a5e5432
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Mon May 9 18:22:21 2011 -0500

    Removed extraneous files.

diff --git a/src/RoutingStateReplicatorListener.cpp~HEAD b/src/RoutingStateReplicatorListener.cpp~HEAD
deleted file mode 100644
index dc48b3c..0000000
--- a/src/RoutingStateReplicatorListener.cpp~HEAD
+++ /dev/null
@@ -1,215 +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 <IceUtil/UUID.h>
-
-#include <boost/thread.hpp>
-
-#include <AsteriskSCF/logger.h>
-
-#include "RoutingStateReplicatorListener.h"
-#include "OperationReplicaCache.h"
-#include "RouteSessionOperation.h"
-#include "EndpointRegistry.h"
-
-using namespace AsteriskSCF::BasicRoutingService::V1;
-using namespace AsteriskSCF::System::Logging;
-
-namespace
-{
-Logger lg = getLoggerFactory().getLogger("AsteriskSCF.BasicRoutingService");
-}
-
-namespace AsteriskSCF
-{
-namespace BasicRoutingService
-{
-/** 
- * Private details of our RoutingStateReplicatorListener implementation. 
- */
-class RoutingStateReplicatorListenerPriv
-{
-public:
-   RoutingStateReplicatorListenerPriv(const EndpointRegistryPtr& registry, const boost::shared_ptr<OperationReplicaCache>& opCache)
-        : mId(IceUtil::generateUUID()),
-          mEndpointRegistry(registry),
-          mOperationReplicaCache(opCache)
-   {
-   }
-
-    void stateRemovedForItems(const RoutingStateItemSeq& items, const Ice::Current& current)
-    {
-        // Method local visitor implementation for handling removal of state items. 
-	    class visitor : public AsteriskSCF::BasicRoutingService::V1::RoutingStateItemVisitor
-	    {
-	    public:
-	        visitor(RoutingStateReplicatorListenerPriv *impl) : mImpl(impl)
-	        {
-	        }
-
-	    private:
-	        RoutingStateReplicatorListenerPriv *mImpl;
-
-            void visitRouteSessionOpStart(const ::AsteriskSCF::BasicRoutingService::V1::RouteSessionOpStartPtr& opState)
-            {
-                // The operation cache keeps all the collected state for an operation under the transaction id. 
-                mImpl->mOperationReplicaCache->getRouteSessionCache()->dropOperation(opState->operationId);
-            }
-
-            void visitRouteSessionOpWaitLookupState(const ::AsteriskSCF::BasicRoutingService::V1::RouteSessionOpWaitLookupStatePtr& opState)
-            {
-                // Removing the Start state for this operation will clean it up. 
-            }
-
-            void visitRouteSessionOpBridgingState(const ::AsteriskSCF::BasicRoutingService::V1::RouteSessionOpBridgingStatePtr& opState)
-            {
-                // Removing the Start state for this operation will clean it up. 
-            }
-
-            void visitConnectBridgedSessionsWithDestinationOpStart(const ::AsteriskSCF::BasicRoutingService::V1::ConnectBridgedSessionsWithDestinationOpStartPtr& opState)
-            {
-                mImpl->mOperationReplicaCache->getConnectBridgedSessionsWithDestCache()->dropOperation(opState->operationId);
-            }
-
-            void visitConnectBridgedSessionsWithDestinationOpWaitLookupState(const ::AsteriskSCF::BasicRoutingService::V1::ConnectBridgedSessionsWithDestinationOpWaitLookupStatePtr& opState)
-            {
-                // Removing the Start state for this operation will clean it up. 
-            }
-
-            void visitConnectBridgedSessionsWithDestinationOpBridgingState(const ::AsteriskSCF::BasicRoutingService::V1::ConnectBridgedSessionsWithDestinationOpBridgingStatePtr& opState)
-            {
-                // Removing the Start state for this operation will clean it up. 
-            }
-
-            void visitEndpointLocatorState(const ::AsteriskSCF::BasicRoutingService::V1::EndpointLocatorStatePtr& item)
-            {
-                mImpl->mEndpointRegistry->removeEndpointLocator(item->key, ::Ice::Current());
-            }
-
-        }; // end method-local visitor def
-
-        // Create the visitor. Smart pointer will cleanup when this method exits. 
-        AsteriskSCF::BasicRoutingService::V1::RoutingStateItemVisitorPtr v = new visitor(this);
-
-        for (RoutingStateItemSeq::const_iterator item = items.begin(); item != items.end(); ++item)
-        {
-	        (*item)->visit(v);
-        }
-    }
-
-    void stateRemoved(const Ice::StringSeq& itemKeys, const Ice::Current& current)
-    {
-        lg(Error) << "Routing Service does not use key-based removes for state replication.";
-    }
-
-    void stateSet(const RoutingStateItemSeq& items, const Ice::Current& current)
-    {
-        // Method-local visitor class for handling new state. 
-
-	    class visitor : public AsteriskSCF::BasicRoutingService::V1::RoutingStateItemVisitor
-	    {
-	    public:
-	        visitor(RoutingStateReplicatorListenerPriv *impl, const Ice::Current& current)  
-                        :  mImpl(impl), mCurrent(current)
-	        {
-	        }
-
-	    private:
-	        RoutingStateReplicatorListenerPriv *mImpl;
-            const Ice::Current& mCurrent;
-
-            void visitRouteSessionOpStart(const ::AsteriskSCF::BasicRoutingService::V1::RouteSessionOpStartPtr& opState)
-            {
-                mImpl->mOperationReplicaCache->getRouteSessionCache()->cacheOperationState(opState);
-            }
-
-            void visitRouteSessionOpWaitLookupState(const ::AsteriskSCF::BasicRoutingService::V1::RouteSessionOpWaitLookupStatePtr& opState)
-            {
-                mImpl->mOperationReplicaCache->getRouteSessionCache()->cacheOperationState(opState);
-            }
-
-            void visitRouteSessionOpBridgingState(const ::AsteriskSCF::BasicRoutingService::V1::RouteSessionOpBridgingStatePtr& opState)
-            {
-                mImpl->mOperationReplicaCache->getRouteSessionCache()->cacheOperationState(opState);
-            }
-
-            void visitConnectBridgedSessionsWithDestinationOpStart(const ::AsteriskSCF::BasicRoutingService::V1::ConnectBridgedSessionsWithDestinationOpStartPtr& opState)
-            {
-                mImpl->mOperationReplicaCache->getConnectBridgedSessionsWithDestCache()->cacheOperationState(opState);
-            }
-
-            void visitConnectBridgedSessionsWithDestinationOpWaitLookupState(const ::AsteriskSCF::BasicRoutingService::V1::ConnectBridgedSessionsWithDestinationOpWaitLookupStatePtr& opState)
-            {
-                mImpl->mOperationReplicaCache->getConnectBridgedSessionsWithDestCache()->cacheOperationState(opState);
-            }
-
-            void visitConnectBridgedSessionsWithDestinationOpBridgingState(const ::AsteriskSCF::BasicRoutingService::V1::ConnectBridgedSessionsWithDestinationOpBridgingStatePtr& opState)
-            {
-                mImpl->mOperationReplicaCache->getConnectBridgedSessionsWithDestCache()->cacheOperationState(opState);
-            }
-
-            void visitEndpointLocatorState(const ::AsteriskSCF::BasicRoutingService::V1::EndpointLocatorStatePtr& item)
-            {
-                mImpl->mEndpointRegistry->addEndpointLocator(item->key, item->regExList, item->locator, mCurrent);
-            }
-
-        }; // end method-local visitor def
-
-        // Create the visitor. Smart pointer will cleanup when this method exits. 
-        AsteriskSCF::BasicRoutingService::V1::RoutingStateItemVisitorPtr v = new visitor(this, current);
-
-        for (RoutingStateItemSeq::const_iterator item = items.begin(); item != items.end(); ++item)
-        {
-	        (*item)->visit(v);
-        }
-    }
-
-    std::string mId;
-    EndpointRegistryPtr mEndpointRegistry;
-    boost::shared_ptr<OperationReplicaCache> mOperationReplicaCache;
-};
-
-RoutingStateReplicatorListenerImpl::RoutingStateReplicatorListenerImpl(const EndpointRegistryPtr& registry, const boost::shared_ptr<OperationReplicaCache>& opCache)
-    : mImpl(new RoutingStateReplicatorListenerPriv(registry, opCache)) 
-{
-}
-
-RoutingStateReplicatorListenerImpl::~RoutingStateReplicatorListenerImpl()
-{
-}
-
-void RoutingStateReplicatorListenerImpl::stateRemoved(const Ice::StringSeq& itemKeys, const Ice::Current& current)
-{
-    mImpl->stateRemoved(itemKeys, current);
-}
-
-void RoutingStateReplicatorListenerImpl::stateRemovedForItems(const RoutingStateItemSeq& items, const Ice::Current& current)
-{
-    mImpl->stateRemovedForItems(items, current);
-}
-
-void RoutingStateReplicatorListenerImpl::stateSet(const RoutingStateItemSeq& items, const Ice::Current& current)
-{
-    mImpl->stateSet(items, current);
-}
-
-bool RoutingStateReplicatorListenerImpl::operator==(RoutingStateReplicatorListenerImpl &rhs)
-{
-    return mImpl->mId == rhs.mImpl->mId;
-}
-
-};
-};
diff --git a/src/RoutingStateReplicatorListener.h~HEAD b/src/RoutingStateReplicatorListener.h~HEAD
deleted file mode 100644
index 61b8ea2..0000000
--- a/src/RoutingStateReplicatorListener.h~HEAD
+++ /dev/null
@@ -1,54 +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.
- */
-
-#pragma once
-
-#include <Ice/Ice.h>
-#include <boost/shared_ptr.hpp>
-
-#include <AsteriskSCF/StateReplicator.h>
-
-#include "BasicRoutingStateReplicationIf.h"
-#include "OperationReplicaCache.h"
-
-namespace AsteriskSCF
-{
-namespace BasicRoutingService
-{
-class RoutingStateReplicatorListenerPriv;
-
-/** 
- * Our RoutingStateReplicatorListener implementation. 
- * This object listens for updates from the state replicator when 
- * this service is in standby mode, and ensures that this instance of the
- * service has the latest dynamic state in case it is activated. 
- */
-class RoutingStateReplicatorListenerImpl : public AsteriskSCF::BasicRoutingService::V1::RoutingStateReplicatorListener
-{
-public:
-    RoutingStateReplicatorListenerImpl(const EndpointRegistryPtr& registry, const boost::shared_ptr<OperationReplicaCache>& opCache);
-    ~RoutingStateReplicatorListenerImpl();
-    void stateRemoved(const Ice::StringSeq&, const Ice::Current&);
-    void stateRemovedForItems(const AsteriskSCF::BasicRoutingService::V1::RoutingStateItemSeq&, const Ice::Current&);
-    void stateSet(const AsteriskSCF::BasicRoutingService::V1::RoutingStateItemSeq&, const Ice::Current&);
-    bool operator==(RoutingStateReplicatorListenerImpl &rhs);
-
-private:
-    boost::shared_ptr<RoutingStateReplicatorListenerPriv> mImpl;
-};
-
-};
-};

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


-- 
asterisk-scf/integration/routing.git



More information about the asterisk-scf-commits mailing list