[asterisk-scf-commits] asterisk-scf/release/sip.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Mon May 23 10:19:11 CDT 2011
branch "master" has been updated
via 6e45f7d7d7ec3e8be48c53e0b581a946171b1c59 (commit)
via 5e0a6d5fd9e409306d77ec066506a8de6afa6be4 (commit)
via 5c696c9882975b9feb11c4ea2d535378e77bcd04 (commit)
via a7f1600075e5990bbecef9f273bf8cb0af77f444 (commit)
from 98584e0f7b7db43e806c59053c5c3df397152521 (commit)
Summary of changes:
config/test_sip_state_replicator.conf | 8 ++
local-slice/SipConfigurationIf.ice | 18 +++++
local-slice/SipStateReplicationIf.ice | 17 +++--
src/CMakeLists.txt | 2 +
src/SipSessionManagerApp.cpp | 75 ++++++++++++++++++++-
src/SipStateReplicatorApp.cpp | 119 +++++++++++++++++++++++++++++++++
6 files changed, 230 insertions(+), 9 deletions(-)
- Log -----------------------------------------------------------------
commit 6e45f7d7d7ec3e8be48c53e0b581a946171b1c59
Author: Joshua Colp <jcolp at digium.com>
Date: Mon May 23 11:59:33 2011 -0300
Use configuration replicator interface.
diff --git a/local-slice/SipStateReplicationIf.ice b/local-slice/SipStateReplicationIf.ice
index 28f7c1e..aae6991 100644
--- a/local-slice/SipStateReplicationIf.ice
+++ b/local-slice/SipStateReplicationIf.ice
@@ -59,7 +59,6 @@ module V1
void removeState(Ice::StringSeq items);
idempotent SipStateItemSeq getState(Ice::StringSeq itemKeys);
idempotent SipStateItemSeq getAllState();
- void registerConfigurationService(AsteriskSCF::System::Configuration::V1::ConfigurationService *service);
};
class SipDialogStateItem extends SipStateItem
{
diff --git a/src/SipSessionManagerApp.cpp b/src/SipSessionManagerApp.cpp
index 1db81f4..5500578 100644
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@ -462,7 +462,9 @@ void SipSessionManager::registerWithStateReplicator()
mLocalAdapter->createDirectProxy(mCommunicator->stringToIdentity(ConfigurationServiceId));
ConfigurationServicePrx configurationServicePrx = ConfigurationServicePrx::uncheckedCast(
configurationServiceObjectPrx);
- mStateReplicator->registerConfigurationService(configurationServicePrx);
+ ConfigurationReplicatorPrx configurationReplicator = ConfigurationReplicatorPrx::checkedCast(
+ mStateReplicator.initialize(), ReplicatorFacet);
+ configurationReplicator->registerConfigurationService(configurationServicePrx);
}
if (mCommunicator->getProperties()->getPropertyWithDefault("Sip.StateReplicatorListener", "no") == "yes")
diff --git a/src/SipStateReplicatorApp.cpp b/src/SipStateReplicatorApp.cpp
index 09eb741..a93b109 100644
--- a/src/SipStateReplicatorApp.cpp
+++ b/src/SipStateReplicatorApp.cpp
@@ -26,6 +26,7 @@
#include <AsteriskSCF/logger.h>
#include <AsteriskSCF/Logger/IceLogger.h>
#include <AsteriskSCF/CollocatedIceStorm/CollocatedIceStorm.h>
+#include <AsteriskSCF/System/Component/ConfigurationIf.h>
#include <SipIf.h>
@@ -39,6 +40,7 @@ using namespace AsteriskSCF::System::Component::V1;
using namespace AsteriskSCF::System::Logging;
using namespace AsteriskSCF::SipSessionManager;
using namespace AsteriskSCF::CollocatedIceStorm;
+using namespace AsteriskSCF::System::Configuration::V1;
namespace
{
@@ -54,6 +56,7 @@ public:
mComponentService = 0;
mAdapter = 0;
mStateReplicator = 0;
+ mConfigurationReplicator = 0;
};
virtual void start(const string &name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq& args);
virtual void stop();
@@ -70,6 +73,7 @@ private:
ConfiguredIceLoggerPtr mIceLogger;
ComponentServicePtr mComponentService;
SipStateReplicatorIPtr mStateReplicator;
+ ConfigurationReplicatorPtr mConfigurationReplicator;
CollocatedIceStormPtr mIceStorm;
Ice::ObjectPrx mConfigurationPublisher;
Discovery::V1::ServiceManagementPrx mConfigurationManagement;
@@ -146,16 +150,16 @@ private:
typedef IceUtil::Handle<SipConfigurationCompare> SipConfigurationComparePtr;
-class SipStateReplicatorConfigI : public SipStateReplicatorI
+class ConfigurationReplicatorI : public ConfigurationReplicator
{
public:
- SipStateReplicatorConfigI(const IceStorm::TopicPrx& topic) : mConfigurationReplicationTopic(topic) { };
+ ConfigurationReplicatorI(const IceStorm::TopicPrx& topic) : mConfigurationReplicationTopic(topic) { };
void registerConfigurationService(const AsteriskSCF::System::Configuration::V1::ConfigurationServicePrx&, const Ice::Current&);
private:
IceStorm::TopicPrx mConfigurationReplicationTopic;
};
-void SipStateReplicatorConfigI::registerConfigurationService(const AsteriskSCF::System::Configuration::V1::ConfigurationServicePrx& service, const Ice::Current&)
+void ConfigurationReplicatorI::registerConfigurationService(const AsteriskSCF::System::Configuration::V1::ConfigurationServicePrx& service, const Ice::Current&)
{
if (mConfigurationReplicationTopic)
{
@@ -319,8 +323,11 @@ void SipStateReplicatorService::initialize(const std::string& appName, const Ice
// Create and publish our ComponentService interface support.
mComponentService = new ComponentServiceImpl(*this);
mAdapter->add(mComponentService, ic->stringToIdentity(ComponentServiceId));
- mStateReplicator = new SipStateReplicatorConfigI(topic);
+ mStateReplicator = new SipStateReplicatorI();
mAdapter->add(mStateReplicator, ic->stringToIdentity(ServiceDiscoveryId));
+ mConfigurationReplicator = new ConfigurationReplicatorI(topic);
+ mAdapter->addFacet(mConfigurationReplicator, ic->stringToIdentity(ServiceDiscoveryId),
+ ReplicatorFacet);
mAdapter->activate();
}
commit 5e0a6d5fd9e409306d77ec066506a8de6afa6be4
Merge: 5c696c9 98584e0
Author: Joshua Colp <jcolp at digium.com>
Date: Mon May 23 11:45:35 2011 -0300
Merge branch 'master' into configuration-replication
commit 5c696c9882975b9feb11c4ea2d535378e77bcd04
Author: Joshua Colp <jcolp at digium.com>
Date: Tue May 17 14:29:26 2011 -0300
Add support for finding the configuration service using service locator.
diff --git a/config/SipConfigurator.py b/config/SipConfigurator.py
index d04f2ac..9d7ed3e 100755
--- a/config/SipConfigurator.py
+++ b/config/SipConfigurator.py
@@ -161,6 +161,10 @@ class SipSectionVisitors(Configurator.SectionVisitors):
elif config.get(section, 'type') == 'endpoint':
self.visit_endpoint(config, section)
+# In order to do service locator based lookup we need to pass in a params object
+serviceLocatorParams = AsteriskSCF.SIP.V1.SipConfigurationParams()
+serviceLocatorParams.category = AsteriskSCF.SIP.V1.ConfigurationDiscoveryCategory
+
# Make a configurator application and let it run
-app = Configurator.ConfiguratorApp('Sip.config', SipSectionVisitors())
+app = Configurator.ConfiguratorApp('Sip.config', SipSectionVisitors(), None, serviceLocatorParams)
sys.exit(app.main(sys.argv))
diff --git a/config/test_sip_state_replicator.conf b/config/test_sip_state_replicator.conf
index 0a35cda..e7e7c6f 100644
--- a/config/test_sip_state_replicator.conf
+++ b/config/test_sip_state_replicator.conf
@@ -23,4 +23,4 @@ SipStateReplicatorIceStorm.Publish.Endpoints=default -p 10008
SipStateReplicatorIceStorm.Trace.TopicManager=2
SipStateReplicatorIceStorm.Transient=1
SipStateReplicatorIceStorm.Flush.Timeout=2000
-SipStateReplicatorTopicManager.Proxy=SipStateReplicatorIceStorm/TopicManager:default -p 10008
+SipStateReplicatorTopicManager.Proxy=SipStateReplicatorIceStorm/TopicManager:default -p 10007
commit a7f1600075e5990bbecef9f273bf8cb0af77f444
Author: Joshua Colp <jcolp at digium.com>
Date: Tue May 17 11:15:14 2011 -0300
Add support for replicating configuration to the SIP component.
diff --git a/config/test_sip_state_replicator.conf b/config/test_sip_state_replicator.conf
index 89af225..0a35cda 100644
--- a/config/test_sip_state_replicator.conf
+++ b/config/test_sip_state_replicator.conf
@@ -16,3 +16,11 @@ SipStateReplicator.Name=default
IceBox.InheritProperties = 1
IceBox.Service.SipStateReplicator=SipStateReplicator:create
+
+SipStateReplicatorIceStorm.InstanceName=SipStateReplicatorIceStorm
+SipStateReplicatorIceStorm.TopicManager.Endpoints=default -p 10007
+SipStateReplicatorIceStorm.Publish.Endpoints=default -p 10008
+SipStateReplicatorIceStorm.Trace.TopicManager=2
+SipStateReplicatorIceStorm.Transient=1
+SipStateReplicatorIceStorm.Flush.Timeout=2000
+SipStateReplicatorTopicManager.Proxy=SipStateReplicatorIceStorm/TopicManager:default -p 10008
diff --git a/local-slice/SipConfigurationIf.ice b/local-slice/SipConfigurationIf.ice
index 58cae24..6cd18d9 100644
--- a/local-slice/SipConfigurationIf.ice
+++ b/local-slice/SipConfigurationIf.ice
@@ -15,7 +15,9 @@
*/
#pragma once
+
#include <Ice/BuiltinSequences.ice>
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.ice>
#include <AsteriskSCF/System/Component/ConfigurationIf.ice>
module AsteriskSCF
@@ -26,6 +28,22 @@ module SIP
module V1
{
/**
+ * Service locator category for finding the configuration service
+ */
+ const string ConfigurationDiscoveryCategory = "SipConfiguration";
+
+ /**
+ * Service locator parameters class for discovering the configuration service
+ */
+ unsliceable class SipConfigurationParams extends AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams
+ {
+ /**
+ * Unique name for the configuration service
+ */
+ string name;
+ };
+
+ /**
* Local visitor class for visiting SIP configuration groups
*/
local class SipConfigurationGroupVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationGroupVisitor
diff --git a/local-slice/SipStateReplicationIf.ice b/local-slice/SipStateReplicationIf.ice
index c7d16d9..28f7c1e 100644
--- a/local-slice/SipStateReplicationIf.ice
+++ b/local-slice/SipStateReplicationIf.ice
@@ -17,9 +17,10 @@
#pragma once
#include <Ice/BuiltinSequences.ice>
#include <Ice/Identity.ice>
-#include "AsteriskSCF/Media/MediaIf.ice"
-#include "AsteriskSCF/SessionCommunications/SessionCommunicationsIf.ice"
-#include "AsteriskSCF/Core/Discovery/ServiceLocatorIf.ice"
+#include <AsteriskSCF/Media/MediaIf.ice>
+#include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.ice>
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.ice>
+#include <AsteriskSCF/System/Component/ConfigurationIf.ice>
module AsteriskSCF
{
@@ -53,11 +54,12 @@ module V1
interface SipStateReplicator
{
void addListener(SipStateReplicatorListener *listener);
- void removeListener(SipStateReplicatorListener *listener);
- void setState (SipStateItemSeq items);
- void removeState(Ice::StringSeq items);
- idempotent SipStateItemSeq getState(Ice::StringSeq itemKeys);
- idempotent SipStateItemSeq getAllState();
+ void removeListener(SipStateReplicatorListener *listener);
+ void setState (SipStateItemSeq items);
+ void removeState(Ice::StringSeq items);
+ idempotent SipStateItemSeq getState(Ice::StringSeq itemKeys);
+ idempotent SipStateItemSeq getAllState();
+ void registerConfigurationService(AsteriskSCF::System::Configuration::V1::ConfigurationService *service);
};
class SipDialogStateItem extends SipStateItem
{
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 202b875..e9acf99 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -58,9 +58,11 @@ asterisk_scf_component_add_file(SipStateReplicator SipStateReplicatorApp.cpp)
asterisk_scf_component_add_file(SipStateReplicator SipStateReplicator.h)
asterisk_scf_component_add_slice(SipStateReplicator ../local-slice/SipStateReplicationIf.ice)
asterisk_scf_component_add_slice(SipStateReplicator ../local-slice/SipIf.ice)
+asterisk_scf_component_add_slice(SipStateReplicator ../local-slice/SipConfigurationIf.ice)
asterisk_scf_component_add_ice_libraries(SipStateReplicator IceStorm)
asterisk_scf_component_add_boost_libraries(SipStateReplicator thread date_time)
asterisk_scf_component_build_icebox(SipStateReplicator)
target_link_libraries(SipStateReplicator logging-client)
target_link_libraries(SipStateReplicator asterisk-scf-api)
+target_link_libraries(SipStateReplicator ice-util-cpp)
asterisk_scf_component_install(SipStateReplicator)
diff --git a/src/SipSessionManagerApp.cpp b/src/SipSessionManagerApp.cpp
index 2644402..1db81f4 100644
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@ -19,6 +19,7 @@
#include <Ice/Ice.h>
#include <IceStorm/IceStorm.h>
#include <IceBox/IceBox.h>
+#include <IceUtil/UUID.h>
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
@@ -116,6 +117,8 @@ private:
ServiceLocatorManagementPrx mServiceLocatorManagement;
ServiceManagementPrx mComponentServiceManagement;
+ ServiceManagementPrx mConfigurationManagement;
+ std::string mConfigCompareGuid;
ReplicaPtr mReplicaService;
ComponentServicePtr mComponentService;
ConfigurationServicePtr mConfigurationService;
@@ -283,6 +286,28 @@ private:
};
/**
+ * Comparator implementation for name based configuration service locating
+ */
+class SipConfigurationCompare : public ServiceLocatorParamsCompare
+{
+public:
+ SipConfigurationCompare(const string& name) : mName(name) {}
+ bool isSupported(const ServiceLocatorParamsPtr ¶ms, const Ice::Current &)
+ {
+ SipConfigurationParamsPtr configParams = SipConfigurationParamsPtr::dynamicCast(params);
+ if (configParams->name == mName)
+ {
+ return true;
+ }
+ return false;
+ }
+private:
+ string mName;
+};
+
+typedef IceUtil::Handle<SipConfigurationCompare> SipConfigurationComparePtr;
+
+/**
* Helper function to add some parameters to one of our registered interfaces in the ServiceLocator, so that
* other components can look up our interfaces.
*/
@@ -325,6 +350,29 @@ void SipSessionManager::registerWithServiceLocator()
setCategory(mComponentServiceManagement, AsteriskSCF::SIP::V1::ComponentServiceDiscoveryCategory);
+ if (mCommunicator->getProperties()->getPropertyWithDefault("Sip.Standalone", "false") == "true")
+ {
+ // Publish the configuration service IceStorm topic so everybody gets configuration
+ Ice::ObjectPrx configurationServicePrx =
+ mLocalAdapter->createDirectProxy(mCommunicator->stringToIdentity(ConfigurationServiceId));
+ mConfigurationManagement = ServiceManagementPrx::uncheckedCast(
+ mServiceLocatorManagement->addService(configurationServicePrx, ""));
+
+ // Populate the configuration parameters with details so we can be found
+ SipConfigurationParamsPtr configurationParams = new SipConfigurationParams();
+ configurationParams->category = ConfigurationDiscoveryCategory;
+ configurationParams->name = mCommunicator->getProperties()->getPropertyWithDefault("SipConfiguration.Name", "");
+
+ // Add our custom comparator so we can support multiple simultaneous configuration sinks
+ SipConfigurationComparePtr configNameCompare = new SipConfigurationCompare(configurationParams->name);
+ ServiceLocatorParamsComparePrx configCompareProxy = ServiceLocatorParamsComparePrx::uncheckedCast(
+ mLocalAdapter->addWithUUID(configNameCompare));
+
+ mConfigCompareGuid = IceUtil::generateUUID();
+ mServiceLocatorManagement->addCompare(mConfigCompareGuid, configCompareProxy);
+ mConfigurationManagement->addLocatorParams(configurationParams, mConfigCompareGuid);
+ }
+
// TBD... We may have other interfaces to publish to the Service Locator.
}
catch(...)
@@ -408,6 +456,15 @@ void SipSessionManager::registerWithStateReplicator()
return;
}
+ if (mCommunicator->getProperties()->getPropertyWithDefault("Rtp.Standalone", "false") == "false")
+ {
+ Ice::ObjectPrx configurationServiceObjectPrx =
+ mLocalAdapter->createDirectProxy(mCommunicator->stringToIdentity(ConfigurationServiceId));
+ ConfigurationServicePrx configurationServicePrx = ConfigurationServicePrx::uncheckedCast(
+ configurationServiceObjectPrx);
+ mStateReplicator->registerConfigurationService(configurationServicePrx);
+ }
+
if (mCommunicator->getProperties()->getPropertyWithDefault("Sip.StateReplicatorListener", "no") == "yes")
{
mStateReplicator->addListener(mReplicatorListenerProxy);
@@ -443,6 +500,10 @@ void SipSessionManager::deregisterFromServiceLocator()
try
{
mComponentServiceManagement->unregister();
+ if (mConfigurationManagement)
+ {
+ mConfigurationManagement->unregister();
+ }
}
catch(...)
{
@@ -489,6 +550,16 @@ void SipSessionManager::registerPJSipModules()
void SipSessionManager::deregisterFromStateReplicator()
{
+ if (!mConfigCompareGuid.empty())
+ {
+ mServiceLocatorManagement->removeCompare(mConfigCompareGuid);
+ }
+
+ if (mConfigurationManagement)
+ {
+ mConfigurationManagement->unregister();
+ }
+
if (mReplicaService->isActive() == true)
{
return;
@@ -549,7 +620,7 @@ void SipSessionManager::initialize(const string& appName, const Ice::Communicato
// Create and publish our Configuration interface support.
mConfigurationService = createConfigurationServant(mPJSipManager, mEndpointFactory, mRoutingId, mRoutingServiceLocatorRegistry);
- mGlobalAdapter->add(mConfigurationService, mCommunicator->stringToIdentity(ConfigurationServiceId));
+ mLocalAdapter->add(mConfigurationService, mCommunicator->stringToIdentity(ConfigurationServiceId));
lg(Debug) << "Created SIP Configuration Implementation";
// Create and configure our Endpoint Locator.
diff --git a/src/SipStateReplicatorApp.cpp b/src/SipStateReplicatorApp.cpp
index c6cb96a..09eb741 100644
--- a/src/SipStateReplicatorApp.cpp
+++ b/src/SipStateReplicatorApp.cpp
@@ -25,9 +25,12 @@
#include <AsteriskSCF/System/Component/ComponentServiceIf.h>
#include <AsteriskSCF/logger.h>
#include <AsteriskSCF/Logger/IceLogger.h>
+#include <AsteriskSCF/CollocatedIceStorm/CollocatedIceStorm.h>
#include <SipIf.h>
+#include "SipConfigurationIf.h"
+
using namespace std;
using namespace AsteriskSCF::Core;
using namespace AsteriskSCF::Core::Discovery::V1;
@@ -35,6 +38,7 @@ using namespace AsteriskSCF::SIP::V1;
using namespace AsteriskSCF::System::Component::V1;
using namespace AsteriskSCF::System::Logging;
using namespace AsteriskSCF::SipSessionManager;
+using namespace AsteriskSCF::CollocatedIceStorm;
namespace
{
@@ -66,6 +70,10 @@ private:
ConfiguredIceLoggerPtr mIceLogger;
ComponentServicePtr mComponentService;
SipStateReplicatorIPtr mStateReplicator;
+ CollocatedIceStormPtr mIceStorm;
+ Ice::ObjectPrx mConfigurationPublisher;
+ Discovery::V1::ServiceManagementPrx mConfigurationManagement;
+ std::string mConfigCompareGuid;
};
static const string ComponentServiceId("SipStateReplicatorComponent");
@@ -119,6 +127,53 @@ private:
typedef IceUtil::Handle<SipStateReplicatorCompare> SipStateReplicatorComparePtr;
+class SipConfigurationCompare : public ServiceLocatorParamsCompare
+{
+public:
+ SipConfigurationCompare(const string& name) : mName(name) {}
+ bool isSupported(const ServiceLocatorParamsPtr ¶ms, const Ice::Current &)
+ {
+ SipConfigurationParamsPtr configParams = SipConfigurationParamsPtr::dynamicCast(params);
+ if (configParams->name == mName)
+ {
+ return true;
+ }
+ return false;
+ }
+private:
+ string mName;
+};
+
+typedef IceUtil::Handle<SipConfigurationCompare> SipConfigurationComparePtr;
+
+class SipStateReplicatorConfigI : public SipStateReplicatorI
+{
+public:
+ SipStateReplicatorConfigI(const IceStorm::TopicPrx& topic) : mConfigurationReplicationTopic(topic) { };
+ void registerConfigurationService(const AsteriskSCF::System::Configuration::V1::ConfigurationServicePrx&, const Ice::Current&);
+private:
+ IceStorm::TopicPrx mConfigurationReplicationTopic;
+};
+
+void SipStateReplicatorConfigI::registerConfigurationService(const AsteriskSCF::System::Configuration::V1::ConfigurationServicePrx& service, const Ice::Current&)
+{
+ if (mConfigurationReplicationTopic)
+ {
+ IceStorm::QoS qos;
+ qos["reliability"] = "ordered";
+
+ try
+ {
+ mConfigurationReplicationTopic->subscribeAndGetPublisher(qos, service);
+ }
+ catch (const IceStorm::AlreadySubscribed&)
+ {
+ // This is perfectly okay actually, it just means what they wanted us to do
+ // is already done.
+ }
+ }
+}
+
/**
* Register this component's primary public interfaces with the Service Locator.
* This enables other Asterisk SCF components to locate our interfaces.
@@ -173,6 +228,24 @@ void SipStateReplicatorService::registerWithServiceLocator(const Ice::Communicat
mServiceLocatorManagement->addCompare(compareGuid, compareProxy);
mStateReplicationManagement->addLocatorParams(discoveryParams, compareGuid);
+ // Publish the configuration service IceStorm topic so everybody gets configuration
+ mConfigurationManagement = ServiceManagementPrx::uncheckedCast(
+ mServiceLocatorManagement->addService(mConfigurationPublisher, ""));
+
+ // Populate the configuration parameters with details so we can be found
+ SipConfigurationParamsPtr configurationParams = new SipConfigurationParams();
+ configurationParams->category = ConfigurationDiscoveryCategory;
+ configurationParams->name = ic->getProperties()->getPropertyWithDefault("SipConfiguration.Name", "");
+
+ // Add our custom comparator so we can support multiple simultaneous configuration sinks
+ SipConfigurationComparePtr configNameCompare = new SipConfigurationCompare(configurationParams->name);
+ ServiceLocatorParamsComparePrx configCompareProxy = ServiceLocatorParamsComparePrx::uncheckedCast(
+ mAdapter->addWithUUID(configNameCompare));
+
+ mConfigCompareGuid = IceUtil::generateUUID();
+ mServiceLocatorManagement->addCompare(mConfigCompareGuid, configCompareProxy);
+ mConfigurationManagement->addLocatorParams(configurationParams, mConfigCompareGuid);
+
// TBD... We may have other interfaces to publish to the Service Locator.
}
catch(...)
@@ -191,6 +264,8 @@ void SipStateReplicatorService::deregisterFromServiceLocator()
try
{
mComponentServiceManagement->unregister();
+ mConfigurationManagement->unregister();
+ mServiceLocatorManagement->removeCompare(mConfigCompareGuid);
}
catch(...)
{
@@ -200,6 +275,40 @@ void SipStateReplicatorService::deregisterFromServiceLocator()
void SipStateReplicatorService::initialize(const std::string& appName, const Ice::CommunicatorPtr& ic)
{
+ mIceStorm = new CollocatedIceStorm("SipStateReplicatorIceStorm", ic->getProperties());
+
+ IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(
+ ic->propertyToProxy("SipStateReplicatorTopicManager.Proxy"));
+
+ IceStorm::TopicPrx topic;
+
+ if (topicManager)
+ {
+ try
+ {
+ topic = topicManager->retrieve("ConfigurationReplication");
+ }
+ catch (const IceStorm::NoSuchTopic&)
+ {
+ try
+ {
+ topic = topicManager->create("ConfigurationReplication");
+ }
+ catch (const IceStorm::TopicExists&)
+ {
+ lg(Error) << "Oh snap! Race condition creating topic, aborting";
+ return;
+ }
+ }
+ // There is no cast here on purpose as this is just going to get passed to
+ // the service locator which just takes a plain ol' proxy anyway.
+ mConfigurationPublisher = topic->getPublisher();
+ }
+ else
+ {
+ lg(Info) << "IceStorm topic manager proxy not present, unable to perform configuration replication.";
+ }
+
mAdapter = ic->createObjectAdapter("SipStateReplicator");
// setup logging client
@@ -210,7 +319,7 @@ void SipStateReplicatorService::initialize(const std::string& appName, const Ice
// Create and publish our ComponentService interface support.
mComponentService = new ComponentServiceImpl(*this);
mAdapter->add(mComponentService, ic->stringToIdentity(ComponentServiceId));
- mStateReplicator = new SipStateReplicatorI();
+ mStateReplicator = new SipStateReplicatorConfigI(topic);
mAdapter->add(mStateReplicator, ic->stringToIdentity(ServiceDiscoveryId));
mAdapter->activate();
@@ -228,6 +337,9 @@ void SipStateReplicatorService::stop()
{
// Remove our interfaces from the service locator.
deregisterFromServiceLocator();
+
+ // Stop our local IceStorm instance
+ mIceStorm->stop();
}
extern "C"
-----------------------------------------------------------------------
--
asterisk-scf/release/sip.git
More information about the asterisk-scf-commits
mailing list