[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 Sep 14 08:22:10 CDT 2010


branch "master" has been updated
       via  21056247f2b8e458fd992aff52c02846d4161969 (commit)
      from  63f1ad59f26d8e51de9d484ffddfe46e0cb0ce93 (commit)

Summary of changes:
 src/ServiceLocator.cpp           |   61 ++++++++++++++++++++------------------
 src/ServiceLocatorManagement.cpp |    7 +++-
 src/ServiceManagement.cpp        |   20 ++++++++++--
 3 files changed, 53 insertions(+), 35 deletions(-)


- Log -----------------------------------------------------------------
commit 21056247f2b8e458fd992aff52c02846d4161969
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Sep 14 10:28:13 2010 -0300

    Make IceStorm optional for running the service locator.

diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index 27d02b4..1a7d1b7 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -86,40 +86,43 @@ int ServiceLocatorApp::run(int argc, char* argv[])
 	/* Talk to the topic manager to either create or get the service discovery topic, configured or default */
 	IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(communicator()->propertyToProxy("TopicManager.Proxy"));
 
-	if (!topicManager)
-	{
-		cerr << "Failed to get a proxy to the topic manager." << endl;
-		return 0;
-	}
+	EventsPrx service_discovery_topic;
 
-	Ice::PropertiesPtr props = communicator()->getProperties();
-	string topicName = props->getProperty("ServiceLocator.TopicName");
-
-	if (topicName.empty())
+	if (topicManager)
 	{
-		topicName = TOPIC;
+	   Ice::PropertiesPtr props = communicator()->getProperties();
+	   string topicName = props->getProperty("ServiceLocator.TopicName");
+
+	   if (topicName.empty())
+	   {
+	      topicName = TOPIC;
+	   }
+
+	   IceStorm::TopicPrx topic;
+	   try
+	   {
+	      topic = topicManager->retrieve(topicName);
+	   }
+	   catch (const IceStorm::NoSuchTopic&)
+	   {
+	      try
+	      {
+		 topic = topicManager->create(topicName);
+	      }
+	      catch (const IceStorm::TopicExists&)
+	      {
+		 cerr << "Oh snap! Race condition creating topic, aborting" << endl;
+		 return 0;
+	      }
+	      cout << "[INFO] Created service discovery event topic" << endl;
+	   }
+
+	   service_discovery_topic = EventsPrx::uncheckedCast(topic->getPublisher());
 	}
-
-	IceStorm::TopicPrx topic;
-	try
+	else
 	{
-		topic = topicManager->retrieve(topicName);
+	   cout << "[INFO] IceStorm topic manager proxy not present, events disabled." << endl;
 	}
-	catch (const IceStorm::NoSuchTopic&)
-	{
-		try
-		{
-			topic = topicManager->create(topicName);
-		}
-		catch (const IceStorm::TopicExists&)
-		{
-			cerr << "Oh snap! Race condition creating topic, aborting" << endl;
-			return 0;
-		}
-		cout << "[INFO] Created service discovery event topic" << endl;
-	}
-
-	EventsPrx service_discovery_topic = EventsPrx::uncheckedCast(topic->getPublisher());
 
 	/* Management and discovery use separate adapters to provide a level of security, 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.
diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index f0a1d26..b32cd80 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -166,7 +166,10 @@ void ServiceLocatorManagementImpl::addCompare(const string& guid, const ServiceL
 		throw DuplicateCompare();
 	}
 
-	mImpl->mLocatorTopic->comparisonRegistered(guid);
+	if (mImpl->mLocatorTopic)
+	{
+	   mImpl->mLocatorTopic->comparisonRegistered(guid);
+	}
 };
 
 /**
@@ -181,7 +184,7 @@ void ServiceLocatorManagementImpl::removeCompare(const string& guid, const Ice::
 	{
 		throw CompareNotFound();
 	}
-	else
+	else if (mImpl->mLocatorTopic)
 	{
 		mImpl->mLocatorTopic->comparisonUnregistered(guid);
 	}
diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index de7da38..722f8dd 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -58,7 +58,10 @@ public:
 		mSuspended(false), mManagement(management), mService(service), mAdapter(adapter), mLocatorTopic(service_discovery_topic), mGuid(guid)
 		{
 			mManagementPrx = ServiceManagementPrx::uncheckedCast(mAdapter->addWithUUID(impl));
-			mLocatorTopic->serviceRegistered(mGuid);
+			if (mLocatorTopic)
+			{
+			   mLocatorTopic->serviceRegistered(mGuid);
+			}
 		}
 
         /**
@@ -221,7 +224,10 @@ void ServiceManagementImpl::suspend(const Ice::Current&)
 
 	mImpl->mSuspended = true;
 
-	mImpl->mLocatorTopic->serviceSuspended(mImpl->mGuid);
+	if (mImpl->mLocatorTopic)
+	{
+	   mImpl->mLocatorTopic->serviceSuspended(mImpl->mGuid);
+	}
 }
 
 /**
@@ -233,7 +239,10 @@ void ServiceManagementImpl::unsuspend(const Ice::Current&)
 
 	mImpl->mSuspended = false;
 
-	mImpl->mLocatorTopic->serviceUnsuspended(mImpl->mGuid);
+	if (mImpl->mLocatorTopic)
+	{
+	   mImpl->mLocatorTopic->serviceUnsuspended(mImpl->mGuid);
+	}
 }
 
 /**
@@ -249,7 +258,10 @@ void ServiceManagementImpl::unregister(const Ice::Current&)
 
 	mImpl->mManagement->removeService(this);
 
-	mImpl->mLocatorTopic->serviceUnregistered(mImpl->mGuid);
+	if (mImpl->mLocatorTopic)
+	{
+	   mImpl->mLocatorTopic->serviceUnregistered(mImpl->mGuid);
+	}
 }
 
 

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


-- 
asterisk-scf/integration/servicediscovery.git



More information about the asterisk-scf-commits mailing list