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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Sun Dec 19 14:08:45 UTC 2010


branch "replication" has been updated
       via  4e549b933acc135b055f0cdf41d1d897e710c7a4 (commit)
       via  a6b20816ebd50804bdbad34c79414c91f510e3be (commit)
       via  6eb9f297eca42e9da2b92b2e6d4aaa065fe8d886 (commit)
       via  59b3159a618b24ed01ab9e7ff8597f3f0d99ac67 (commit)
       via  94c03fc58807efd9f8d330d039925cf3a2f332de (commit)
      from  f7bf1b966c3652008c3e03ec0529e1b99a3f920c (commit)

Summary of changes:
 config/test_service_locator.config                 |    7 +++++++
 ...config => test_service_locator_listener.config} |    7 +++++++
 config/test_servicelocator_state_replicator.conf   |   11 +++++++++++
 src/ServiceLocator.cpp                             |    2 +-
 src/ServiceManagement.cpp                          |   19 +++++++++++--------
 5 files changed, 37 insertions(+), 9 deletions(-)
 copy config/{test_service_locator.config => test_service_locator_listener.config} (86%)
 create mode 100644 config/test_servicelocator_state_replicator.conf


- Log -----------------------------------------------------------------
commit 4e549b933acc135b055f0cdf41d1d897e710c7a4
Author: Joshua Colp <jcolp at digium.com>
Date:   Sun Dec 19 10:01:31 2010 -0400

    Be more descriptive in debug messages about why an isSupported call is true or false.

diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index ce6e5b3..ff8c595 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -242,7 +242,7 @@ void ServiceManagementImpl::isSupported(const ServiceLocatorParamsPtr& params, c
      */
     if (mImpl->mStateItem->mSuspended)
     {
-        lg(Debug) << "  ...isSupported(" << params->category << ") = false\n";
+        lg(Debug) << "  ...isSupported(" << params->category << ") = false (suspended)\n";
         callback->result(false);
         return;
     }
@@ -279,14 +279,14 @@ void ServiceLocatorParamsSpec::isSupported(const ServiceLocatorParamsPtr& params
     // everything/anything, so give it to them
     if (params->category.empty())
     {
-        lg(Debug) << "  ...isSupported(" << params->category << ") = true\n";
+        lg(Debug) << "  ...isSupported(" << params->category << ") = true (empty category)\n";
         callback->result(true);
     }
     /* This is just a simple comparison that acts as a preliminary, and
      * perhaps final, check */
     else if (mStateItem->mParams->category != params->category)
     {
-        lg(Debug) << "  ...isSupported(" << params->category << ") = false\n";
+        lg(Debug) << "  ...isSupported(" << params->category << ") = false (different categories)\n";
         callback->result(false);
     }
     /* If a comparator was provided then yield to it for a final yay or nay */

commit a6b20816ebd50804bdbad34c79414c91f510e3be
Author: Joshua Colp <jcolp at digium.com>
Date:   Sun Dec 19 10:00:54 2010 -0400

    Use a boost::shared_ptr so the parameters state item does not get prematurely removed.

diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index 8e548fb..ce6e5b3 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -19,6 +19,7 @@
 
 #include <boost/thread.hpp>
 #include <boost/thread/shared_mutex.hpp>
+#include <boost/shared_ptr.hpp>
 
 #include "Core/Discovery/ServiceLocatorIf.h"
 #include "Core/Discovery/ServiceLocatorEventsIf.h"
@@ -135,7 +136,7 @@ public:
     /**
      * A vector of locator parameters that this service supports.
      */
-    std::vector<ServiceLocatorParamsSpec> mSupportedLocatorParams;
+    std::vector< boost::shared_ptr<ServiceLocatorParamsSpec> > mSupportedLocatorParams;
 
     /**
      * A proxy that can be used to publish events to the service locator topic.
@@ -249,12 +250,12 @@ void ServiceManagementImpl::isSupported(const ServiceLocatorParamsPtr& params, c
     IsSupportedCallbackPtr myCallback = new CountedIsSupported(
         callback, mImpl->mSupportedLocatorParams.size());
 
-    for (vector<ServiceLocatorParamsSpec>::iterator
+    for (vector<boost::shared_ptr<ServiceLocatorParamsSpec>>::iterator
              spec = mImpl->mSupportedLocatorParams.begin();
          spec != mImpl->mSupportedLocatorParams.end();
          ++spec)
     {
-        spec->isSupported(params, myCallback);
+        (*spec)->isSupported(params, myCallback);
     }
 }
 
@@ -307,7 +308,7 @@ void ServiceManagementImpl::addLocatorParams(const ServiceLocatorParamsPtr& para
 {
     boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
 
-    ServiceLocatorParamsSpec spec(params, compareGuid, mImpl->mManagement, mImpl->mStateItem);
+    boost::shared_ptr<ServiceLocatorParamsSpec> spec(new ServiceLocatorParamsSpec(params, compareGuid, mImpl->mManagement, mImpl->mStateItem));
 
     mImpl->mSupportedLocatorParams.push_back(spec);
 }

commit 6eb9f297eca42e9da2b92b2e6d4aaa065fe8d886
Author: Joshua Colp <jcolp at digium.com>
Date:   Sun Dec 19 09:54:19 2010 -0400

    Pass the service state item into the parameters spec so the key can be copied.

diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index c0d17b7..8e548fb 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -50,12 +50,14 @@ class ServiceLocatorParamsSpec
 public:
     ServiceLocatorParamsSpec(const ServiceLocatorParamsPtr& params,
         const std::string& compareGuid,
-        ServiceLocatorManagementImplPtr management)
+        ServiceLocatorManagementImplPtr management,
+	ServiceLocatorServiceStateItemPtr serviceState)
         :
 	mStateItem(new ServiceLocatorParamsStateItem()),
         mManagement(management)
     {
 	mStateItem->key = IceUtil::generateUUID();
+	mStateItem->mServiceKey = serviceState->key;
 	mStateItem->mParams = params;
 	mStateItem->mCompareGuid = compareGuid;
 	mManagement->replicateState(0, mStateItem, 0);
@@ -305,7 +307,7 @@ void ServiceManagementImpl::addLocatorParams(const ServiceLocatorParamsPtr& para
 {
     boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
 
-    ServiceLocatorParamsSpec spec(params, compareGuid, mImpl->mManagement);
+    ServiceLocatorParamsSpec spec(params, compareGuid, mImpl->mManagement, mImpl->mStateItem);
 
     mImpl->mSupportedLocatorParams.push_back(spec);
 }

commit 59b3159a618b24ed01ab9e7ff8597f3f0d99ac67
Author: Joshua Colp <jcolp at digium.com>
Date:   Sun Dec 19 09:10:11 2010 -0400

    Fix a race condition where it was possible for the service locator to think it was active, thus replicating to itself for a small period of time.

diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index 0e2535d..a397676 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -256,8 +256,8 @@ void ServiceLocatorApp::start(const string& name, const Ice::CommunicatorPtr& co
 
         if (communicator->getProperties()->getPropertyWithDefault("ServiceLocatorStateReplicatorListener", "no") == "yes")
         {
+	    mReplicaService->standby();
             mStateReplicator->addListener(mReplicatorListenerProxy);
-            mReplicaService->standby();
             lg(Info) << "Operating as a standby replica." << endl;
         }
         else

commit 94c03fc58807efd9f8d330d039925cf3a2f332de
Author: Joshua Colp <jcolp at digium.com>
Date:   Sun Dec 19 09:09:31 2010 -0400

    Update configuration files and add new ones for state replicator.

diff --git a/config/test_service_locator.config b/config/test_service_locator.config
index d058ee6..2ad533f 100644
--- a/config/test_service_locator.config
+++ b/config/test_service_locator.config
@@ -47,10 +47,17 @@ AsteriskSCFIceStorm.Flush.Timeout=2000
 # Test endpoints for the service locator management adapter
 ServiceLocatorManagementAdapter.Endpoints=tcp -p 4422
 
+# Test endpoints for the service locator local adapter
+ServiceLocatorLocalAdapter.Endpoints=tcp -p 4412
+
 # Test endpoints for the service locator adapter
 ServiceLocatorAdapter.Endpoints=tcp -p 4411
 LocatorService.Proxy=LocatorService:tcp -p 4411
 
+ServiceLocator.StateReplicator.Proxy=ServiceLocatorStateReplicatorService:tcp -p 4413
+
+ServiceLocatorStateReplicatorListener=no
+
 # Test endpoints for IceStorm
 TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:default -p 10000
 
diff --git a/config/test_service_locator.config b/config/test_service_locator_listener.config
similarity index 86%
copy from config/test_service_locator.config
copy to config/test_service_locator_listener.config
index d058ee6..12f1482 100644
--- a/config/test_service_locator.config
+++ b/config/test_service_locator_listener.config
@@ -47,10 +47,17 @@ AsteriskSCFIceStorm.Flush.Timeout=2000
 # Test endpoints for the service locator management adapter
 ServiceLocatorManagementAdapter.Endpoints=tcp -p 4422
 
+# Test endpoints for the service locator local adapter
+ServiceLocatorLocalAdapter.Endpoints=tcp -p 4412
+
 # Test endpoints for the service locator adapter
 ServiceLocatorAdapter.Endpoints=tcp -p 4411
 LocatorService.Proxy=LocatorService:tcp -p 4411
 
+ServiceLocator.StateReplicator.Proxy=ServiceLocatorStateReplicatorService:tcp -p 4413
+
+ServiceLocatorStateReplicatorListener=yes
+
 # Test endpoints for IceStorm
 TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:default -p 10000
 
diff --git a/config/test_servicelocator_state_replicator.conf b/config/test_servicelocator_state_replicator.conf
new file mode 100644
index 0000000..98a48d4
--- /dev/null
+++ b/config/test_servicelocator_state_replicator.conf
@@ -0,0 +1,11 @@
+# Adapter parameters for this component
+ServiceLocatorStateReplicator.Endpoints=tcp -p 4413:udp -p 4413
+ServiceLocatorStateReplicator.ThreadPool.Size=4
+
+# A proxy to the IceStorm topic manager
+TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:default -p 10000
+
+LocatorService.Proxy=LocatorService:tcp -p 4411
+
+IceBox.InheritProperties=1
+IceBox.Service.ServiceLocatorStateReplicator=ServiceLocatorStateReplicator:create

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


-- 
asterisk-scf/integration/servicediscovery.git



More information about the asterisk-scf-commits mailing list