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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Jul 19 17:14:30 CDT 2011


branch "locate-with-id" has been updated
       via  38f68cf4da53fcb7ac9f8c9fdf1ed7aa72672a6b (commit)
       via  4a9b45cc418ed722297eff24e6d8068fd2f167c4 (commit)
      from  f7f94776ae4a9fe97b66cc0d732682d6390c69b8 (commit)

Summary of changes:
 src/ServiceManagement.cpp |   68 ++++++++++++++++++++++++++++----------------
 1 files changed, 43 insertions(+), 25 deletions(-)


- Log -----------------------------------------------------------------
commit 38f68cf4da53fcb7ac9f8c9fdf1ed7aa72672a6b
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue Jul 19 17:13:12 2011 -0500

    Let the caught exceptions added during in a debug session continue to throw as they did before.
    Logging is still useful.

diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index 1da8141..2ec8483 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -448,10 +448,12 @@ void ServiceManagementImpl::unregister(const Ice::Current&)
     catch(const std::exception& e)
     {
         lg(Error) << BOOST_CURRENT_FUNCTION << " : " << e.what();
+	throw;
     }
     catch(...)
     {
         lg(Error) << BOOST_CURRENT_FUNCTION << " : " << "Unknown exception.";
+	throw;
     }
 }
 

commit 4a9b45cc418ed722297eff24e6d8068fd2f167c4
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue Jul 19 17:11:23 2011 -0500

    Incorporated review feedback, replaced tabs, general cleanup.

diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index 35405e6..1da8141 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -55,21 +55,21 @@ public:
     ServiceLocatorParamsSpec(const ServiceLocatorParamsPtr& params,
         const std::string& compareGuid,
         ServiceLocatorManagementImplPtr management,
-	ServiceLocatorServiceStateItemPtr serviceState)
+        ServiceLocatorServiceStateItemPtr serviceState)
         :
-	mStateItem(new ServiceLocatorParamsStateItem()),
+        mStateItem(new ServiceLocatorParamsStateItem()),
         mManagement(management)
     {
-	mStateItem->key = IceUtil::generateUUID();
-	mStateItem->serviceKey = serviceState->key;
-	mStateItem->params = params;
-	mStateItem->compareGuid = compareGuid;
-	mManagement->replicateState(mStateItem);
+        mStateItem->key = IceUtil::generateUUID();
+        mStateItem->serviceKey = serviceState->key;
+        mStateItem->params = params;
+        mStateItem->compareGuid = compareGuid;
+        mManagement->replicateState(mStateItem);
     }
 
     ~ServiceLocatorParamsSpec()
     {
-	mManagement->removeState(mStateItem);
+        mManagement->removeState(mStateItem);
     }
 
     bool isSupported(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&, const IsSupportedCallbackPtr&);
@@ -95,20 +95,20 @@ public:
     ServiceManagementImplPriv(ServiceManagementImpl* impl, ServiceLocatorManagementImplPtr management,
         const Ice::ObjectPrx& service, const Ice::ObjectAdapterPtr& adapter, const AsteriskSCF::System::Discovery::EventsPrx& serviceDiscoveryTopic,
         const string& guid, const Ice::Identity& identity) :
