[asterisk-scf-commits] asterisk-scf/integration/servicediscovery.git branch "single-build-dir" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Apr 26 09:05:45 CDT 2011


branch "single-build-dir" has been created
        at  e80e83fa53d5d1c2617f1e87189110d656cb2fd2 (commit)

- Log -----------------------------------------------------------------
commit e80e83fa53d5d1c2617f1e87189110d656cb2fd2
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Mon Apr 25 17:47:30 2011 -0500

    Changes to work with new single-build-directory CMake script.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1e6759a..603e015 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,9 +16,6 @@ if(NOT integrated_build STREQUAL "true")
    # Include common AsteriskSCF build infrastructure
    include(cmake/AsteriskSCF.cmake)
 
-   # This project is C++ based and requires a minimum of 3.4
-   asterisk_scf_project(service_locator 3.4 CXX)
-
    # Take care of slice definitions
    add_subdirectory(slice EXCLUDE_FROM_ALL)
 
@@ -29,5 +26,7 @@ else()
   set(service_locator_bindir ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
 endif()
 
+asterisk_scf_project(service_locator 3.4)
+
 add_subdirectory(src)
 add_subdirectory(test)
diff --git a/config/test_component.config.in b/config/test_component.config
similarity index 86%
rename from config/test_component.config.in
rename to config/test_component.config
index 6d13371..812d22f 100644
--- a/config/test_component.config.in
+++ b/config/test_component.config
@@ -41,7 +41,7 @@ AsteriskSCFIceStorm.Trace.TopicManager=2
 AsteriskSCFIceStorm.Flush.Timeout=2000
 
 # Service Locator State Replicator Configuration
-IceBox.Service.ServiceDiscoveryStateReplicator=../src at ServiceLocatorStateReplicator:create
+IceBox.Service.ServiceDiscoveryStateReplicator=ServiceLocatorStateReplicator:create
 
 # Test endpoints for the state replicator
 ServiceLocatorStateReplicator.Endpoints=tcp -p 4413:udp -p 4413
@@ -49,7 +49,7 @@ ServiceLocatorStateReplicator.Endpoints=tcp -p 4413:udp -p 4413
 #
 # ServiceDiscovery configuration
 #
-IceBox.Service.ServiceDiscovery=../src at service_locator:create
+IceBox.Service.ServiceDiscovery=service_locator:create
 
 # Test endpoints for the service locator local adapter
 ServiceLocatorLocalAdapter.Endpoints=tcp -p 4412
@@ -77,7 +77,7 @@ LoggerAdapter.Endpoints=default
 #
 # test configuration
 #
-IceBox.Service.ServiceDiscoveryTest=. at service_locator_test:create --report_sink=${CMAKE_BINARY_DIR}/service_locator_test-result.xml --report_format=XML --report_level=detailed
+IceBox.Service.ServiceDiscoveryTest=service_locator_test:create
 
 LocatorService.Proxy=LocatorService:tcp -p 4411
 ServiceLocatorManagement.proxy=ServiceLocatorManagement:tcp -p 4422
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 3fc98bd..7c26a40 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -18,10 +18,6 @@ include_directories(${API_INCLUDE_DIR})
 asterisk_scf_component_build_icebox(service_locator_test)
 target_link_libraries(service_locator_test asterisk-scf-api)
 
-icebox_add_test(service_locator_test config/test_component.config)
+asterisk_scf_test_icebox(service_locator_test config/test_component.config)
 
 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/AsteriskSCFIceStorm)
-
-# Copy our test config file to make it available in the test directory.
-# CMake does a bit of search-and-replace, as well.
-configure_file(../config/test_component.config.in ${CMAKE_CURRENT_BINARY_DIR}/config/test_component.config)

commit f885343e02abd41623c86670b4a238011506334d
Author: Joshua Colp <jcolp at digium.com>
Date:   Fri Apr 22 15:58:22 2011 -0300

    Remove an include that should not exist. YOU SEE NOTHING!

