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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu May 3 14:45:49 CDT 2012


branch "retry_deux" has been updated
       via  3f9377b7ac071b864cce15fc6be5a02dc8a31ec7 (commit)
      from  955ebd54eed532aecd7465a462319303487f796e (commit)

Summary of changes:
 src/ServiceLocator.cpp              |   47 +++++++++++++++++++++-------------
 src/ServiceLocatorStateListener.cpp |    4 +++
 src/ServiceManagement.cpp           |    5 +++
 3 files changed, 38 insertions(+), 18 deletions(-)


- Log -----------------------------------------------------------------
commit 3f9377b7ac071b864cce15fc6be5a02dc8a31ec7
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Thu May 3 14:43:54 2012 -0500

    Moved the management adapter activation so that standby mode gets activated, and corrected the naming and thread pool size checks for the adapters. Also cleaned up some of the retry logic (missing setCompleted() and rethrow of exceptions.)

diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index 1f6ac35..2a647ed 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -83,7 +83,8 @@ private:
     bool mStandalone;
     Ice::CommunicatorPtr mCommunicator;
     string mBackplaneAdapterName;
-    string mServiceAdapterName;
+    string mDiscoveryAdapterName;
+    string mManagementAdapterName;
 };
 
 /**
@@ -147,7 +148,7 @@ public:
         catch (const std::exception& e)
         {
             data->setException(e);
-            throw e;
+            throw;
         }
         catch (...)
         {
@@ -196,7 +197,7 @@ public:
         catch (const std::exception& e)
         {
             data->setException(e);
-            throw e;
+            throw;
         }
         catch (...)
         {
@@ -304,12 +305,24 @@ void ServiceLocatorApp::verifyProperties()
     string strDefaultSize = boost::lexical_cast<std::string>(defaultSize);
 
     Ice::Int defaultPoolSize = mCommunicator->getProperties()->getPropertyAsIntWithDefault("Ice.ThreadPool.Server.Size", 0);
-    if (mCommunicator->getProperties()->getPropertyAsIntWithDefault(mServiceAdapterName + ".ThreadPool.Size", 0) < defaultSize)
+    
+    // NOTE: The ServiceLocator, unlike other components, uses two adapters for its primary services: management, and discovery. 
+
+    if (mCommunicator->getProperties()->getPropertyAsIntWithDefault(mDiscoveryAdapterName + ".ThreadPool.Size", 0) < defaultSize)
+    {
+        if (defaultPoolSize < defaultSize)
+        {
+            lg(Info) << "Configured thread pool size for " << mDiscoveryAdapterName + " is too small, defaulting to " << strDefaultSize;
+            mCommunicator->getProperties()->setProperty(mDiscoveryAdapterName + ".ThreadPool.Size", strDefaultSize);
+        }
+    }
+
+    if (mCommunicator->getProperties()->getPropertyAsIntWithDefault(mManagementAdapterName + ".ThreadPool.Size", 0) < defaultSize)
     {
         if (defaultPoolSize < defaultSize)
         {
-            lg(Info) << "Configured thread pool size for " << mServiceAdapterName + " is too small, defaulting to " << strDefaultSize;
-            mCommunicator->getProperties()->setProperty(mServiceAdapterName + ".ThreadPool.Size", strDefaultSize);
+            lg(Info) << "Configured thread pool size for " << mManagementAdapterName + " is too small, defaulting to " << strDefaultSize;
+            mCommunicator->getProperties()->setProperty(mManagementAdapterName + ".ThreadPool.Size", strDefaultSize);
         }
     }
 
@@ -322,23 +335,22 @@ void ServiceLocatorApp::verifyProperties()
         }
     }
 
-    defaultPoolSize = mCommunicator->getProperties()->getPropertyAsIntWithDefault("Ice.ThreadPool.Client.Size", 0);
-    if (defaultPoolSize < defaultSize)
+    int clientSize = mCommunicator->getProperties()->getPropertyAsIntWithDefault("Ice.ThreadPool.Client.Size", 0);
+    if (clientSize < defaultSize)
     {
         lg(Warning) << "Client thread pool size of " << defaultPoolSize << " is too small! Set to " << strDefaultSize << " or greater.";
         assert(false);
     }
-
 }
 
-
 void ServiceLocatorApp::start(const string& appName, const Ice::CommunicatorPtr& communicator,
     const Ice::StringSeq&)
 {
     mCommunicator = communicator;
 
     mBackplaneAdapterName = appName + ".BackplaneAdapter";
-    mServiceAdapterName = appName + ".Management.ServiceAdapter";
+    mDiscoveryAdapterName = appName + ".Locator.ServiceAdapter";
+    mManagementAdapterName = appName + ".Management.ServiceAdapter";
     verifyProperties();
 
     mIceStorm = new AsteriskSCF::CollocatedIceStorm::CollocatedIceStorm(appName, communicator->getProperties());
@@ -405,8 +417,8 @@ void ServiceLocatorApp::start(const string& appName, const Ice::CommunicatorPtr&
      * management may want to be protected so arbitrary people can't inject bad services
      * into the infrastructure while discovery as a read only function may be allowed to all.
      */
