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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Apr 20 16:52:55 CDT 2011


branch "master" has been updated
       via  043220484084b440d39c8a5e6f8be2c3410a8b12 (commit)
       via  80b89ef014c25bef1c2298191863e303a8618dc6 (commit)
       via  6dba63805671b9ffafa67dbd7dd3a556d3451562 (commit)
       via  57f91e2f44daef95eeb826020ac3a07cb12eb538 (commit)
       via  b4b9514036a1fdb9cee737ec9fd8e4d7f398366e (commit)
       via  e443a92d5d8df9effce88c61057e355988c589e1 (commit)
       via  3832f7809439029a156ae8c4fab6396ed7d88f03 (commit)
       via  5a3992df4a3e1646519055b4a2f044e2c78ca3da (commit)
       via  c6702d31128aab08e903ed8942374208101853df (commit)
       via  7bb626f8158bc6ebf94a38cb924c15b19af9c389 (commit)
       via  3c3c3e655aae318e216b2c1ba4ad93fcc635c60b (commit)
       via  8158ae940a21e1a82bc460ae4777dfb00ddef155 (commit)
       via  12f5496c2f3eda95ff7c9fc8808dc2bf15102ca2 (commit)
       via  78153456f35531d951bd20a0be9db7241a28bf3d (commit)
       via  ffa80ea5f956ca2c043576e6f260c5a2497e5f8f (commit)
       via  3a037bcd3d5c056aa516d3e1661b482736e63467 (commit)
       via  55d5ae61ad3fa1583e29c5ce2c7c65fc7e24ab50 (commit)
       via  db89112f4d059757e6ad1d32a4f500e9a4412e7c (commit)
       via  b37ab5655657a54fd0a1fc053d02ff2a1cbd23d8 (commit)
       via  111b4673736e29555052b53dfd4d920cc593b9ed (commit)
       via  98b2f444209e008770b792dbb2df3790437c2966 (commit)
       via  088414bdb58269202ac55f7ae34acd59c9fd8ddd (commit)
       via  a129bc7a69bacda3bb9fdfa7b2c335f6de5c8be6 (commit)
       via  4f249d4cd7b46822f1af1a440c7715f1a1c6f149 (commit)
       via  4f6f0a656bbd426a9a625319b9efec98502f0e23 (commit)
       via  f372998eacc4852d85df37862f661c3efa5639a2 (commit)
       via  7bc3710cb9d3d6fd47cc6e16c44a75ad801bdb3c (commit)
       via  5e89772774c923bba9d42d4c38296d388457657f (commit)
       via  d4359096194624e4aca13d8d29b9da9a93a64c14 (commit)
       via  e1d9166e9b06697f06c243e4adf85b14dae79f8b (commit)
      from  b3da3ccb85932f5668ffb2ff18a67af72a396d93 (commit)

Summary of changes:
 config/test_component.config.in                    |   17 ++-
 config/test_service_locator.config                 |    7 +
 ...config => test_service_locator_listener.config} |    7 +
 config/test_servicelocator_state_replicator.conf   |   11 +
 local-slice/ServiceLocatorStateReplicationIf.ice   |   85 ++++++++
 src/CMakeLists.txt                                 |   28 +++
 src/ServiceLocator.cpp                             |  120 ++++++++++--
 src/ServiceLocatorManagement.cpp                   |  213 +++++++++++++++++++-
 src/ServiceLocatorManagement.h                     |   21 ++-
 src/ServiceLocatorStateListener.cpp                |  198 ++++++++++++++++++
 src/ServiceLocatorStateReplicator.h                |   42 ++++
 src/ServiceLocatorStateReplicatorApp.cpp           |  129 ++++++++++++
 src/ServiceManagement.cpp                          |  123 ++++++-----
 src/ServiceManagement.h                            |   12 +-
 14 files changed, 930 insertions(+), 83 deletions(-)
 copy config/{test_service_locator.config => test_service_locator_listener.config} (86%)
 create mode 100644 config/test_servicelocator_state_replicator.conf
 create mode 100644 local-slice/ServiceLocatorStateReplicationIf.ice
 create mode 100644 src/ServiceLocatorStateListener.cpp
 create mode 100644 src/ServiceLocatorStateReplicator.h
 create mode 100644 src/ServiceLocatorStateReplicatorApp.cpp


- Log -----------------------------------------------------------------
commit 043220484084b440d39c8a5e6f8be2c3410a8b12
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Apr 20 18:49:25 2011 -0300

    Update things slightly.

diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index 3481396..59274ab 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -22,7 +22,7 @@
 #include <AsteriskSCF/Core/Discovery/ServiceLocatorEventsIf.h>
 #include <AsteriskSCF/logger.h>
 #include <AsteriskSCF/Logger/IceLogger.h>
-#include <AsterisksCF/System/Component/ReplicaIf.h>
+#include <AsteriskSCF/System/Component/ReplicaIf.h>
 
 #include "ServiceLocatorManagement.h"
 #include "ServiceManagement.h"
diff --git a/src/ServiceLocatorStateReplicatorApp.cpp b/src/ServiceLocatorStateReplicatorApp.cpp
index 8a80f0d..244485f 100644
--- a/src/ServiceLocatorStateReplicatorApp.cpp
+++ b/src/ServiceLocatorStateReplicatorApp.cpp
@@ -35,7 +35,7 @@ using namespace AsteriskSCF::System::Logging;
 
 namespace
 {
-Logger &lg = getLoggerFactory().getLogger("AsteriskSCF.System.Discovery");
+const Logger &lg = getLoggerFactory().getLogger("AsteriskSCF.System.Discovery");
 }
 
 class ServiceLocatorStateReplicatorService : public IceBox::Service

commit 80b89ef014c25bef1c2298191863e303a8618dc6
Merge: b3da3cc 6dba638
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Apr 20 18:35:00 2011 -0300

    Merge remote branch 'integration/replication'


commit 6dba63805671b9ffafa67dbd7dd3a556d3451562
Author: Joshua Colp <jcolp at digium.com>
Date:   Sat Jan 22 19:17:42 2011 -0400

    Constify the items being passed to the replicateState and removeState functions.

diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index a0b4ff2..dc72db9 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -585,7 +585,7 @@ void ServiceLocatorManagementImpl::removeService(
 /**
  * Function which replicates state items.
  */
-void ServiceLocatorManagementImpl::replicateState(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr item)
+void ServiceLocatorManagementImpl::replicateState(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr& item)
 {
 	if (!item)
 	{
@@ -615,7 +615,7 @@ void ServiceLocatorManagementImpl::replicateState(AsteriskSCF::Core::Discovery::
 /**
  * Function which removes state items from the replicator.
  */
-void ServiceLocatorManagementImpl::removeState(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr item)
+void ServiceLocatorManagementImpl::removeState(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr& item)
 {
 	if (!item)
 	{
diff --git a/src/ServiceLocatorManagement.h b/src/ServiceLocatorManagement.h
index f755522..2251ad5 100644
--- a/src/ServiceLocatorManagement.h
+++ b/src/ServiceLocatorManagement.h
@@ -79,8 +79,8 @@ public:
     // Replication related functions.
     ServiceManagementImplPtr addService(const Ice::ObjectPrx&, const std::string&, const
         Ice::Identity&);
-    void replicateState(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr);
-    void removeState(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr);	
+    void replicateState(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr&);
+    void removeState(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr&);	
     void setStateReplicator(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateReplicatorPrx);
 
     //

commit 57f91e2f44daef95eeb826020ac3a07cb12eb538
Author: Joshua Colp <jcolp at digium.com>
Date:   Sat Jan 22 19:16:29 2011 -0400

    This is no longer needed.

diff --git a/local-slice/CMakeLists.txt b/local-slice/CMakeLists.txt
deleted file mode 100644
index 94e9d7d..0000000
--- a/local-slice/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-asterisk_scf_slice_include_directories("${CMAKE_SOURCE_DIR}/slice")
-asterisk_scf_compile_slice(ServiceLocatorStateReplicationIf.ice lib "Service Locator State Replicator" service_locator)
-

commit b4b9514036a1fdb9cee737ec9fd8e4d7f398366e
Author: Joshua Colp <jcolp at digium.com>
Date:   Sat Jan 22 19:16:16 2011 -0400

    Get to a working state once again.

diff --git a/local-slice/ServiceLocatorStateReplicationIf.ice b/local-slice/ServiceLocatorStateReplicationIf.ice
index abb8e12..c0fc4e2 100644
--- a/local-slice/ServiceLocatorStateReplicationIf.ice
+++ b/local-slice/ServiceLocatorStateReplicationIf.ice
@@ -18,7 +18,7 @@
 
 #include <Ice/BuiltinSequences.ice>
 #include <Ice/Identity.ice>
-#include "Core/Discovery/ServiceLocatorIf.ice"
+#include "AsteriskSCF/Core/Discovery/ServiceLocatorIf.ice"
 
 module AsteriskSCF
 {
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 997b6c9..b72ddb2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -9,6 +9,11 @@
 include_directories(${utils_dir}/StateReplicator/src)
 include_directories(${utils_dir}/SmartProxy/src)
 
+include_directories(${utils_dir}/StateReplicator/include)
+include_directories(${utils_dir}/SmartProxy/include)
+
+asterisk_scf_slice_include_directories(${API_SLICE_DIR})
+
 # Create the actual standalone service locator component
 asterisk_scf_component_init(service_locator CXX)
 
diff --git a/src/ServiceLocatorManagement.h b/src/ServiceLocatorManagement.h
index 168fae9..f755522 100644
--- a/src/ServiceLocatorManagement.h
+++ b/src/ServiceLocatorManagement.h
@@ -20,7 +20,7 @@
 
 #include <IceUtil/Shared.h>
 
-#include "System/Component/ReplicaIf.h"
+#include <AsteriskSCF/System/Component/ReplicaIf.h>
 
 #include "ServiceLocatorStateReplicationIf.h"
 
diff --git a/src/ServiceLocatorStateListener.cpp b/src/ServiceLocatorStateListener.cpp
index 1018ad4..d4df1e5 100644
--- a/src/ServiceLocatorStateListener.cpp
+++ b/src/ServiceLocatorStateListener.cpp
@@ -19,11 +19,11 @@
 #include <boost/thread.hpp>
 #include <boost/shared_ptr.hpp>
 
-#include "ReplicaIf.h"
-#include "SmartProxy.h"
+#include <AsteriskSCF/System/Component/ReplicaIf.h>
+#include <AsteriskSCF/SmartProxy.h>
 
-#include "Core/Discovery/ServiceLocatorIf.h"
-#include "Core/Discovery/ServiceLocatorEventsIf.h"
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorEventsIf.h>
 
 #include "ServiceLocatorManagement.h"
 #include "ServiceManagement.h"
diff --git a/src/ServiceLocatorStateReplicator.h b/src/ServiceLocatorStateReplicator.h
index dfaf388..0dea777 100644
--- a/src/ServiceLocatorStateReplicator.h
+++ b/src/ServiceLocatorStateReplicator.h
@@ -17,12 +17,12 @@
 #pragma once
 
 #include <Ice/Ice.h>
-#include "Core/Discovery/ServiceLocatorIf.h"
-#include "Core/Discovery/ServiceLocatorEventsIf.h"
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorEventsIf.h>
 #include "ServiceLocatorStateReplicationIf.h"
 #include "ServiceLocatorManagement.h"
 #include "ServiceManagement.h"
-#include "StateReplicator.h"
+#include <AsteriskSCF/StateReplicator.h>
 
 using namespace AsteriskSCF::Core::Discovery::V1;
 
diff --git a/src/ServiceLocatorStateReplicatorApp.cpp b/src/ServiceLocatorStateReplicatorApp.cpp
index c125aa2..8a80f0d 100644
--- a/src/ServiceLocatorStateReplicatorApp.cpp
+++ b/src/ServiceLocatorStateReplicatorApp.cpp
@@ -21,11 +21,11 @@
 
 #include <pjlib.h>
 
-#include "ServiceLocatorIf.h"
-#include "ComponentServiceIf.h"
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
+#include <AsteriskSCF/System/Component/ComponentServiceIf.h>
 #include "ServiceLocatorStateReplicator.h"
-#include "IceLogger.h"
-#include "logger.h"
+#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Logger/IceLogger.h>
 
 using namespace std;
 using namespace AsteriskSCF::Core;

commit e443a92d5d8df9effce88c61057e355988c589e1
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Jan 3 09:55:23 2011 -0400

    Provide a default value for Ice::Current in the declaration so one does not need to be created before using it elsewhere.

diff --git a/src/ServiceLocatorManagement.h b/src/ServiceLocatorManagement.h
index 98ca5e7..168fae9 100644
--- a/src/ServiceLocatorManagement.h
+++ b/src/ServiceLocatorManagement.h
@@ -95,7 +95,7 @@ public:
     void addCompare(const std::string&,
         const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsComparePrx&,
         const Ice::Current&);
-    void removeCompare(const std::string&, const Ice::Current&);
+    void removeCompare(const std::string&, const Ice::Current& = Ice::Current());
 
     void isSupported(const std::string&,
         const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&,
diff --git a/src/ServiceLocatorStateListener.cpp b/src/ServiceLocatorStateListener.cpp
index 38d79dd..1018ad4 100644
--- a/src/ServiceLocatorStateListener.cpp
+++ b/src/ServiceLocatorStateListener.cpp
@@ -36,17 +36,18 @@ using namespace AsteriskSCF::ServiceDiscovery;
 class ServiceLocatorStateReplicatorItem
 {
 public:
-    ServiceLocatorStateReplicatorItem(ServiceLocatorManagementImplPtr locatorManagement) : mLocatorManagement(locatorManagement) { }
+    ServiceLocatorStateReplicatorItem(ServiceLocatorManagementImplPtr locatorManagement) :
+	  mLocatorManagement(locatorManagement) { }
+
     ~ServiceLocatorStateReplicatorItem()
     {
-	Ice::Current current;
 	if (mService)
 	{
-	    mService->unregister(current);
+	    mService->unregister();
 	}
 	if (!mComparator.empty())
 	{
-	    mLocatorManagement->removeCompare(mComparator, current);
+	    mLocatorManagement->removeCompare(mComparator);
 	}
     }
 
@@ -104,7 +105,6 @@ public:
 
 	    if ((serviceState = ServiceLocatorServiceStateItemPtr::dynamicCast((*item))))
 	    {
-		Ice::Current current;
 		std::map<std::string, boost::shared_ptr<ServiceLocatorStateReplicatorItem> >::iterator i = mStateItems.find((*item)->key);
 	        boost::shared_ptr<ServiceLocatorStateReplicatorItem> localitem;
 
@@ -124,11 +124,11 @@ public:
 		// The only thing that can be changed by a subsequent state item is the suspend status
 		if (serviceState->suspended == true)
 		{
-		    localitem->getService()->suspend(current);
+		    localitem->getService()->suspend();
 		}
 		else
 		{
-		    localitem->getService()->unsuspend(current);
+		    localitem->getService()->unsuspend();
 		}
 	    }
 	    else if ((paramsState = ServiceLocatorParamsStateItemPtr::dynamicCast((*item))))
@@ -142,8 +142,7 @@ public:
 		}
 
 		// Parameters are only ever added, they are never modified or removed
-		Ice::Current current;
-		i->second->getService()->addLocatorParams(paramsState->params, paramsState->compareGuid, current);
+		i->second->getService()->addLocatorParams(paramsState->params, paramsState->compareGuid);
 	    }
 	    else if ((comparatorState = ServiceLocatorComparatorStateItemPtr::dynamicCast((*item))))
 	    {
diff --git a/src/ServiceManagement.h b/src/ServiceManagement.h
index 14b5b13..66fd43f 100644
--- a/src/ServiceManagement.h
+++ b/src/ServiceManagement.h
@@ -39,10 +39,10 @@ public:
     //
     // AsteriskSCF::Core::Discovery::V1::ServiceManagement interface.
     //
-    void addLocatorParams(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&, const std::string&, const Ice::Current&);
-    void suspend(const Ice::Current&);
-    void unsuspend(const Ice::Current&);
-    void unregister(const Ice::Current&);
+    void addLocatorParams(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&, const std::string&, const Ice::Current& = Ice::Current());
+    void suspend(const Ice::Current& = Ice::Current());
+    void unsuspend(const Ice::Current& = Ice::Current());
+    void unregister(const Ice::Current& = Ice::Current());
     AsteriskSCF::Core::Discovery::V1::ServiceStatus getStatus(const Ice::Current&) const { return getStatus(); }
 
     Ice::ObjectPrx getService();

commit 3832f7809439029a156ae8c4fab6396ed7d88f03
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Jan 3 09:42:26 2011 -0400

    Add proper logging if a suitable proxy is not available for replication.

diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index bec6a78..a0b4ff2 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -606,8 +606,9 @@ void ServiceLocatorManagementImpl::replicateState(AsteriskSCF::Core::Discovery::
         ServiceLocatorStateReplicatorPrx oneway = ServiceLocatorStateReplicatorPrx::uncheckedCast(mImpl->mStateReplicator->ice_oneway());
         oneway->setState(items);
     }
-    catch (...)
+	catch (const Ice::NoEndpointException&)
     {
+	    lg(Error) << "No endpoint for oneway invocation of replicateState() for state replication." << std::endl;
     }
 }
 
@@ -635,8 +636,9 @@ void ServiceLocatorManagementImpl::removeState(AsteriskSCF::Core::Discovery::V1:
         ServiceLocatorStateReplicatorPrx oneway = ServiceLocatorStateReplicatorPrx::uncheckedCast(mImpl->mStateReplicator->ice_oneway());
         oneway->removeState(items);
     }
-    catch (...)
+	catch (const Ice::NoEndpointException&)
     {
+	    lg(Error) << "No endpoint for oneway invocation of replicateState() for state replication." << std::endl;
     }
 }
 

commit 5a3992df4a3e1646519055b4a2f044e2c78ca3da
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Jan 3 09:35:33 2011 -0400

    Since only one item is ever passed to replicateState and removeState simply make it accept the base class.

diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index 73e24c2..bec6a78 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -108,7 +108,7 @@ public:
 	mStateItem->key = IceUtil::generateUUID();
 	mStateItem->name = name;
 	mStateItem->comparator = compare;
-	mManagement->replicateState(0, 0, mStateItem);
+	mManagement->replicateState(mStateItem);
     }
 
     /**
@@ -117,7 +117,7 @@ public:
      */
     ~ServiceLocatorComparator()
     {
-	mManagement->removeState(0, 0, mStateItem);
+	mManagement->removeState(mStateItem);
     }
 
     /**
@@ -585,10 +585,13 @@ void ServiceLocatorManagementImpl::removeService(
 /**
  * Function which replicates state items.
  */
-void ServiceLocatorManagementImpl::replicateState(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr service,
-    AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsStateItemPtr params,
-    AsteriskSCF::Core::Discovery::V1::ServiceLocatorComparatorStateItemPtr comparator)
+void ServiceLocatorManagementImpl::replicateState(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr item)
 {
+	if (!item)
+	{
+		return;
+	}
+
     if (!mImpl->mStateReplicator || mImpl->mReplicaService->isActive() == false)
     {
         return;
@@ -596,25 +599,7 @@ void ServiceLocatorManagementImpl::replicateState(AsteriskSCF::Core::Discovery::
 
     ServiceLocatorStateItemSeq items;
 
-    if (service)
-    {
-	items.push_back(service);
-    }
-
-    if (params)
-    {
-	items.push_back(params);
-    }
-
-    if (comparator)
-    {
-	items.push_back(comparator);
-    }
-
-    if (items.size() == 0)
-    {
-        return;
-    }
+	items.push_back(item);
 
     try
     {
@@ -629,10 +614,13 @@ void ServiceLocatorManagementImpl::replicateState(AsteriskSCF::Core::Discovery::
 /**
  * Function which removes state items from the replicator.
  */
-void ServiceLocatorManagementImpl::removeState(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr service,
-    AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsStateItemPtr params,
-    AsteriskSCF::Core::Discovery::V1::ServiceLocatorComparatorStateItemPtr comparator)
+void ServiceLocatorManagementImpl::removeState(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr item)
 {
+	if (!item)
+	{
+		return;
+	}
+
     if (!mImpl->mStateReplicator || mImpl->mReplicaService->isActive() == false)
     {
         return;
@@ -640,25 +628,7 @@ void ServiceLocatorManagementImpl::removeState(AsteriskSCF::Core::Discovery::V1:
 
     Ice::StringSeq items;
 
-    if (service)
-    {
-	items.push_back(service->key);
-    }
-
-    if (params)
-    {
-	items.push_back(params->key);
-    }
-
-    if (comparator)
-    {
-	items.push_back(comparator->key);
-    }
-
-    if (items.size() == 0)
-    {
-        return;
-    }
+	items.push_back(item->key);
 
     try
     {
diff --git a/src/ServiceLocatorManagement.h b/src/ServiceLocatorManagement.h
index b80aaec..98ca5e7 100644
--- a/src/ServiceLocatorManagement.h
+++ b/src/ServiceLocatorManagement.h
@@ -79,12 +79,8 @@ public:
     // Replication related functions.
     ServiceManagementImplPtr addService(const Ice::ObjectPrx&, const std::string&, const
         Ice::Identity&);
-    void replicateState(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr, 
-        AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsStateItemPtr,
-        AsteriskSCF::Core::Discovery::V1::ServiceLocatorComparatorStateItemPtr);
-    void removeState(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr,
-        AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsStateItemPtr,
-        AsteriskSCF::Core::Discovery::V1::ServiceLocatorComparatorStateItemPtr);	
+    void replicateState(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr);
+    void removeState(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr);	
     void setStateReplicator(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateReplicatorPrx);
 
     //
diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index bedbecf..13fddf6 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -64,12 +64,12 @@ public:
 	mStateItem->serviceKey = serviceState->key;
 	mStateItem->params = params;
 	mStateItem->compareGuid = compareGuid;
-	mManagement->replicateState(0, mStateItem, 0);
+	mManagement->replicateState(mStateItem);
     }
 
     ~ServiceLocatorParamsSpec()
     {
-	mManagement->removeState(0, mStateItem, 0);
+	mManagement->removeState(mStateItem);
     }
 
     void isSupported(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&, const IsSupportedCallbackPtr&);
@@ -108,7 +108,7 @@ public:
         {
             mLocatorTopic->serviceRegistered(guid);
         }
-	mManagement->replicateState(mStateItem, 0, 0);
+	mManagement->replicateState(mStateItem);
     }
 
     /**
@@ -328,7 +328,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, 0, 0);
+	mImpl->mManagement->replicateState(mImpl->mStateItem);
     }
 
     if (mImpl->mLocatorTopic)
@@ -348,7 +348,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, 0, 0);
+	mImpl->mManagement->replicateState(mImpl->mStateItem);
     }
 
     if (mImpl->mLocatorTopic)
@@ -380,7 +380,7 @@ void ServiceManagementImpl::unregister(const Ice::Current&)
      */
     lg(Info) << "Un-register " << mImpl->mStateItem->guid << " " << mImpl->mStateItem->service->ice_toString();
 
-    mImpl->mManagement->removeState(mImpl->mStateItem, 0, 0);
+    mImpl->mManagement->removeState(mImpl->mStateItem);
 
     mImpl->mAdapter->remove(mImpl->mManagementPrx->ice_getIdentity());
 

commit c6702d31128aab08e903ed8942374208101853df
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Jan 3 09:28:21 2011 -0400

    If we can't talk to the state replicator for some reason give more detail on why not if an exception is thrown.

diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index 5ffdfa6..1eee03a 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -259,6 +259,10 @@ void ServiceLocatorApp::start(const string& name, const Ice::CommunicatorPtr& co
             lg(Info) << "Operating in an active state and pushing updates." << endl;
         }
     }
+	catch (const std::exception& e)
+    {
+		lg(Info) << "Operating in an active and standalone state since we got an exception: " << e.what() << endl;
+    }
     catch (...)
     {
 	// If we reach this point then no state replicator is present and we are acting in a stand-alone fashion

commit 7bb626f8158bc6ebf94a38cb924c15b19af9c389
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Jan 3 09:23:32 2011 -0400

    Don't prefix local variables with m, since they aren't member variables.

diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index accd7d7..5ffdfa6 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -243,15 +243,15 @@ void ServiceLocatorApp::start(const string& name, const Ice::CommunicatorPtr& co
     try
     {
 	mStateReplicator = ServiceLocatorStateReplicatorPrx::checkedCast(communicator->propertyToProxy("ServiceLocator.StateReplicator.Proxy"));
-        ServiceLocatorStateReplicatorListenerPtr mReplicatorListener = new ServiceLocatorStateReplicatorListenerI(locatorServiceManagement);
-        ServiceLocatorStateReplicatorListenerPrx mReplicatorListenerProxy = ServiceLocatorStateReplicatorListenerPrx::uncheckedCast(mLocalAdapter->addWithUUID(mReplicatorListener));
+        ServiceLocatorStateReplicatorListenerPtr replicatorListener = new ServiceLocatorStateReplicatorListenerI(locatorServiceManagement);
+        ServiceLocatorStateReplicatorListenerPrx replicatorListenerProxy = ServiceLocatorStateReplicatorListenerPrx::uncheckedCast(mLocalAdapter->addWithUUID(replicatorListener));
 
 	locatorServiceManagement->setStateReplicator(mStateReplicator);
 
         if (communicator->getProperties()->getPropertyWithDefault("ServiceLocatorStateReplicatorListener", "no") == "yes")
         {
 	    mReplicaService->standby();
-            mStateReplicator->addListener(mReplicatorListenerProxy);
+            mStateReplicator->addListener(replicatorListenerProxy);
             lg(Info) << "Operating as a standby replica." << endl;
         }
         else

commit 3c3c3e655aae318e216b2c1ba4ad93fcc635c60b
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Jan 3 09:22:08 2011 -0400

    Get rid of the logger adapter in favor of the local adapter.

diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index 5d846fe..accd7d7 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -57,7 +57,6 @@ private:
     Ice::ObjectAdapterPtr mLocalAdapter;
     Ice::ObjectAdapterPtr mDiscoveryAdapter;
     Ice::ObjectAdapterPtr mManagementAdapter;
-    Ice::ObjectAdapterPtr mLoggerAdapter;
     AsteriskSCF::ServiceDiscovery::CollocatedIceStormPtr mIceStorm;
     ReplicaPtr mReplicaService;
     ServiceLocatorStateReplicatorPrx mStateReplicator;
@@ -170,13 +169,13 @@ void ServiceLocatorApp::start(const string& name, const Ice::CommunicatorPtr& co
 {
     mIceStorm = new AsteriskSCF::ServiceDiscovery::CollocatedIceStorm("AsteriskSCFIceStorm", communicator->getProperties());
 
-    mLoggerAdapter = communicator->createObjectAdapter("LoggerAdapter");
+	mLocalAdapter = communicator->createObjectAdapter("ServiceLocatorLocalAdapter");
 
-    ConfiguredIceLoggerPtr mIceLogger = createIceLogger(mLoggerAdapter);
+    ConfiguredIceLoggerPtr mIceLogger = createIceLogger(mLocalAdapter);
 
     getLoggerFactory().setLogOutput(mIceLogger->getLogger());
 
-    mLoggerAdapter->activate();
+    mLocalAdapter->activate();
 
     lg(Info) << "Initializing service discovery component";
 
@@ -223,14 +222,9 @@ void ServiceLocatorApp::start(const string& name, const Ice::CommunicatorPtr& co
         lg(Info) << "IceStorm topic manager proxy not present, events disabled.";
     }
 
-    mLocalAdapter = communicator->createObjectAdapter(
-        "ServiceLocatorLocalAdapter");
-
     mReplicaService = new ReplicaImpl(mLocalAdapter);
     mLocalAdapter->add(mReplicaService, communicator->stringToIdentity(ReplicaServiceId));
 
-    mLocalAdapter->activate();
-
     /* 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.

commit 8158ae940a21e1a82bc460ae4777dfb00ddef155
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Jan 3 09:20:36 2011 -0400

    Constify the passing of the locator service management pointer.

diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index dcd9c82..5d846fe 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -124,7 +124,7 @@ private:
 class ServiceLocatorImpl : public ServiceLocator
 {
 public:
-    ServiceLocatorImpl(ServiceLocatorManagementImplPtr LocatorServiceManagement) :
+    ServiceLocatorImpl(const ServiceLocatorManagementImplPtr& LocatorServiceManagement) :
         mLocatorServiceManagement(LocatorServiceManagement) { };
     /**
      * Asynchronously locate a service for the given parameters.

commit 12f5496c2f3eda95ff7c9fc8808dc2bf15102ca2
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Jan 3 09:17:59 2011 -0400

    Don't prefix state items with m, and don't call a comparator proxy a service call it a comparator.

diff --git a/local-slice/ServiceLocatorStateReplicationIf.ice b/local-slice/ServiceLocatorStateReplicationIf.ice
index 7d4c71f..abb8e12 100644
--- a/local-slice/ServiceLocatorStateReplicationIf.ice
+++ b/local-slice/ServiceLocatorStateReplicationIf.ice
@@ -57,23 +57,23 @@ module V1
 
    class ServiceLocatorServiceStateItem extends ServiceLocatorStateItem
    {
-       bool mSuspended;
-       Object *mService;
-       Ice::Identity mManagementIdentity;
-       string mGuid;
+       bool suspended;
+       Object *service;
+       Ice::Identity managementIdentity;
+       string guid;
    };
 
    class ServiceLocatorParamsStateItem extends ServiceLocatorStateItem
    {
-       string mServiceKey;
-       ServiceLocatorParams mParams;
-       string mCompareGuid;
+       string serviceKey;
+       ServiceLocatorParams params;
+       string compareGuid;
    };
 
    class ServiceLocatorComparatorStateItem extends ServiceLocatorStateItem
    {
-       string mName;
-       ServiceLocatorParamsCompare *mService;
+       string name;
+       ServiceLocatorParamsCompare *comparator;
    };
 
 }; //module V1
diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index 60e4bff..73e24c2 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -106,8 +106,8 @@ public:
 	mStateItem(new ServiceLocatorComparatorStateItem())
     {
 	mStateItem->key = IceUtil::generateUUID();
-	mStateItem->mName = name;
-	mStateItem->mService = compare;
+	mStateItem->name = name;
+	mStateItem->comparator = compare;
 	mManagement->replicateState(0, 0, mStateItem);
     }
 
@@ -137,7 +137,7 @@ public:
         Ice::CallbackPtr d = Ice::newCallback(iceCallback,
             &Comparator_IsSupported_Callback::finished);
         // async forward to the comparator
-        mStateItem->mService->begin_isSupported(params, d);
+        mStateItem->comparator->begin_isSupported(params, d);
     }
 private:
     /**
diff --git a/src/ServiceLocatorStateListener.cpp b/src/ServiceLocatorStateListener.cpp
index e6bb3fd..38d79dd 100644
--- a/src/ServiceLocatorStateListener.cpp
+++ b/src/ServiceLocatorStateListener.cpp
@@ -113,7 +113,7 @@ public:
 		    boost::shared_ptr<ServiceLocatorStateReplicatorItem> newitem(new ServiceLocatorStateReplicatorItem(mLocatorManagement));
                     localitem = newitem;
                     mStateItems.insert(std::make_pair((*item)->key, newitem));
-		    ServiceManagementImplPtr service = mLocatorManagement->addService(serviceState->mService, serviceState->mGuid, serviceState->mManagementIdentity);
+		    ServiceManagementImplPtr service = mLocatorManagement->addService(serviceState->service, serviceState->guid, serviceState->managementIdentity);
 		    newitem->setService(service);
 		}
 		else
@@ -122,7 +122,7 @@ public:
 		}
 
 		// The only thing that can be changed by a subsequent state item is the suspend status
-		if (serviceState->mSuspended == true)
+		if (serviceState->suspended == true)
 		{
 		    localitem->getService()->suspend(current);
 		}
@@ -134,7 +134,7 @@ public:
 	    else if ((paramsState = ServiceLocatorParamsStateItemPtr::dynamicCast((*item))))
 	    {
 		// This is special, we have to find the respective service and then add parameters to it
-		std::map<std::string, boost::shared_ptr<ServiceLocatorStateReplicatorItem> >::iterator i = mStateItems.find(paramsState->mServiceKey);
+		std::map<std::string, boost::shared_ptr<ServiceLocatorStateReplicatorItem> >::iterator i = mStateItems.find(paramsState->serviceKey);
 
 	        if ((i == mStateItems.end()))
 		{
@@ -143,7 +143,7 @@ public:
 
 		// Parameters are only ever added, they are never modified or removed
 		Ice::Current current;
-		i->second->getService()->addLocatorParams(paramsState->mParams, paramsState->mCompareGuid, current);
+		i->second->getService()->addLocatorParams(paramsState->params, paramsState->compareGuid, current);
 	    }
 	    else if ((comparatorState = ServiceLocatorComparatorStateItemPtr::dynamicCast((*item))))
 	    {
@@ -158,10 +158,10 @@ public:
 		try
 		{
 		    Ice::Current current;
-		    mLocatorManagement->addCompare(comparatorState->mName, comparatorState->mService, current);
+		    mLocatorManagement->addCompare(comparatorState->name, comparatorState->comparator, current);
 		    boost::shared_ptr<ServiceLocatorStateReplicatorItem> newitem(new ServiceLocatorStateReplicatorItem(mLocatorManagement));
 		    mStateItems.insert(std::make_pair((*item)->key, newitem));
-		    newitem->setComparator(comparatorState->mName);
+		    newitem->setComparator(comparatorState->name);
 		}
 		catch (...)
 		{
diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index 5d8960d..bedbecf 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -61,9 +61,9 @@ public:
         mManagement(management)
     {
 	mStateItem->key = IceUtil::generateUUID();
-	mStateItem->mServiceKey = serviceState->key;
-	mStateItem->mParams = params;
-	mStateItem->mCompareGuid = compareGuid;
+	mStateItem->serviceKey = serviceState->key;
+	mStateItem->params = params;
+	mStateItem->compareGuid = compareGuid;
 	mManagement->replicateState(0, mStateItem, 0);
     }
 
@@ -99,11 +99,11 @@ public:
         mManagement(management), mAdapter(adapter), mLocatorTopic(serviceDiscoveryTopic)
     {
 	mStateItem->key = IceUtil::generateUUID();
-	mStateItem->mSuspended = false;
-	mStateItem->mService = service;
-	mStateItem->mGuid = guid;
+	mStateItem->suspended = false;
+	mStateItem->service = service;
+	mStateItem->guid = guid;
 	mManagementPrx = ServiceManagementPrx::uncheckedCast(mAdapter->add(impl, identity));
-	mStateItem->mManagementIdentity = identity;
+	mStateItem->managementIdentity = identity;
         if (mLocatorTopic)
         {
             mLocatorTopic->serviceRegistered(guid);
@@ -169,7 +169,7 @@ ServiceManagementImpl::ServiceManagementImpl(ServiceLocatorManagementImplPtr man
  */
 Ice::ObjectPrx ServiceManagementImpl::getService()
 {
-    return mImpl->mStateItem->mService;
+    return mImpl->mStateItem->service;
 }
 
 /**
@@ -245,7 +245,7 @@ void ServiceManagementImpl::isSupported(const ServiceLocatorParamsPtr& params, c
     /* If this service is suspended we can just skip the entire check and
      * return false now, easy as pie
      */
-    if (mImpl->mStateItem->mSuspended)
+    if (mImpl->mStateItem->suspended)
     {
         lg(Debug) << "  ...isSupported(" << params->category << ") = false (suspended)\n";
         callback->result(false);
@@ -266,7 +266,7 @@ void ServiceManagementImpl::isSupported(const ServiceLocatorParamsPtr& params, c
 
 const std::string& ServiceManagementImpl::getGuid() const
 {
-    return mImpl->mStateItem->mGuid;
+    return mImpl->mStateItem->guid;
 }
 
 /**
@@ -288,15 +288,15 @@ void ServiceLocatorParamsSpec::isSupported(const ServiceLocatorParamsPtr& params
     }
     /* This is just a simple comparison that acts as a preliminary, and
      * perhaps final, check */
-    else if (mStateItem->mParams->category != params->category)
+    else if (mStateItem->params->category != params->category)
     {
         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 */
-    else if (!mStateItem->mCompareGuid.empty())
+    else if (!mStateItem->compareGuid.empty())
     {
-        mManagement->isSupported(mStateItem->mCompareGuid, params, callback);
+        mManagement->isSupported(mStateItem->compareGuid, params, callback);
     }
     /* category matches, no comparator to turn us down.  it's a match. */
     else
@@ -324,16 +324,16 @@ void ServiceManagementImpl::suspend(const Ice::Current&)
 {
     boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
 
-    if (!mImpl->mStateItem->mSuspended)
+    if (!mImpl->mStateItem->suspended)
     {
-        lg(Info) << "Suspending " << mImpl->mStateItem->mGuid << " " << mImpl->mStateItem->mService->ice_toString();
-        mImpl->mStateItem->mSuspended = true;
+        lg(Info) << "Suspending " << mImpl->mStateItem->guid << " " << mImpl->mStateItem->service->ice_toString();
+        mImpl->mStateItem->suspended = true;
 	mImpl->mManagement->replicateState(mImpl->mStateItem, 0, 0);
     }
 
     if (mImpl->mLocatorTopic)
     {
-        mImpl->mLocatorTopic->serviceSuspended(mImpl->mStateItem->mGuid);
+        mImpl->mLocatorTopic->serviceSuspended(mImpl->mStateItem->guid);
     }
 }
 
@@ -344,23 +344,23 @@ void ServiceManagementImpl::unsuspend(const Ice::Current&)
 {
     boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
 
-    if (mImpl->mStateItem->mSuspended)
+    if (mImpl->mStateItem->suspended)
     {
-        lg(Info) << "Un-suspending " << mImpl->mStateItem->mGuid << " " << mImpl->mStateItem->mService->ice_toString();
-        mImpl->mStateItem->mSuspended = false;
+        lg(Info) << "Un-suspending " << mImpl->mStateItem->guid << " " << mImpl->mStateItem->service->ice_toString();
+        mImpl->mStateItem->suspended = false;
 	mImpl->mManagement->replicateState(mImpl->mStateItem, 0, 0);
     }
 
     if (mImpl->mLocatorTopic)
     {
-        mImpl->mLocatorTopic->serviceUnsuspended(mImpl->mStateItem->mGuid);
+        mImpl->mLocatorTopic->serviceUnsuspended(mImpl->mStateItem->guid);
     }
 }
 
 ServiceStatus ServiceManagementImpl::getStatus() const
 {
     boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
-    if (mImpl->mStateItem->mSuspended)
+    if (mImpl->mStateItem->suspended)
     {
         return Suspended;
     }
@@ -378,7 +378,7 @@ 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->mGuid << " " << mImpl->mStateItem->mService->ice_toString();
+    lg(Info) << "Un-register " << mImpl->mStateItem->guid << " " << mImpl->mStateItem->service->ice_toString();
 
     mImpl->mManagement->removeState(mImpl->mStateItem, 0, 0);
 
@@ -388,7 +388,7 @@ void ServiceManagementImpl::unregister(const Ice::Current&)
 
     if (mImpl->mLocatorTopic)
     {
-        mImpl->mLocatorTopic->serviceUnregistered(mImpl->mStateItem->mGuid);
+        mImpl->mLocatorTopic->serviceUnregistered(mImpl->mStateItem->guid);
     }
 }
 

commit 78153456f35531d951bd20a0be9db7241a28bf3d
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Dec 20 08:40:24 2010 -0400

    Remove service locator details from service locator replication slice. The proxies have to be specified in the configuration.

diff --git a/local-slice/ServiceLocatorStateReplicationIf.ice b/local-slice/ServiceLocatorStateReplicationIf.ice
index c475cf8..7d4c71f 100644
--- a/local-slice/ServiceLocatorStateReplicationIf.ice
+++ b/local-slice/ServiceLocatorStateReplicationIf.ice
@@ -32,14 +32,6 @@ module Discovery
 ["suppress"]
 module V1
 {
-   const string StateReplicatorComponentCategory = "ServiceLocatorStateReplicatorComponent";
-   const string StateReplicatorDiscoveryCategory = "ServiceLocatorStateReplicator";
-
-   class ServiceLocatorStateReplicatorParams extends AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams
-   {
-      string mName;
-   };
-
    class ServiceLocatorStateItem
    {
       string key;

commit ffa80ea5f956ca2c043576e6f260c5a2497e5f8f
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 15ad1d2..5d8960d 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -247,6 +247,7 @@ void ServiceManagementImpl::isSupported(const ServiceLocatorParamsPtr& params, c
      */
     if (mImpl->mStateItem->mSuspended)
     {
+        lg(Debug) << "  ...isSupported(" << params->category << ") = false (suspended)\n";
         callback->result(false);
         return;
     }
@@ -282,12 +283,14 @@ void ServiceLocatorParamsSpec::isSupported(const ServiceLocatorParamsPtr& params
     // everything/anything, so give it to them
     if (params->category.empty())
     {
+        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 (different categories)\n";
         callback->result(false);
     }
     /* If a comparator was provided then yield to it for a final yay or nay */

commit 3a037bcd3d5c056aa516d3e1661b482736e63467
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 5de72bf..15ad1d2 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 <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
 #include <AsteriskSCF/Core/Discovery/ServiceLocatorEventsIf.h>
@@ -138,7 +139,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.
@@ -253,12 +254,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);
     }
 }
 
@@ -308,7 +309,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 55d5ae61ad3fa1583e29c5ce2c7c65fc7e24ab50
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 89a0190..5de72bf 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -53,12 +53,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);
@@ -306,7 +308,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 db89112f4d059757e6ad1d32a4f500e9a4412e7c
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 59ebe3d..dcd9c82 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 b37ab5655657a54fd0a1fc053d02ff2a1cbd23d8
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

commit 111b4673736e29555052b53dfd4d920cc593b9ed
Author: Joshua Colp <jcolp at digium.com>
Date:   Thu Dec 16 11:08:58 2010 -0400

    Get the service locator talking to the state replicator and pushing out state items.

diff --git a/config/test_component.config.in b/config/test_component.config.in
index b793c27..6d13371 100644
--- a/config/test_component.config.in
+++ b/config/test_component.config.in
@@ -40,11 +40,20 @@ AsteriskSCFIceStorm.Trace.TopicManager=2
 #
 AsteriskSCFIceStorm.Flush.Timeout=2000
 
+# Service Locator State Replicator Configuration
+IceBox.Service.ServiceDiscoveryStateReplicator=../src at ServiceLocatorStateReplicator:create
+
+# Test endpoints for the state replicator
+ServiceLocatorStateReplicator.Endpoints=tcp -p 4413:udp -p 4413
+
 #
 # ServiceDiscovery configuration
 #
 IceBox.Service.ServiceDiscovery=../src at service_locator:create
 
+# Test endpoints for the service locator local adapter
+ServiceLocatorLocalAdapter.Endpoints=tcp -p 4412
+
 # Test endpoints for the service locator management adapter
 ServiceLocatorManagementAdapter.Endpoints=tcp -p 4422
 
@@ -54,6 +63,12 @@ ServiceLocatorAdapter.Endpoints=tcp -p 4411
 # Test endpoints for IceStorm
 TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:default -p 10000
 
+# Proxy to the state replicator
+ServiceLocator.StateReplicator.Proxy=ServiceLocatorStateReplicatorService:tcp -p 4413
+
+# Configure ourselves as a master
+ServiceLocatorStateReplicatorListener=no
+
 #
 # Logger configuration
 #
@@ -70,4 +85,4 @@ ServiceLocatorManagement.proxy=ServiceLocatorManagement:tcp -p 4422
 #
 # IceBox load order
 #
-IceBox.LoadOrder=ServiceDiscovery,ServiceDiscoveryTest
+IceBox.LoadOrder=ServiceDiscoveryStateReplicator,ServiceDiscovery,ServiceDiscoveryTest
diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index 9c4f70b..59ebe3d 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -22,9 +22,11 @@
 #include <AsteriskSCF/Core/Discovery/ServiceLocatorEventsIf.h>
 #include <AsteriskSCF/logger.h>
 #include <AsteriskSCF/Logger/IceLogger.h>
+#include <AsterisksCF/System/Component/ReplicaIf.h>
 
 #include "ServiceLocatorManagement.h"
 #include "ServiceManagement.h"
+#include "ServiceLocatorStateReplicator.h"
 #include "CollocatedIceStorm.h"
 
 using namespace std;
@@ -32,11 +34,14 @@ using namespace AsteriskSCF::System::Discovery;
 using namespace AsteriskSCF::System::Logging;
 using namespace AsteriskSCF::Core::Discovery::V1;
 using namespace AsteriskSCF::ServiceDiscovery;
+using namespace AsteriskSCF::System::Component::V1;
 
 namespace
 {
 Logger const &lg = getLoggerFactory().getLogger("AsteriskSCF.System.Discovery");
 
+static const string ReplicaServiceId("ServiceLocatorReplica");
+
 /**
  * Implementation of the Ice::Application class
  */
@@ -49,10 +54,68 @@ public:
     void stop();
 
 private:
+    Ice::ObjectAdapterPtr mLocalAdapter;
     Ice::ObjectAdapterPtr mDiscoveryAdapter;
     Ice::ObjectAdapterPtr mManagementAdapter;
     Ice::ObjectAdapterPtr mLoggerAdapter;
     AsteriskSCF::ServiceDiscovery::CollocatedIceStormPtr mIceStorm;
+    ReplicaPtr mReplicaService;
+    ServiceLocatorStateReplicatorPrx mStateReplicator;
+};
+
+/**
+ * Implementation of the Replica interface.
+ */
+class ReplicaImpl : public Replica
+{
+public:
+    ReplicaImpl(Ice::ObjectAdapterPtr adapter) : mAdapter(adapter), mPaused(false), mActive(true) { }
+
+    bool isActive(const Ice::Current&)
+    {
+        return mActive;
+    }
+
+    bool activate(const Ice::Current&)
+    {
+        mActive = true;
+
+        for (vector<AsteriskSCF::System::Component::V1::ReplicaListenerPrx>::const_iterator listener = mListeners.begin(); listener != mListeners.end(); ++listener)
+        {
+            (*listener)->activated(ReplicaPrx::uncheckedCast(mAdapter->createDirectProxy(mAdapter->getCommunicator()->stringToIdentity(ReplicaServiceId))));
+        }
+
+        return true;
+    }
+
+    void standby(const Ice::Current&)
+    {
+        mActive = false;
+
+        for (vector<AsteriskSCF::System::Component::V1::ReplicaListenerPrx>::const_iterator listener = mListeners.begin(); listener != mListeners.end(); ++listener)
+        {
+            (*listener)->onStandby(ReplicaPrx::uncheckedCast(mAdapter->createDirectProxy(mAdapter->getCommunicator()->stringToIdentity(ReplicaServiceId))));
+        }
+    }
+
+    void addListener(const AsteriskSCF::System::Component::V1::ReplicaListenerPrx& listener, const Ice::Current&)
+    {
+        mListeners.push_back(listener);
+    }
+
+    void removeListener(const AsteriskSCF::System::Component::V1::ReplicaListenerPrx& listener, const Ice::Current&)
+    {
+        mListeners.erase(std::remove(mListeners.begin(), mListeners.end(), listener), mListeners.end());
+    }
+
+private:
+    Ice::ObjectAdapterPtr mAdapter;
+
+    vector<AsteriskSCF::System::Component::V1::ReplicaListenerPrx> mListeners;
+
+    bool mPaused;
+
+    bool mActive;
 };
 
 /**
@@ -61,7 +124,7 @@ private:
 class ServiceLocatorImpl : public ServiceLocator
 {
 public:
-    ServiceLocatorImpl(ServiceLocatorManagementImpl* LocatorServiceManagement) :
+    ServiceLocatorImpl(ServiceLocatorManagementImplPtr LocatorServiceManagement) :
         mLocatorServiceManagement(LocatorServiceManagement) { };
     /**
      * Asynchronously locate a service for the given parameters.
@@ -81,7 +144,7 @@ private:
      * actually stored. Our ServiceLocator implementation simply acts as a read-only
      *  frontend to it.
      */
-    ServiceLocatorManagementImpl* mLocatorServiceManagement;
+    ServiceLocatorManagementImplPtr mLocatorServiceManagement;
 };
 
 }
@@ -107,6 +170,14 @@ void ServiceLocatorApp::start(const string& name, const Ice::CommunicatorPtr& co
 {
     mIceStorm = new AsteriskSCF::ServiceDiscovery::CollocatedIceStorm("AsteriskSCFIceStorm", communicator->getProperties());
 
+    mLoggerAdapter = communicator->createObjectAdapter("LoggerAdapter");
+
+    ConfiguredIceLoggerPtr mIceLogger = createIceLogger(mLoggerAdapter);
+
+    getLoggerFactory().setLogOutput(mIceLogger->getLogger());
+
+    mLoggerAdapter->activate();
+
     lg(Info) << "Initializing service discovery component";
 
     /* Talk to the topic manager to either create or get the service discovery topic,
@@ -152,6 +223,14 @@ void ServiceLocatorApp::start(const string& name, const Ice::CommunicatorPtr& co
         lg(Info) << "IceStorm topic manager proxy not present, events disabled.";
     }
 
+    mLocalAdapter = communicator->createObjectAdapter(
+        "ServiceLocatorLocalAdapter");
+
+    mReplicaService = new ReplicaImpl(mLocalAdapter);
+    mLocalAdapter->add(mReplicaService, communicator->stringToIdentity(ReplicaServiceId));
+
+    mLocalAdapter->activate();
+
     /* 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.
@@ -159,14 +238,39 @@ void ServiceLocatorApp::start(const string& name, const Ice::CommunicatorPtr& co
     mManagementAdapter= communicator->createObjectAdapter(
         "ServiceLocatorManagementAdapter");
 
-    ServiceLocatorManagementImpl* locatorServiceManagement =
-        new ServiceLocatorManagementImpl(mManagementAdapter, serviceDiscoveryTopic);
+    ServiceLocatorManagementImplPtr locatorServiceManagement =
+        new ServiceLocatorManagementImpl(mManagementAdapter, serviceDiscoveryTopic, mReplicaService);
 
     mManagementAdapter->add(locatorServiceManagement,
         communicator->stringToIdentity("LocatorServiceManagement"));
 
     mManagementAdapter->activate();
 
+    try
+    {
+	mStateReplicator = ServiceLocatorStateReplicatorPrx::checkedCast(communicator->propertyToProxy("ServiceLocator.StateReplicator.Proxy"));
+        ServiceLocatorStateReplicatorListenerPtr mReplicatorListener = new ServiceLocatorStateReplicatorListenerI(locatorServiceManagement);
+        ServiceLocatorStateReplicatorListenerPrx mReplicatorListenerProxy = ServiceLocatorStateReplicatorListenerPrx::uncheckedCast(mLocalAdapter->addWithUUID(mReplicatorListener));
+
+	locatorServiceManagement->setStateReplicator(mStateReplicator);
+
+        if (communicator->getProperties()->getPropertyWithDefault("ServiceLocatorStateReplicatorListener", "no") == "yes")
+        {
+            mStateReplicator->addListener(mReplicatorListenerProxy);
+            mReplicaService->standby();
+            lg(Info) << "Operating as a standby replica." << endl;
+        }
+        else
+        {
+            lg(Info) << "Operating in an active state and pushing updates." << endl;
+        }
+    }
+    catch (...)
+    {
+	// If we reach this point then no state replicator is present and we are acting in a stand-alone fashion
+	lg(Info) << "Operating in an active and standalone state." << endl;
+    }
+
     lg(Info) << "Activated service discovery management.";
 
     mDiscoveryAdapter = communicator->createObjectAdapter("ServiceLocatorAdapter");
@@ -177,14 +281,6 @@ void ServiceLocatorApp::start(const string& name, const Ice::CommunicatorPtr& co
 
     mDiscoveryAdapter->activate();
 
-    mLoggerAdapter = communicator->createObjectAdapter("LoggerAdapter");
-
-    ConfiguredIceLoggerPtr mIceLogger = createIceLogger(mLoggerAdapter);
-
-    getLoggerFactory().setLogOutput(mIceLogger->getLogger());
-
-    mLoggerAdapter->activate();
-
     lg(Info) << "Activated service discovery.";
 
     lg(Info) << "Waiting for requests.";
diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index 9e7e28e..60e4bff 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -314,8 +314,9 @@ class AsteriskSCF::ServiceDiscovery::ServiceLocatorManagementImplPriv :
 {
 public:
     ServiceLocatorManagementImplPriv(const Ice::ObjectAdapterPtr& adapter,
-        const EventsPrx& serviceDiscoveryTopic) :
-        mAdapter(adapter), mLocatorTopic(serviceDiscoveryTopic)
+        const EventsPrx& serviceDiscoveryTopic,
+	const AsteriskSCF::System::Component::V1::ReplicaPtr replicaService) :
+        mAdapter(adapter), mLocatorTopic(serviceDiscoveryTopic), mReplicaService(replicaService)
     {
     };
 
@@ -345,6 +346,16 @@ public:
      * A proxy that can be used to publish locator events.
      */
     AsteriskSCF::System::Discovery::EventsPrx mLocatorTopic;
+
+    /**
+     * A proxy to the state replicator we are pushing updates to.
+     */
+    ServiceLocatorStateReplicatorPrx mStateReplicator;
+
+    /**
+     * A pointer to an instance of our replica service.
+     */
+    AsteriskSCF::System::Component::V1::ReplicaPtr mReplicaService;
 };
 
 /**
@@ -352,8 +363,9 @@ public:
  */
 ServiceLocatorManagementImpl::ServiceLocatorManagementImpl(
     const Ice::ObjectAdapterPtr& adapter,
-    const EventsPrx& serviceDiscoveryTopic) :
-    mImpl(new ServiceLocatorManagementImplPriv(adapter, serviceDiscoveryTopic))
+    const EventsPrx& serviceDiscoveryTopic,
+    const AsteriskSCF::System::Component::V1::ReplicaPtr replicaService) :
+    mImpl(new ServiceLocatorManagementImplPriv(adapter, serviceDiscoveryTopic, replicaService))
 {
 }
 
@@ -577,6 +589,11 @@ void ServiceLocatorManagementImpl::replicateState(AsteriskSCF::Core::Discovery::
     AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsStateItemPtr params,
     AsteriskSCF::Core::Discovery::V1::ServiceLocatorComparatorStateItemPtr comparator)
 {
+    if (!mImpl->mStateReplicator || mImpl->mReplicaService->isActive() == false)
+    {
+        return;
+    }
+
     ServiceLocatorStateItemSeq items;
 
     if (service)
@@ -593,6 +610,20 @@ void ServiceLocatorManagementImpl::replicateState(AsteriskSCF::Core::Discovery::
     {
 	items.push_back(comparator);
     }
+
+    if (items.size() == 0)
+    {
+        return;
+    }
+
+    try
+    {
+        ServiceLocatorStateReplicatorPrx oneway = ServiceLocatorStateReplicatorPrx::uncheckedCast(mImpl->mStateReplicator->ice_oneway());
+        oneway->setState(items);
+    }
+    catch (...)
+    {
+    }
 }
 
 /**
@@ -602,6 +633,11 @@ void ServiceLocatorManagementImpl::removeState(AsteriskSCF::Core::Discovery::V1:
     AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsStateItemPtr params,
     AsteriskSCF::Core::Discovery::V1::ServiceLocatorComparatorStateItemPtr comparator)
 {
+    if (!mImpl->mStateReplicator || mImpl->mReplicaService->isActive() == false)
+    {
+        return;
+    }
+
     Ice::StringSeq items;
 
     if (service)
@@ -618,4 +654,26 @@ void ServiceLocatorManagementImpl::removeState(AsteriskSCF::Core::Discovery::V1:
     {
 	items.push_back(comparator->key);
     }
+
+    if (items.size() == 0)
+    {
+        return;
+    }
+
+    try
+    {
+        ServiceLocatorStateReplicatorPrx oneway = ServiceLocatorStateReplicatorPrx::uncheckedCast(mImpl->mStateReplicator->ice_oneway());
+        oneway->removeState(items);
+    }
+    catch (...)
+    {
+    }
+}
+
+/**
+ * Function which sets the proxy to the state replicator.
+ */
+void ServiceLocatorManagementImpl::setStateReplicator(ServiceLocatorStateReplicatorPrx stateReplicator)
+{
+    mImpl->mStateReplicator = stateReplicator;
 }
diff --git a/src/ServiceLocatorManagement.h b/src/ServiceLocatorManagement.h
index 705f853..b80aaec 100644
--- a/src/ServiceLocatorManagement.h
+++ b/src/ServiceLocatorManagement.h
@@ -20,6 +20,8 @@
 
 #include <IceUtil/Shared.h>
 
+#include "System/Component/ReplicaIf.h"
+
 #include "ServiceLocatorStateReplicationIf.h"
 
 namespace AsteriskSCF
@@ -65,7 +67,8 @@ class ServiceLocatorManagementImpl :
 {
 public:
     ServiceLocatorManagementImpl(const Ice::ObjectAdapterPtr& adapter,
-        const AsteriskSCF::System::Discovery::EventsPrx& serviceDiscoveryTopic);
+        const AsteriskSCF::System::Discovery::EventsPrx& serviceDiscoveryTopic,
+	const AsteriskSCF::System::Component::V1::ReplicaPtr);
     void locate(
         const AsteriskSCF::Core::Discovery::V1::AMD_ServiceLocator_locatePtr&,
         const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
@@ -82,6 +85,7 @@ public:
     void removeState(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr,
         AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsStateItemPtr,
         AsteriskSCF::Core::Discovery::V1::ServiceLocatorComparatorStateItemPtr);	
+    void setStateReplicator(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateReplicatorPrx);
 
     //
     // AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagement interface.

commit 98b2f444209e008770b792dbb2df3790437c2966
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Dec 15 15:26:33 2010 -0400

    Add missing implementations.

diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index 81a77f2..9e7e28e 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -404,15 +404,33 @@ ServiceManagementPrx ServiceLocatorManagementImpl::addService(
 {
     lg(Debug) << "addService(" << guid << ')';
     boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
+
+    Ice::Identity identity;
+    identity.name = IceUtil::generateUUID();
+
     ServiceManagementImplPtr new_service = new ServiceManagementImpl(this,
         service,
-        mImpl->mAdapter, mImpl->mLocatorTopic, guid);
+        mImpl->mAdapter, mImpl->mLocatorTopic, guid, identity);
 
     mImpl->mServices.push_back(new_service);
 
     return new_service->getServiceManagementPrx();
 }
 
+ServiceManagementImplPtr ServiceLocatorManagementImpl::addService(const Ice::ObjectPrx& service, 
+    const std::string& guid, const Ice::Identity& identity)
+{
+    lg(Debug) << "addService(" << guid << ')';
+    boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
+    ServiceManagementImplPtr new_service = new ServiceManagementImpl(this,
+        service,
+        mImpl->mAdapter, mImpl->mLocatorTopic, guid, identity);
+
+    mImpl->mServices.push_back(new_service);
+
+    return new_service;
+}
+
 ServiceInfoSeq ServiceLocatorManagementImpl::getServices(const ::Ice::Current&) const
 {
     lg(Debug) << "getServices()";
@@ -551,3 +569,53 @@ void ServiceLocatorManagementImpl::removeService(
     lg(Error) << "removeService(" << service->getGuid() <<
         ") failed.  service not found";
 }
+
+/**
+ * Function which replicates state items.
+ */
+void ServiceLocatorManagementImpl::replicateState(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr service,
+    AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsStateItemPtr params,
+    AsteriskSCF::Core::Discovery::V1::ServiceLocatorComparatorStateItemPtr comparator)
+{
+    ServiceLocatorStateItemSeq items;
+
+    if (service)
+    {
+	items.push_back(service);
+    }
+
+    if (params)
+    {
+	items.push_back(params);
+    }
+
+    if (comparator)
+    {
+	items.push_back(comparator);
+    }
+}
+
+/**
+ * Function which removes state items from the replicator.
+ */
+void ServiceLocatorManagementImpl::removeState(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr service,
+    AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsStateItemPtr params,
+    AsteriskSCF::Core::Discovery::V1::ServiceLocatorComparatorStateItemPtr comparator)
+{
+    Ice::StringSeq items;
+
+    if (service)
+    {
+	items.push_back(service->key);
+    }
+
+    if (params)
+    {
+	items.push_back(params->key);
+    }
+
+    if (comparator)
+    {
+	items.push_back(comparator->key);
+    }
+}
diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index 0c83a69..89a0190 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -91,7 +91,7 @@ class ServiceManagementImplPriv
 public:
     ServiceManagementImplPriv(ServiceManagementImpl* impl, ServiceLocatorManagementImplPtr management,
         const Ice::ObjectPrx& service, const Ice::ObjectAdapterPtr& adapter, const AsteriskSCF::System::Discovery::EventsPrx& serviceDiscoveryTopic,
-        const string& guid) :
+        const string& guid, const Ice::Identity& identity) :
 	mStateItem(new ServiceLocatorServiceStateItem()),
         mManagement(management), mAdapter(adapter), mLocatorTopic(serviceDiscoveryTopic)
     {
@@ -99,8 +99,8 @@ public:
 	mStateItem->mSuspended = false;
 	mStateItem->mService = service;
 	mStateItem->mGuid = guid;
-        mManagementPrx = ServiceManagementPrx::uncheckedCast(mAdapter->addWithUUID(impl));
-	mStateItem->mManagementIdentity = mManagementPrx->ice_getIdentity();
+	mManagementPrx = ServiceManagementPrx::uncheckedCast(mAdapter->add(impl, identity));
+	mStateItem->mManagementIdentity = identity;
         if (mLocatorTopic)
         {
             mLocatorTopic->serviceRegistered(guid);
@@ -153,8 +153,9 @@ using namespace AsteriskSCF::System::Discovery;
  * also sends out an event for those that are listening.
  */
 ServiceManagementImpl::ServiceManagementImpl(ServiceLocatorManagementImplPtr management,
-    const Ice::ObjectPrx& service, const Ice::ObjectAdapterPtr& adapter, const EventsPrx& serviceDiscoveryTopic, const string& guid) :
-    mImpl(new ServiceManagementImplPriv(this, management, service, adapter, serviceDiscoveryTopic, guid))
+    const Ice::ObjectPrx& service, const Ice::ObjectAdapterPtr& adapter, const EventsPrx& serviceDiscoveryTopic, const string& guid,
+    const Ice::Identity& identity) :
+    mImpl(new ServiceManagementImplPriv(this, management, service, adapter, serviceDiscoveryTopic, guid, identity))
 {
 }
 
diff --git a/src/ServiceManagement.h b/src/ServiceManagement.h
index ecd3e5c..14b5b13 100644
--- a/src/ServiceManagement.h
+++ b/src/ServiceManagement.h
@@ -33,8 +33,8 @@ class ServiceManagementImplPriv;
 class ServiceManagementImpl : public AsteriskSCF::Core::Discovery::V1::ServiceManagement
 {
 public:
-    ServiceManagementImpl(ServiceLocatorManagementImplPtr, const Ice::ObjectPrx&, const Ice::ObjectAdapterPtr&,
-        const AsteriskSCF::System::Discovery::EventsPrx&, const std::string&);
+   ServiceManagementImpl(ServiceLocatorManagementImplPtr, const Ice::ObjectPrx&, const Ice::ObjectAdapterPtr&,
+        const AsteriskSCF::System::Discovery::EventsPrx&, const std::string&, const Ice::Identity&);
 
     //
     // AsteriskSCF::Core::Discovery::V1::ServiceManagement interface.

commit 088414bdb58269202ac55f7ae34acd59c9fd8ddd
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Dec 15 14:46:32 2010 -0400

    Add calls to replicateState and removeState in places where it should be done.

diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index 07cc3df..81a77f2 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -46,10 +46,9 @@ namespace ServiceLocatorManagementImplNS
 
 const Logger& lg = getLoggerFactory().getLogger("AsteriskSCF.System.Discovery");
 
-<<<<<<< HEAD
 /** Parameter type for Locator, to allow use of ResponseCollector. */
 typedef std::pair<bool, ServiceManagementImplPtr> LocateParam;
-=======
+
 /**
  * Callback class for isSupported AMI calls.  Acts as a bridge between
  * Ice callbacks and IsSupportedCallback.
@@ -101,12 +100,24 @@ public:
      *
      * @param compare A proxy to the comparator service we are wrapping.
      */
-    ServiceLocatorComparator(const ServiceLocatorParamsComparePrx& compare, std::string name) :
+    ServiceLocatorComparator(const ServiceLocatorParamsComparePrx& compare, std::string name,
+	ServiceLocatorManagementImplPtr management) :
+	mManagement(management),
 	mStateItem(new ServiceLocatorComparatorStateItem())
     {
 	mStateItem->key = IceUtil::generateUUID();
 	mStateItem->mName = name;
 	mStateItem->mService = compare;
+	mManagement->replicateState(0, 0, mStateItem);
+    }
+
+    /**
+     * Destructor for the ServiceLocatorComparator class.
+     *
+     */
+    ~ServiceLocatorComparator()
+    {
+	mManagement->removeState(0, 0, mStateItem);
     }
 
     /**
@@ -130,6 +141,11 @@ public:
     }
 private:
     /**
+     * A pointer to the locator management instance.
+     */
+    ServiceLocatorManagementImplPtr mManagement;
+
+    /**
      * Comparator state replication item.
      */
     ServiceLocatorComparatorStateItemPtr mStateItem;
diff --git a/src/ServiceLocatorManagement.h b/src/ServiceLocatorManagement.h
index 6ff4655..705f853 100644
--- a/src/ServiceLocatorManagement.h
+++ b/src/ServiceLocatorManagement.h
@@ -20,6 +20,8 @@
 
 #include <IceUtil/Shared.h>
 
+#include "ServiceLocatorStateReplicationIf.h"
+
 namespace AsteriskSCF
 {
 namespace ServiceDiscovery
@@ -74,6 +76,12 @@ public:
     // Replication related functions.
     ServiceManagementImplPtr addService(const Ice::ObjectPrx&, const std::string&, const
         Ice::Identity&);
+    void replicateState(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr, 
+        AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsStateItemPtr,
+        AsteriskSCF::Core::Discovery::V1::ServiceLocatorComparatorStateItemPtr);
+    void removeState(AsteriskSCF::Core::Discovery::V1::ServiceLocatorStateItemPtr,
+        AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsStateItemPtr,
+        AsteriskSCF::Core::Discovery::V1::ServiceLocatorComparatorStateItemPtr);	
 
     //
     // AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagement interface.
diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index ff26a02..0c83a69 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -53,7 +53,7 @@ class ServiceLocatorParamsSpec
 public:
     ServiceLocatorParamsSpec(const ServiceLocatorParamsPtr& params,
         const std::string& compareGuid,
-        ServiceLocatorManagementImpl* management)
+        ServiceLocatorManagementImplPtr management)
         :
 	mStateItem(new ServiceLocatorParamsStateItem()),
         mManagement(management)
@@ -61,6 +61,12 @@ public:
 	mStateItem->key = IceUtil::generateUUID();
 	mStateItem->mParams = params;
 	mStateItem->mCompareGuid = compareGuid;
+	mManagement->replicateState(0, mStateItem, 0);
+    }
+
+    ~ServiceLocatorParamsSpec()
+    {
+	mManagement->removeState(0, mStateItem, 0);
     }
 
     void isSupported(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&, const IsSupportedCallbackPtr&);
@@ -74,7 +80,7 @@ private:
     /**
      * A pointer to the service locator management implementation that instantiated this class.
      */
-    ServiceLocatorManagementImpl* mManagement;
+    ServiceLocatorManagementImplPtr mManagement;
 };
 
 /**
@@ -83,7 +89,7 @@ private:
 class ServiceManagementImplPriv
 {
 public:
-    ServiceManagementImplPriv(ServiceManagementImpl* impl, ServiceLocatorManagementImpl* management,
+    ServiceManagementImplPriv(ServiceManagementImpl* impl, ServiceLocatorManagementImplPtr management,
         const Ice::ObjectPrx& service, const Ice::ObjectAdapterPtr& adapter, const AsteriskSCF::System::Discovery::EventsPrx& serviceDiscoveryTopic,
         const string& guid) :
 	mStateItem(new ServiceLocatorServiceStateItem()),
@@ -99,6 +105,7 @@ public:
         {
             mLocatorTopic->serviceRegistered(guid);
         }
+	mManagement->replicateState(mStateItem, 0, 0);
     }
 
     /**
@@ -114,7 +121,7 @@ public:
     /**
      * A pointer to the service locator management implementation that instantiated this call.
      */
-    ServiceLocatorManagementImpl* mManagement;
+    ServiceLocatorManagementImplPtr mManagement;
 
     /**
      * A pointer to the object adapter that this service is available on.
@@ -145,7 +152,7 @@ using namespace AsteriskSCF::System::Discovery;
  * Constructor for the ServiceManagementImpl class. This adds itself to the object adapter so the service can perform some management and
  * also sends out an event for those that are listening.
  */
-ServiceManagementImpl::ServiceManagementImpl(ServiceLocatorManagementImpl* management,
+ServiceManagementImpl::ServiceManagementImpl(ServiceLocatorManagementImplPtr management,
     const Ice::ObjectPrx& service, const Ice::ObjectAdapterPtr& adapter, const EventsPrx& serviceDiscoveryTopic, const string& guid) :
     mImpl(new ServiceManagementImplPriv(this, management, service, adapter, serviceDiscoveryTopic, guid))
 {
@@ -314,6 +321,7 @@ void ServiceManagementImpl::suspend(const Ice::Current&)
     {
         lg(Info) << "Suspending " << mImpl->mStateItem->mGuid << " " << mImpl->mStateItem->mService->ice_toString();
         mImpl->mStateItem->mSuspended = true;
+	mImpl->mManagement->replicateState(mImpl->mStateItem, 0, 0);
     }
 
     if (mImpl->mLocatorTopic)
@@ -333,6 +341,7 @@ void ServiceManagementImpl::unsuspend(const Ice::Current&)
     {
         lg(Info) << "Un-suspending " << mImpl->mStateItem->mGuid << " " << mImpl->mStateItem->mService->ice_toString();
         mImpl->mStateItem->mSuspended = false;
+	mImpl->mManagement->replicateState(mImpl->mStateItem, 0, 0);
     }
 
     if (mImpl->mLocatorTopic)
@@ -364,6 +373,8 @@ void ServiceManagementImpl::unregister(const Ice::Current&)
      */
     lg(Info) << "Un-register " << mImpl->mStateItem->mGuid << " " << mImpl->mStateItem->mService->ice_toString();
 
+    mImpl->mManagement->removeState(mImpl->mStateItem, 0, 0);
+
     mImpl->mAdapter->remove(mImpl->mManagementPrx->ice_getIdentity());
 
     mImpl->mManagement->removeService(this);
diff --git a/src/ServiceManagement.h b/src/ServiceManagement.h
index 24236c1..ecd3e5c 100644
--- a/src/ServiceManagement.h
+++ b/src/ServiceManagement.h
@@ -33,7 +33,7 @@ class ServiceManagementImplPriv;
 class ServiceManagementImpl : public AsteriskSCF::Core::Discovery::V1::ServiceManagement
 {
 public:
-    ServiceManagementImpl(ServiceLocatorManagementImpl*, const Ice::ObjectPrx&, const Ice::ObjectAdapterPtr&,
+    ServiceManagementImpl(ServiceLocatorManagementImplPtr, const Ice::ObjectPrx&, const Ice::ObjectAdapterPtr&,
         const AsteriskSCF::System::Discovery::EventsPrx&, const std::string&);
 
     //

commit a129bc7a69bacda3bb9fdfa7b2c335f6de5c8be6
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Dec 15 14:03:41 2010 -0400

    Add listener implementation for service locator replication.

diff --git a/src/ServiceLocatorManagement.h b/src/ServiceLocatorManagement.h
index 6d9f65d..6ff4655 100644
--- a/src/ServiceLocatorManagement.h
+++ b/src/ServiceLocatorManagement.h
@@ -71,6 +71,10 @@ public:
         const AsteriskSCF::Core::Discovery::V1::AMD_ServiceLocator_locateAllPtr&,
         const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
 
+    // Replication related functions.
+    ServiceManagementImplPtr addService(const Ice::ObjectPrx&, const std::string&, const
+        Ice::Identity&);
+
     //
     // AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagement interface.
     //
@@ -99,5 +103,10 @@ private:
     void finish_isSupported(const Ice::AsyncResultPtr& r);
 };
 
+/**
+ * A typedef which creates a smart pointer type for ServiceLocatorManagementImpl.
+ */
+typedef IceUtil::Handle<ServiceLocatorManagementImpl> ServiceLocatorManagementImplPtr;
+
... 1043 lines suppressed ...


-- 
asterisk-scf/release/servicediscovery.git



More information about the asterisk-scf-commits mailing list