diff --git a/src/ServiceLocatorStateReplicatorApp.cpp b/src/ServiceLocatorStateReplicatorApp.cpp
index 244485f..1c03205 100644
--- a/src/ServiceLocatorStateReplicatorApp.cpp
+++ b/src/ServiceLocatorStateReplicatorApp.cpp
@@ -19,8 +19,6 @@
 #include <IceStorm/IceStorm.h>
 #include <IceBox/IceBox.h>
 
-#include <pjlib.h>
-
 #include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
 #include <AsteriskSCF/System/Component/ComponentServiceIf.h>
 #include "ServiceLocatorStateReplicator.h"

commit a5b096d44c9c247cc17f020f3c8702e68c81e86c
Author: Brent Eagles <beagles at digium.com>
Date:   Fri Apr 22 14:56:56 2011 -0230

    Add ASTERISK_SCF_ICEBOX_EXPORT to the IceBox entry point

diff --git a/test/TestServiceLocator.cpp b/test/TestServiceLocator.cpp
index e52e1fc..85a8cbf 100644
--- a/test/TestServiceLocator.cpp
+++ b/test/TestServiceLocator.cpp
@@ -761,7 +761,7 @@ void ServiceLocatorTest::stop()
 
 extern "C"
 {
-IceBox::Service* create(Ice::CommunicatorPtr)
+ASTERISK_SCF_ICEBOX_EXPORT IceBox::Service* create(Ice::CommunicatorPtr)
 {
     return new ServiceLocatorTest;
 }

commit 9d2c897e6ba8aba446b53a61ef8c64f488eb72b0
Author: David M. Lee <dlee at digium.com>
Date:   Thu Apr 21 15:14:50 2011 -0500

    Fixed nested template argument list.
    
    Some compilers require '> >' instead of '>>' for nested templates.

diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index 1fe0318..4e2f30a 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -255,7 +255,7 @@ void ServiceManagementImpl::isSupported(const ServiceLocatorParamsPtr& params, c
     IsSupportedCallbackPtr myCallback = new CountedIsSupported(
         callback, mImpl->mSupportedLocatorParams.size());
 
-    for (vector<boost::shared_ptr<ServiceLocatorParamsSpec>>::iterator
+    for (vector<boost::shared_ptr<ServiceLocatorParamsSpec> >::iterator
              spec = mImpl->mSupportedLocatorParams.begin();
          spec != mImpl->mSupportedLocatorParams.end();
          ++spec)

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 b3da3ccb85932f5668ffb2ff18a67af72a396d93
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Thu Apr 14 13:25:27 2011 -0500

    Minor fixes for various code constructs that trip up GCC with new warning
    options enabled (-Wextra, -Wconversion, -Wformat, and others).

diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index 9c4f70b..4924b0a 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -102,8 +102,8 @@ void ServiceLocatorImpl::locateAll_async(const AMD_ServiceLocator_locateAllPtr&
     mLocatorServiceManagement->locateAll(cb, params);
 }
 
-void ServiceLocatorApp::start(const string& name, const Ice::CommunicatorPtr& communicator,
-    const Ice::StringSeq& args)
+void ServiceLocatorApp::start(const string&, const Ice::CommunicatorPtr& communicator,
+    const Ice::StringSeq&)
 {
     mIceStorm = new AsteriskSCF::ServiceDiscovery::CollocatedIceStorm("AsteriskSCFIceStorm", communicator->getProperties());
 
@@ -210,7 +210,7 @@ void ServiceLocatorApp::stop()
 
 extern "C"
 {
-ASTERISK_SCF_ICEBOX_EXPORT IceBox::Service* create(Ice::CommunicatorPtr communicator)
+ASTERISK_SCF_ICEBOX_EXPORT IceBox::Service* create(Ice::CommunicatorPtr)
 {
     return new ServiceLocatorApp;
 }
diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index 79fc22e..b4d2943 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -174,21 +174,21 @@ class LocateCallback : public IsSupportedCallback
 public:
     LocateCallback(const LocateCollectorPtr& collector,
         const ServiceManagementImplPtr& management) :
-        collector(collector),
-        management(management)
+        mCollector(collector),
+        mManagement(management)
     {
     }
 
-    void result(bool result)
+    void result(bool res)
     {
         // delegation to thread safe object
         // no lock needed
-        collector->invoke(LocateParam(result, management));
-        collector = 0;
+        mCollector->invoke(LocateParam(res, mManagement));
+        mCollector = 0;
     }
 private:
-    LocateCollectorPtr collector;
-    ServiceManagementImplPtr management;
+    LocateCollectorPtr mCollector;
+    ServiceManagementImplPtr mManagement;
 };
 typedef IceUtil::Handle<LocateCallback> LocateCallbackPtr;
 
@@ -368,7 +368,7 @@ void ServiceLocatorManagementImpl::removeCompare(const string& guid, const Ice::
 {
     lg(Info) << "removeCompare(" << guid << ')';
     boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
-    int erased = mImpl->mCompares.erase(guid);
+    std::map<std::string, ServiceLocatorParamsComparePrx>::size_type erased = mImpl->mCompares.erase(guid);
 
     if (!erased)
     {
diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index 6542f01..eeb3fb7 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -189,24 +189,24 @@ class CountedIsSupported :
 {
 public:
     CountedIsSupported(const IsSupportedCallbackPtr& callback, size_t numVotes) :
-        callback(callback)
+        mCallback(callback)
     {
         init(numVotes);
     }
 
-    void result(bool result) { invoke(result); }
+    void result(bool res) { invoke(res); }
 
 protected:
-    void processInvocation(bool result)
+    void processInvocation(bool res)
     {
-        // any affirmitive vote means success
-        if (result)
+        // any affirmative vote means success
+        if (res)
         {
             boost::lock_guard<boost::mutex> guard(mMutex);
-            if (callback)
+            if (mCallback)
             {
-                callback->result(true);
-                callback = 0;
+                mCallback->result(true);
+                mCallback = 0;
             }
         }
     }
@@ -215,15 +215,15 @@ protected:
     {
         boost::lock_guard<boost::mutex> guard(mMutex);
         // all negative votes means failure
-        if (callback)
+        if (mCallback)
         {
-            callback->result(false);
-            callback = 0;
+            mCallback->result(false);
+            mCallback = 0;
         }
     }
 
 private:
-    IsSupportedCallbackPtr callback;
+    IsSupportedCallbackPtr mCallback;
 };
 
 /**
diff --git a/test/TestComparatorBlocking.cpp b/test/TestComparatorBlocking.cpp
index 82294d4..c10b0da 100644
--- a/test/TestComparatorBlocking.cpp
+++ b/test/TestComparatorBlocking.cpp
@@ -90,14 +90,14 @@ class BlockingCallback : public IceUtil::Shared
 public:
     BlockingCallback() : beenCalled(false) {}
 
-    void locateCB(const Ice::ObjectPrx& located)
+    void locateCB(const Ice::ObjectPrx&)
     {
         boost::unique_lock<boost::mutex> lock(mut);
         beenCalled = true;
         cond.notify_one();
     }
 
-    void locateFailureCB(const Ice::Exception& e)
+    void locateFailureCB(const Ice::Exception&)
     {
         boost::unique_lock<boost::mutex> lock(mut);
         beenCalled = true;
diff --git a/test/TestServiceLocator.cpp b/test/TestServiceLocator.cpp
index 3c7292d..e52e1fc 100644
--- a/test/TestServiceLocator.cpp
+++ b/test/TestServiceLocator.cpp
@@ -735,20 +735,20 @@ BOOST_AUTO_TEST_CASE(FindServiceAfterUnregister)
     BOOST_CHECK(!found);
 }
 
-void ServiceLocatorTest::start(std::string const &name,
-    Ice::CommunicatorPtr const &communicator,
-    Ice::StringSeq const &args)
+void ServiceLocatorTest::start(std::string const& name,
+    Ice::CommunicatorPtr const&,
+    Ice::StringSeq const& args)
 {
     std::vector<char const *> argv;
     argv.push_back(name.c_str());
     for (Ice::StringSeq::const_iterator i = args.begin(); i != args.end(); ++i)
     {
         argv.push_back(i->c_str());
+	mCachedArgs.argc++;
     }
     // null terminated list
     argv.push_back((const char*)0);
 
-    mCachedArgs.argc = argv.size() - 1;
     mCachedArgs.argv = (char**)&argv[0];
 
     int r = ::boost::unit_test::unit_test_main(&init_unit_test, mCachedArgs.argc, mCachedArgs.argv);
@@ -761,7 +761,7 @@ void ServiceLocatorTest::stop()
 
 extern "C"
 {
-IceBox::Service* create(Ice::CommunicatorPtr communicator)
+IceBox::Service* create(Ice::CommunicatorPtr)
 {
     return new ServiceLocatorTest;
 }

commit d9ef2a8b4092b1258b81e8df01c1c052edb2517f
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Mon Mar 14 06:16:28 2011 -0500

    Update to accommodate DynamicLibrary moving to IceUtilInternal.

diff --git a/src/CollocatedIceStorm.cpp b/src/CollocatedIceStorm.cpp
index dbffcf3..54c05fc 100644
--- a/src/CollocatedIceStorm.cpp
+++ b/src/CollocatedIceStorm.cpp
@@ -40,8 +40,8 @@ CollocatedIceStorm::CollocatedIceStorm(const std::string& namePrefix, const Ice:
 
     std::string loadString = mCommunicator->getProperties()->getPropertyWithDefault("IceStorm.EntryPoint", "IceStormService:createIceStorm");
 
-    mLibrary = new IceInternal::DynamicLibrary;
-    IceInternal::DynamicLibrary::symbol_type entry = mLibrary->loadEntryPoint(loadString);
+    mLibrary = new IceUtilInternal::DynamicLibrary;
+    IceUtilInternal::DynamicLibrary::symbol_type entry = mLibrary->loadEntryPoint(loadString);
     if(entry == 0)
     {
         throw mLibrary->getErrorMessage();
diff --git a/src/CollocatedIceStorm.h b/src/CollocatedIceStorm.h
index e8b5da5..fb598ae 100644
--- a/src/CollocatedIceStorm.h
+++ b/src/CollocatedIceStorm.h
@@ -15,7 +15,7 @@
  */
 #pragma once
 
-#include <Ice/DynamicLibrary.h>
+#include <IceUtil/DynamicLibrary.h>
 #include <Ice/Service.h>
 #include <IceBox/IceBox.h>
 #include <Ice/Ice.h>
@@ -43,7 +43,7 @@ public:
     void stop();
 
 private:
-    IceInternal::DynamicLibraryPtr mLibrary;
+    IceUtilInternal::DynamicLibraryPtr mLibrary;
     IceBox::ServicePtr mService;
     Ice::CommunicatorPtr mCommunicator;
     bool mStopped;

commit b9e4e5d98418a006dd18cfe54935607a4a80a7a1
Author: David M. Lee <dlee at digium.com>
Date:   Mon Feb 21 09:36:03 2011 -0600

    Fixed for new ClassMemberDefault slice translator plugin.

diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index 5bc0c74..79fc22e 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -317,7 +317,7 @@ ServiceInfoSeq ServiceLocatorManagementImpl::getServices(const ::Ice::Current&)
          i != mImpl->mServices.end();
          ++i)
     {
-        ServiceInfo v = {(*i)->getGuid(), (*i)->getServiceManagementPrx(), (*i)->getStatus(), (*i)->getService()};
+        ServiceInfo v((*i)->getGuid(), (*i)->getServiceManagementPrx(), (*i)->getStatus(), (*i)->getService());
         r.push_back(v);
     }
     return r;
@@ -331,7 +331,7 @@ ServiceInfo ServiceLocatorManagementImpl::getService(const std::string &guid, co
          ++i)
     {
         if (guid == (*i)->getGuid()) {
-            ServiceInfo r = {(*i)->getGuid(), (*i)->getServiceManagementPrx(), (*i)->getStatus(), (*i)->getService()};
+            ServiceInfo r((*i)->getGuid(), (*i)->getServiceManagementPrx(), (*i)->getStatus(), (*i)->getService());
             return r;
         }
     }

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();
... 20797 lines suppressed ...


-- 
asterisk-scf/integration/servicediscovery.git



More information about the asterisk-scf-commits mailing list