-	mStateItem(new ServiceLocatorServiceStateItem()),
+        mStateItem(new ServiceLocatorServiceStateItem()),
         mManagement(management), mAdapter(adapter), mLocatorTopic(serviceDiscoveryTopic)
     {
-	mStateItem->key = IceUtil::generateUUID();
-	mStateItem->suspended = false;
-	mStateItem->service = service;
-	mStateItem->guid = guid;
-	mManagementPrx = ServiceManagementPrx::uncheckedCast(mAdapter->add(impl, identity));
-	mStateItem->managementIdentity = identity;
+        mStateItem->key = IceUtil::generateUUID();
+        mStateItem->suspended = false;
+        mStateItem->service = service;
+        mStateItem->guid = guid;
+        mManagementPrx = ServiceManagementPrx::uncheckedCast(mAdapter->add(impl, identity));
+        mStateItem->managementIdentity = identity;
         if (mLocatorTopic)
         {
             mLocatorTopic->serviceRegistered(guid);
         }
-	mManagement->replicateState(mStateItem);
+        mManagement->replicateState(mStateItem);
     }
 
     /**
@@ -269,6 +269,8 @@ void ServiceManagementImpl::isSupported(const ServiceLocatorParamsPtr& params, c
     {
         if ((*spec)->isSupported(params, myCallback))
         {
+            // If we get here, a match was found without needing to call an external comparator. 
+            // We are done. 
             break;
         }
     }
@@ -300,6 +302,7 @@ bool ServiceLocatorParamsSpec::isSupported(const ServiceLocatorParamsPtr& params
         if (mStateItem->params->category != params->category)
         {
             lg(Debug) << "  ...isSupported" << debugPrintParams(params) + " = false (different categories)\n";
+
             callback->result(false);
             return false;
         }
@@ -324,8 +327,9 @@ bool ServiceLocatorParamsSpec::isSupported(const ServiceLocatorParamsPtr& params
     // Wrong service?
     if (mStateItem->params->service != params->service)
     {
+        lg(Debug) << "  ...isSupported" << debugPrintParams(params) + " = false (different services)\n";
         callback->result(false);
-        return true;
+        return false;
     }
 
     // Is this query for a specific instance?
@@ -334,6 +338,7 @@ bool ServiceLocatorParamsSpec::isSupported(const ServiceLocatorParamsPtr& params
         // Wrong instance?
         if (mStateItem->params->id != params->id)
         {
+            lg(Debug) << "  ...isSupported" << debugPrintParams(params) + " = false (different id)\n";
             callback->result(false);
             return false;
         }
@@ -375,7 +380,7 @@ void ServiceManagementImpl::suspend(const Ice::Current&)
     {
         lg(Info) << "Suspending " << mImpl->mStateItem->guid << " " << mImpl->mStateItem->service->ice_toString();
         mImpl->mStateItem->suspended = true;
-	mImpl->mManagement->replicateState(mImpl->mStateItem);
+        mImpl->mManagement->replicateState(mImpl->mStateItem);
     }
 
     if (mImpl->mLocatorTopic)
@@ -395,7 +400,7 @@ void ServiceManagementImpl::unsuspend(const Ice::Current&)
     {
         lg(Info) << "Un-suspending " << mImpl->mStateItem->guid << " " << mImpl->mStateItem->service->ice_toString();
         mImpl->mStateItem->suspended = false;
-	mImpl->mManagement->replicateState(mImpl->mStateItem);
+        mImpl->mManagement->replicateState(mImpl->mStateItem);
     }
 
     if (mImpl->mLocatorTopic)
@@ -425,17 +430,28 @@ void ServiceManagementImpl::unregister(const Ice::Current&)
     /* You'll notice no lock here. That's because we aren't actually modifying any internal state that should
      * be protected, and if we did lock here there is a chance for a deadlock which is super sad.
      */
-    lg(Info) << "Un-register " << mImpl->mStateItem->guid << " " << mImpl->mStateItem->service->ice_toString();
+    try
+    {
+        lg(Info) << "Un-register " << mImpl->mStateItem->guid << " " << mImpl->mStateItem->service->ice_toString();
 
-    mImpl->mManagement->removeState(mImpl->mStateItem);
+        mImpl->mManagement->removeState(mImpl->mStateItem);
 
-    mImpl->mAdapter->remove(mImpl->mManagementPrx->ice_getIdentity());
+        mImpl->mAdapter->remove(mImpl->mManagementPrx->ice_getIdentity());
 
-    mImpl->mManagement->removeService(this);
+        mImpl->mManagement->removeService(this);
 
-    if (mImpl->mLocatorTopic)
+        if (mImpl->mLocatorTopic)
+        {
+            mImpl->mLocatorTopic->serviceUnregistered(mImpl->mStateItem->guid);
+        }
+    }
+    catch(const std::exception& e)
+    {
+        lg(Error) << BOOST_CURRENT_FUNCTION << " : " << e.what();
+    }
+    catch(...)
     {
-        mImpl->mLocatorTopic->serviceUnregistered(mImpl->mStateItem->guid);
+        lg(Error) << BOOST_CURRENT_FUNCTION << " : " << "Unknown exception.";
     }
 }
 

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


-- 
asterisk-scf/integration/servicediscovery.git



More information about the asterisk-scf-commits mailing list