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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Nov 2 16:14:55 CDT 2010


branch "master" has been updated
       via  68de66ffb4c487d2e49dbd0ea048f50a4d1b0a08 (commit)
      from  91710e91bb1c7e95c7bf880438cb178728c35893 (commit)

Summary of changes:
 src/ServiceLocatorManagement.cpp |   29 +++++++++++++++++++++++++++++
 src/ServiceLocatorManagement.h   |    4 +++-
 src/ServiceManagement.cpp        |   13 +++++++++++++
 src/ServiceManagement.h          |    3 ++-
 4 files changed, 47 insertions(+), 2 deletions(-)


- Log -----------------------------------------------------------------
commit 68de66ffb4c487d2e49dbd0ea048f50a4d1b0a08
Author: David M. Lee <dlee at digium.com>
Date:   Thu Oct 28 09:01:49 2010 -0500

    New operations for getting the status of registered services.

diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index e057f92..0a3b2c8 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -190,6 +190,35 @@ ServiceManagementPrx ServiceLocatorManagementImpl::addService(const Ice::ObjectP
    return new_service->getServiceManagementPrx();
 }
 
+ServiceInfoSeq ServiceLocatorManagementImpl::getServices(const ::Ice::Current&) const
+{
+   boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
+   ServiceInfoSeq r;
+   for (std::vector<ServiceManagementImplPtr>::const_iterator i = mImpl->mServices.begin();
+        i != mImpl->mServices.end();
+        ++i)
+   {
+       ServiceInfo v = {(*i)->getGuid(), (*i)->getServiceManagementPrx(), (*i)->getStatus(), (*i)->getService()};
+      r.push_back(v);
+   }
+   return r;
+}
+
+ServiceInfo ServiceLocatorManagementImpl::getService(const std::string &guid, const ::Ice::Current&) const
+{
+   boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
+   for (std::vector<ServiceManagementImplPtr>::const_iterator i = mImpl->mServices.begin();
+        i != mImpl->mServices.end();
+        ++i)
+   {
+      if (guid == (*i)->getGuid()) {
+         ServiceInfo r = {(*i)->getGuid(), (*i)->getServiceManagementPrx(), (*i)->getStatus(), (*i)->getService()};
+         return r;
+      }
+   }
+   throw ServiceNotFound();
+}
+
 /**
  * Implementation of the addCompare method as defined in service_locator.ice
  */
diff --git a/src/ServiceLocatorManagement.h b/src/ServiceLocatorManagement.h
index 77ebf17..8b118df 100644
--- a/src/ServiceLocatorManagement.h
+++ b/src/ServiceLocatorManagement.h
@@ -43,7 +43,7 @@ class ServiceLocatorManagementImplPriv;
 class ServiceLocatorManagementImpl : public AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagement
 {
 public:
-    ServiceLocatorManagementImpl(const Ice::ObjectAdapterPtr& adapter, 
+    ServiceLocatorManagementImpl(const Ice::ObjectAdapterPtr& adapter,
       const AsteriskSCF::System::Discovery::EventsPrx& serviceDiscoveryTopic);
     Ice::ObjectPrx locate(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
     Ice::ObjectProxySeq locateAll(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
@@ -52,6 +52,8 @@ public:
     // AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagement interface.
     //
     AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx addService(const Ice::ObjectPrx&, const std::string&, const Ice::Current&);
+    AsteriskSCF::Core::Discovery::V1::ServiceInfoSeq getServices(const ::Ice::Current&) const;
+    AsteriskSCF::Core::Discovery::V1::ServiceInfo getService(const std::string &, const ::Ice::Current&) const;
     void addCompare(const std::string&, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsComparePrx&, const Ice::Current&);
     void removeCompare(const std::string&, const Ice::Current&);
 
diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index 08bc831..af4c873 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -291,6 +291,19 @@ void ServiceManagementImpl::unsuspend(const Ice::Current&)
     }
 }
 
+ServiceStatus ServiceManagementImpl::getStatus() const
+{
+    boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
+    if (mImpl->mSuspended)
+    {
+        return Suspended;
+    }
+    else
+    {
+        return Active;
+    }
+}
+
 /**
  * Implementation of the unregister method as defined in service_locator.ice
  */
diff --git a/src/ServiceManagement.h b/src/ServiceManagement.h
index 46f2d36..bf4fd5f 100644
--- a/src/ServiceManagement.h
+++ b/src/ServiceManagement.h
@@ -43,12 +43,13 @@ public:
     void suspend(const Ice::Current&);
     void unsuspend(const Ice::Current&);
     void unregister(const Ice::Current&);
+    AsteriskSCF::Core::Discovery::V1::ServiceStatus getStatus(const Ice::Current&) const { return getStatus(); }
 
     Ice::ObjectPrx getService();
     AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx getServiceManagementPrx();
     bool isSupported(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
     const std::string &getGuid() const;
-
+    AsteriskSCF::Core::Discovery::V1::ServiceStatus getStatus() const;
 private:
     /**
      * Private implementation data for ServiceManagementImpl.

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


-- 
asterisk-scf/integration/servicediscovery.git



More information about the asterisk-scf-commits mailing list