[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Sep 21 15:58:46 CDT 2010
branch "master" has been updated
via 936ad79cdb9b6db021cbe53d2942bfe547d0d2c5 (commit)
via 8cc5a526df31b148959e8eac16dce114dbfe1883 (commit)
via 5582c8d392ebd7fd5352419ec6216ea3f0d44bfa (commit)
from b4a2c5e0d7587cde80ae11bbda2d3139bb6a574b (commit)
Summary of changes:
config/test_sip.conf | 3 +
local-slice/SipStateReplicationIf.ice | 8 +++
src/SipChannelServiceApp.cpp | 7 +-
src/SipStateReplicator.cpp | 22 +++++---
src/SipStateReplicator.h | 18 ++++--
src/SipStateReplicatorApp.cpp | 100 ++++++++++++++++++++-------------
6 files changed, 100 insertions(+), 58 deletions(-)
- Log -----------------------------------------------------------------
commit 936ad79cdb9b6db021cbe53d2942bfe547d0d2c5
Merge: 8cc5a52 b4a2c5e
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Sep 21 15:59:13 2010 -0500
Merge branch 'master' of git.asterisk.org:asterisk-scf/integration/sip
Conflicts:
src/SipStateReplicator.cpp
diff --cc local-slice/SipStateReplicationIf.ice
index 65a574a,90ac4a2..5c2497b
--- a/local-slice/SipStateReplicationIf.ice
+++ b/local-slice/SipStateReplicationIf.ice
@@@ -1,8 -1,8 +1,9 @@@
#pragma once
#include <Ice/BuiltinSequences.ice>
+ #include <Ice/Identity.ice>
#include "Media/MediaIf.ice"
#include "SessionCommunications/SessionCommunicationsIf.ice"
+#include "Core/Discovery/ServiceLocatorIf.ice"
module AsteriskSCF
{
diff --cc src/SipStateReplicator.cpp
index 9a3ddde,4a744a7..f4b14fe
--- a/src/SipStateReplicator.cpp
+++ b/src/SipStateReplicator.cpp
@@@ -115,47 -117,5 +118,10 @@@ SipStateItemSeq SipStateReplicatorI::ge
return mImpl->getAllStatesImpl();
}
+std::string SipStateReplicatorI::getName()
+{
+ return mImpl->mName;
+}
+
- struct SipStateReplicatorListenerImpl
- {
- public:
- SipStateReplicatorListenerImpl() : mId(IceUtil::generateUUID()) {}
- void removeStateNoticeImpl(Ice::StringSeq itemKeys)
- {
- //stub
- }
- void setStateNoticeImpl(SipStateItemSeq items)
- {
- //stub
- }
- std::string mId;
- };
-
- SipStateReplicatorListenerI::SipStateReplicatorListenerI() : mImpl(new SipStateReplicatorListenerImpl) {}
-
- SipStateReplicatorListenerI::~SipStateReplicatorListenerI()
- {
- delete mImpl;
- }
-
- void SipStateReplicatorListenerI::removeStateNotice(Ice::StringSeq itemKeys, Ice::Current &)
- {
- mImpl->removeStateNoticeImpl(itemKeys);
- }
-
- void SipStateReplicatorListenerI::setStateNotice(SipStateItemSeq items, Ice::Current &)
- {
- mImpl->setStateNoticeImpl(items);
- }
-
- bool SipStateReplicatorListenerI::operator==(SipStateReplicatorListenerI &rhs)
- {
- return mImpl->mId == rhs.mImpl->mId;
- }
-
};
};
commit 8cc5a526df31b148959e8eac16dce114dbfe1883
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Sep 21 15:52:56 2010 -0500
Add Sip State Replication comparator to compare passed-in name to stored one.
Use such parameters in SipChannelService to determine which state replicator to use.
Add sample configuration.
diff --git a/config/test_sip.conf b/config/test_sip.conf
index 906f7f6..8de569a 100644
--- a/config/test_sip.conf
+++ b/config/test_sip.conf
@@ -19,6 +19,9 @@ Sip.Modules=Session
# UDP Bind address.
Sip.Transport.UdpBindAddr=0.0.0.0:5060
+# The name of the State replicator to use
+Sip.StateReplicatorName=default
+
# Endpoints that we know about
Sip.Endpoints=cisco 18005558355
diff --git a/local-slice/SipStateReplicationIf.ice b/local-slice/SipStateReplicationIf.ice
index 4483bc7..65a574a 100644
--- a/local-slice/SipStateReplicationIf.ice
+++ b/local-slice/SipStateReplicationIf.ice
@@ -2,6 +2,7 @@
#include <Ice/BuiltinSequences.ice>
#include "Media/MediaIf.ice"
#include "SessionCommunications/SessionCommunicationsIf.ice"
+#include "Core/Discovery/ServiceLocatorIf.ice"
module AsteriskSCF
{
@@ -11,6 +12,13 @@ module SIP
module V1
{
const string StateReplicatorDiscoveryCategory = "SipStateReplicator";
+ const string StateReplicatorCompareGuid = "SipStateReplicatorCompare";
+
+ class SipStateReplicatorParams extends AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams
+ {
+ string mName;
+ };
+
class SipStateItem
{
string mId;
diff --git a/src/SipChannelServiceApp.cpp b/src/SipChannelServiceApp.cpp
index 5a6bb95..ac49a42 100644
--- a/src/SipChannelServiceApp.cpp
+++ b/src/SipChannelServiceApp.cpp
@@ -366,12 +366,13 @@ void SipChannelServiceApp::locateStateReplicator()
mDataModelInstance.mServiceLocator = ServiceLocatorPrx::checkedCast(communicator()->propertyToProxy("LocatorService.Proxy"));
}
- ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
- genericparams->category = SIP::V1::StateReplicatorDiscoveryCategory;
+ SIP::V1::SipStateReplicatorParamsPtr replicatorParams = new SIP::V1::SipStateReplicatorParams();
+ replicatorParams->category = SIP::V1::StateReplicatorDiscoveryCategory;
+ replicatorParams->mName = communicator()->getProperties()->getPropertyWithDefault("Sip.StateReplicatorName", "default");
try
{
- Ice::ObjectPrx objectPrx = mDataModelInstance.mServiceLocator->locate(genericparams);
+ Ice::ObjectPrx objectPrx = mDataModelInstance.mServiceLocator->locate(replicatorParams);
mDataModelInstance.mStateReplicator = SIP::V1::SipStateReplicatorPrx::checkedCast(objectPrx);
}
catch (...)
diff --git a/src/SipStateReplicatorApp.cpp b/src/SipStateReplicatorApp.cpp
index 515c315..afdfe8f 100644
--- a/src/SipStateReplicatorApp.cpp
+++ b/src/SipStateReplicatorApp.cpp
@@ -7,6 +7,7 @@
*/
#include <Ice/Ice.h>
+#include <IceUtil/UUID.h>
#include <IceStorm/IceStorm.h>
#include "ServiceLocatorIf.h"
@@ -36,7 +37,6 @@ private:
void initialize(std::string appName);
void registerWithServiceLocator();
void deregisterFromServiceLocator();
- void setCategory(Discovery::V1::ServiceManagementPrx serviceManagement, const string &category);
std::string mAppName;
//vector<SipStateReplicatorListenerPrx> mListeners;
Ice::ObjectAdapterPtr mAdapter;
@@ -77,6 +77,25 @@ private:
SipStateReplicatorApp& mApp;
};
+class SipStateReplicatorCompare : public ServiceLocatorParamsCompare
+{
+public:
+ SipStateReplicatorCompare(string name) : mName(name) {}
+ bool isSupported(const ServiceLocatorParamsPtr ¶ms, const Ice::Current &)
+ {
+ SipStateReplicatorParamsPtr sipParams = SipStateReplicatorParamsPtr::dynamicCast(params);
+ if (sipParams->mName == mName)
+ {
+ return true;
+ }
+ return false;
+ }
+private:
+ string mName;
+};
+
+typedef IceUtil::Handle<SipStateReplicatorCompare> SipStateReplicatorComparePtr;
+
/**
* Handles control characters in case the component is invoked as a console app.
*/
@@ -88,17 +107,6 @@ void SipStateReplicatorApp::interruptCallback(int val)
}
/**
- * Helper function to add some parameters to one of our registered interfaces in the ServiceLocator, so that
- * other components can look up our interfaces.
- */
-void SipStateReplicatorApp::setCategory(Discovery::V1::ServiceManagementPrx serviceManagement, const string &category)
-{
- // Add category as a parameter to enable other components look this component up.
- ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
- genericparams->category = category;
- serviceManagement->addLocatorParams(genericparams, "");
-}
-/**
* Register this component's primary public interfaces with the Service Locator.
* This enables other Asterisk SCF components to locate our interfaces.
*/
@@ -120,11 +128,19 @@ void SipStateReplicatorApp::registerWithServiceLocator()
ComponentServicePrx componentServicePrx = ComponentServicePrx::checkedCast(componentServiceObjectPrx);
// The GUID passed in to add service needs to be unique for reporting.
- string componentServiceGuid(mStateReplicator->getName());
+ string componentServiceGuid(AsteriskSCF::SIP::V1::StateReplicatorDiscoveryCategory);
mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(componentServicePrx, componentServiceGuid));
- //XXX Is it a problem that we use the same category as the SipChannelServiceApp here?
- setCategory(mComponentServiceManagement, AsteriskSCF::SIP::V1::ComponentServiceDiscoveryCategory);
+ // Add category as a parameter to enable other components look this component up.
+ ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
+ genericparams->category = AsteriskSCF::SIP::V1::StateReplicatorDiscoveryCategory;
+ string replicatorName = communicator()->getProperties()->getPropertyWithDefault("SipStateReplicator.Name", "default");
+ SipStateReplicatorCompare* nameCompare = new SipStateReplicatorCompare(replicatorName);
+ ServiceLocatorParamsComparePrx compareProxy = ServiceLocatorParamsComparePrx::uncheckedCast(mAdapter->addWithUUID(nameCompare));
+
+ string compareGuid = IceUtil::generateUUID();
+ mServiceLocatorManagement->addCompare(compareGuid, compareProxy);
+ mComponentServiceManagement->addLocatorParams(genericparams, compareGuid);
// TBD... We may have other interfaces to publish to the Service Locator.
}
commit 5582c8d392ebd7fd5352419ec6216ea3f0d44bfa
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Sep 21 09:45:23 2010 -0500
Add ability to name Sip State Replicators via Ice config.
Also actually added a Sip State Replicator to the app...it was mysteriously
absent...
diff --git a/src/SipStateReplicator.cpp b/src/SipStateReplicator.cpp
index 73d8f4d..9a3ddde 100644
--- a/src/SipStateReplicator.cpp
+++ b/src/SipStateReplicator.cpp
@@ -20,7 +20,7 @@ using namespace AsteriskSCF::SIP::V1;
struct SipStateReplicatorImpl
{
public:
- SipStateReplicatorImpl() {}
+ SipStateReplicatorImpl(std::string name) : mName(name) {}
void addListenerImpl(SipStateReplicatorListenerPrx listener)
{
mListeners.push_back(listener);
@@ -75,45 +75,51 @@ public:
std::vector<SipStateReplicatorListenerPrx> mListeners;
SipStateItemSeq mStateItems;
+ std::string mName;
};
-SipStateReplicatorI::SipStateReplicatorI() : mImpl(new SipStateReplicatorImpl) {}
+SipStateReplicatorI::SipStateReplicatorI(std::string name) : mImpl(new SipStateReplicatorImpl(name)) {}
SipStateReplicatorI::~SipStateReplicatorI()
{
delete mImpl;
}
-void SipStateReplicatorI::addListener(SipStateReplicatorListenerPrx listener, Ice::Current &)
+void SipStateReplicatorI::addListener(const SipStateReplicatorListenerPrx &listener, const Ice::Current &)
{
mImpl->addListenerImpl(listener);
}
-void SipStateReplicatorI::removeListener(SipStateReplicatorListenerPrx listener, Ice::Current &)
+void SipStateReplicatorI::removeListener(const SipStateReplicatorListenerPrx &listener, const Ice::Current &)
{
mImpl->removeListenerImpl(listener);
}
-void SipStateReplicatorI::setState(SipStateItemSeq items, Ice::Current &)
+void SipStateReplicatorI::setState(const SipStateItemSeq &items, const Ice::Current &)
{
mImpl->setStateImpl(items);
}
-void SipStateReplicatorI::removeState(SipStateItemSeq items, Ice::Current &)
+void SipStateReplicatorI::removeState(const SipStateItemSeq &items, const Ice::Current &)
{
mImpl->removeStateImpl(items);
}
-SipStateItemSeq SipStateReplicatorI::getState(Ice::StringSeq itemKeys, Ice::Current &)
+SipStateItemSeq SipStateReplicatorI::getState(const Ice::StringSeq &itemKeys, const Ice::Current &)
{
return mImpl->getStateImpl(itemKeys);
}
-SipStateItemSeq SipStateReplicatorI::getAllStates(Ice::Current &)
+SipStateItemSeq SipStateReplicatorI::getAllStates(const Ice::Current &)
{
return mImpl->getAllStatesImpl();
}
+std::string SipStateReplicatorI::getName()
+{
+ return mImpl->mName;
+}
+
struct SipStateReplicatorListenerImpl
{
public:
diff --git a/src/SipStateReplicator.h b/src/SipStateReplicator.h
index 8e1b696..94beda5 100644
--- a/src/SipStateReplicator.h
+++ b/src/SipStateReplicator.h
@@ -8,6 +8,7 @@
#pragma once
+#include <Ice/Ice.h>
#include "SipStateReplicationIf.h"
namespace AsteriskSCF
@@ -19,19 +20,22 @@ using namespace AsteriskSCF::SIP::V1;
class SipStateReplicatorI : public SipStateReplicator
{
public:
- SipStateReplicatorI();
+ SipStateReplicatorI(std::string name);
~SipStateReplicatorI();
- void addListener(SipStateReplicatorListenerPrx listener, Ice::Current&);
- void removeListener(SipStateReplicatorListenerPrx listener, Ice::Current &);
- void setState(SipStateItemSeq items, Ice::Current &);
- void removeState(SipStateItemSeq items, Ice::Current &);
- SipStateItemSeq getState(Ice::StringSeq itemKeys, Ice::Current &);
- SipStateItemSeq getAllStates(Ice::Current &);
+ void addListener(const SipStateReplicatorListenerPrx &listener, const Ice::Current&);
+ void removeListener(const SipStateReplicatorListenerPrx &listener, const Ice::Current &);
+ void setState(const SipStateItemSeq &items, const Ice::Current &);
+ void removeState(const SipStateItemSeq &items, const Ice::Current &);
+ SipStateItemSeq getState(const Ice::StringSeq &itemKeys, const Ice::Current &);
+ SipStateItemSeq getAllStates(const Ice::Current &);
+ std::string getName();
private:
struct SipStateReplicatorImpl *mImpl;
//SipStateReplicatorImpl *mImpl;
};
+typedef IceUtil::Handle<SipStateReplicatorI> SipStateReplicatorIPtr;
+
class SipStateReplicatorListenerI : public SipStateReplicatorListener
{
public:
diff --git a/src/SipStateReplicatorApp.cpp b/src/SipStateReplicatorApp.cpp
index dfaa097..515c315 100644
--- a/src/SipStateReplicatorApp.cpp
+++ b/src/SipStateReplicatorApp.cpp
@@ -18,6 +18,7 @@ using namespace std;
using namespace AsteriskSCF::Core;
using namespace AsteriskSCF::Core::Discovery::V1;
using namespace AsteriskSCF::System::Component::V1;
+using namespace AsteriskSCF::SipChannelService;
class SipStateReplicatorApp : public Ice::Application
{
@@ -27,6 +28,7 @@ public:
{
mComponentService = 0;
mAdapter = 0;
+ mStateReplicator = 0;
};
virtual int run(int, char *[]);
virtual void interruptCallback(int);
@@ -41,6 +43,7 @@ private:
ServiceLocatorManagementPrx mServiceLocatorManagement;
Discovery::V1::ServiceManagementPrx mComponentServiceManagement;
ComponentServicePtr mComponentService;
+ SipStateReplicatorIPtr mStateReplicator;
};
static const string ComponentServiceId("SipStateReplicatorComponent");
@@ -101,34 +104,34 @@ void SipStateReplicatorApp::setCategory(Discovery::V1::ServiceManagementPrx serv
*/
void SipStateReplicatorApp::registerWithServiceLocator()
{
- try
- {
- // Get a proxy to the management interface for the Service Locator, so we can add ourselves into the system discovery mechanisms.
- mServiceLocatorManagement = ServiceLocatorManagementPrx::checkedCast(communicator()->propertyToProxy("LocatorServiceManagement.Proxy"));
-
- if (mServiceLocatorManagement == 0)
- {
- cout << "Unable to obtain proxy to ServiceLocatorManagement interface. Check config file. This component can't be found until this is corrected." << endl;
- return;
- }
-
- // Get a proxy to our ComponentService interface and add it to the Service Locator.
- Ice::ObjectPrx componentServiceObjectPrx = mAdapter->createDirectProxy(communicator()->stringToIdentity(ComponentServiceId));
- ComponentServicePrx componentServicePrx = ComponentServicePrx::checkedCast(componentServiceObjectPrx);
-
- // The GUID passed in to add service needs to be unique for reporting.
- string componentServiceGuid("SipStateReplicator");
- mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(componentServicePrx, componentServiceGuid));
-
- //XXX Is it a problem that we use the same category as the SipChannelServiceApp here?
- setCategory(mComponentServiceManagement, AsteriskSCF::SIP::V1::ComponentServiceDiscoveryCategory);
-
- // TBD... We may have other interfaces to publish to the Service Locator.
- }
- catch(...)
- {
- cout << "Exception in " << mAppName << " registerWithServiceLocator()" << endl;
- }
+ try
+ {
+ // Get a proxy to the management interface for the Service Locator, so we can add ourselves into the system discovery mechanisms.
+ mServiceLocatorManagement = ServiceLocatorManagementPrx::checkedCast(communicator()->propertyToProxy("LocatorServiceManagement.Proxy"));
+
+ if (mServiceLocatorManagement == 0)
+ {
+ cout << "Unable to obtain proxy to ServiceLocatorManagement interface. Check config file. This component can't be found until this is corrected." << endl;
+ return;
+ }
+
+ // Get a proxy to our ComponentService interface and add it to the Service Locator.
+ Ice::ObjectPrx componentServiceObjectPrx = mAdapter->createDirectProxy(communicator()->stringToIdentity(ComponentServiceId));
+ ComponentServicePrx componentServicePrx = ComponentServicePrx::checkedCast(componentServiceObjectPrx);
+
+ // The GUID passed in to add service needs to be unique for reporting.
+ string componentServiceGuid(mStateReplicator->getName());
+ mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(mServiceLocatorManagement->addService(componentServicePrx, componentServiceGuid));
+
+ //XXX Is it a problem that we use the same category as the SipChannelServiceApp here?
+ setCategory(mComponentServiceManagement, AsteriskSCF::SIP::V1::ComponentServiceDiscoveryCategory);
+
+ // TBD... We may have other interfaces to publish to the Service Locator.
+ }
+ catch(...)
+ {
+ cout << "Exception in " << mAppName << " registerWithServiceLocator()" << endl;
+ }
}
/**
@@ -150,6 +153,7 @@ void SipStateReplicatorApp::deregisterFromServiceLocator()
void SipStateReplicatorApp::initialize(const std::string appName)
{
+ mStateReplicator = new SipStateReplicatorI(communicator()->getProperties()->getPropertyWithDefault("SipStateReplicator.Name", "default"));
mAppName = appName;
// Create and publish our ComponentService interface support.
mComponentService = new ComponentServiceImpl(*this);
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list