-    mManagementAdapter = communicator->createObjectAdapterWithEndpoints(mServiceAdapterName,
-        communicator->getProperties()->getPropertyWithDefault(mServiceAdapterName + ".Endpoints", "tcp -p 4412"));
+    mManagementAdapter = communicator->createObjectAdapterWithEndpoints(mManagementAdapterName,
+        communicator->getProperties()->getPropertyWithDefault(mManagementAdapterName + ".Endpoints", "tcp -p 4412"));
 
     mLocatorServiceManagement =
         new ServiceLocatorManagementImpl(mManagementAdapter, serviceDiscoveryTopic, mReplicaService);
@@ -454,9 +466,8 @@ void ServiceLocatorApp::start(const string& appName, const Ice::CommunicatorPtr&
 
     lg(Info) << "Publishing service discovery management.";
 
-    string locatorAdapterName = appName + ".Locator.ServiceAdapter";
-    mDiscoveryAdapter = communicator->createObjectAdapterWithEndpoints(locatorAdapterName,
-        communicator->getProperties()->getPropertyWithDefault(locatorAdapterName + ".Endpoints", "tcp -p 4411"));
+    mDiscoveryAdapter = communicator->createObjectAdapterWithEndpoints(mDiscoveryAdapterName,
+        communicator->getProperties()->getPropertyWithDefault(mDiscoveryAdapterName + ".Endpoints", "tcp -p 4411"));
 
     ServiceLocatorPtr locatorService = new ServiceLocatorImpl(mLocatorServiceManagement);
 
@@ -468,6 +479,8 @@ void ServiceLocatorApp::start(const string& appName, const Ice::CommunicatorPtr&
 
     replicaImpl->setServiceLocatorApp(this);
 
+    mDiscoveryAdapter->activate();
+
     // Make our IceStorm topic manager available to all if we are the active service. This is because by adding it
     // we will replicate it.
     if (mReplicaService->isActive() == true)
@@ -479,8 +492,6 @@ void ServiceLocatorApp::start(const string& appName, const Ice::CommunicatorPtr&
 
     onStandby();
     lg(Info) << "In standby mode.";
-
-    mDiscoveryAdapter->activate();
 }
 
 void ServiceLocatorApp::activated()
diff --git a/src/ServiceLocatorStateListener.cpp b/src/ServiceLocatorStateListener.cpp
index fd27b06..498d313 100644
--- a/src/ServiceLocatorStateListener.cpp
+++ b/src/ServiceLocatorStateListener.cpp
@@ -195,12 +195,16 @@ public:
         catch (const std::exception& e)
         {
             data->setException(e);
+            throw;
         }
         catch (...)
         {
             assert(false);
             data->setException();
+            throw;
         }
+
+        data->setCompleted();
     }
 
     const std::string& getId() const { return mId; }
diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index 493238a..19bc1b7 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -431,11 +431,13 @@ void ServiceManagementImpl::suspend(const AsteriskSCF::System::V1::OperationCont
     catch (const std::exception& e)
     {
         data->setException(e);
+        throw;
     }
     catch (...)
     {
         assert(false);
         data->setException();
+        throw;
     }
 }
 
@@ -471,12 +473,15 @@ void ServiceManagementImpl::unsuspend(const AsteriskSCF::System::V1::OperationCo
     catch (const std::exception& e)
     {
         data->setException(e);
+        throw;
     }
     catch (...)
     {
         assert(false);
         data->setException();
+        throw;
     }
+    data->setCompleted();
 }
 
 ServiceStatus ServiceManagementImpl::getStatus() const

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


-- 
asterisk-scf/integration/servicediscovery.git



More information about the asterisk-scf-commits mailing list