[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Mon Sep 13 13:23:10 CDT 2010
branch "master" has been updated
via 97ae1fa44ff23745ec65cc93511797f31ca584f0 (commit)
from de0abfc9190ae4f187d6140cd799637318b6182a (commit)
Summary of changes:
cmake | 2 +-
src/BridgeImpl.cpp | 35 +++++++++----------
src/BridgeListenerMgr.cpp | 1 -
src/BridgeListenerMgr.h | 2 +-
src/BridgeManagerImpl.cpp | 72 ++++++++++++++++++++++++++++++++++----
src/BridgeManagerImpl.h | 13 ++++---
src/CMakeLists.txt | 6 +++
src/ListenerManager.h | 2 +
src/Service.cpp | 8 +++-
test/BridgeManagerListenerI.cpp | 2 +
test/CMakeLists.txt | 2 +
test/TestBridging.cpp | 71 +++++++++++++++++++++++++++++++++++++-
12 files changed, 177 insertions(+), 39 deletions(-)
- Log -----------------------------------------------------------------
commit 97ae1fa44ff23745ec65cc93511797f31ca584f0
Author: Brent Eagles <beagles at digium.com>
Date: Mon Sep 13 15:00:13 2010 -0230
Fix a bug in the ListenerManager template (needs to be ported over to the test channel driver).
Fixed a listener bug in the bridge manager.
diff --git a/cmake b/cmake
index 98cbf4a..1e7a172 160000
--- a/cmake
+++ b/cmake
@@ -1 +1 @@
-Subproject commit 98cbf4a0d71e2af47068d55a7bcbabf8616aff92
+Subproject commit 1e7a1725fe9e2d176a2c26820d6bcd96c6c3939e
diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index ee5c7bf..6ef3af9 100644
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -178,7 +178,10 @@ AsteriskSCF::BridgeService::BridgeImpl::BridgeImpl(
mListeners(listenerMgr),
mSessionListener(new SessionListener(this))
{
- mListeners->addListener(ev);
+ if(ev)
+ {
+ mListeners->addListener(ev);
+ }
mSessionListenerPrx = AsteriskSCF::SessionCommunications::V1::SessionListenerPrx::uncheckedCast(mObjAdapter->addWithUUID(mSessionListener));
}
@@ -304,32 +307,28 @@ void AsteriskSCF::BridgeService::BridgeImpl::shutdown(const Ice::Current& curren
// When shutting down, the bridge makes a copy of its current state and unlocks, proceeding with
// no other internal locks.
//
- std::vector<BridgeSession> copyOfSessions;
-
mLogger.getTraceStream() << __FUNCTION__ << ":" << current.adapter->getCommunicator()->identityToString(current.id) << std::endl;
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ if(mState == ShuttingDown)
{
- boost::unique_lock<boost::shared_mutex> lock(mLock);
- if(mState == ShuttingDown)
- {
- mLogger.getDebugStream() << __FUNCTION__ << ": called when shutting down." << std::endl;
- return;
- }
- if(mState == Destroyed)
- {
- mLogger.getDebugStream() << __FUNCTION__ << ": called when destroyed." << std::endl;
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
- }
- mState = ShuttingDown;
- std::swap(copyOfSessions, mSessions);
+ mLogger.getDebugStream() << __FUNCTION__ << ": called when shutting down." << std::endl;
+ return;
}
+ if(mState == Destroyed)
+ {
+ mLogger.getDebugStream() << __FUNCTION__ << ": called when destroyed." << std::endl;
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ }
+ mState = ShuttingDown;
+
mListeners->stopping();
//
// TODO: Response code for termination messages for bridges shutting down should come from configuration
//
- if(copyOfSessions.size())
+ if(mSessions.size() > 0)
{
- std::for_each(copyOfSessions.begin(), copyOfSessions.end(),
+ std::for_each(mSessions.begin(), mSessions.end(),
AsteriskSCF::BridgeService::ShutdownImpl(new AsteriskSCF::SessionCommunications::V1::ResponseCode));
}
diff --git a/src/BridgeListenerMgr.cpp b/src/BridgeListenerMgr.cpp
index 8aa176e..c89d808 100644
--- a/src/BridgeListenerMgr.cpp
+++ b/src/BridgeListenerMgr.cpp
@@ -13,7 +13,6 @@ AsteriskSCF::BridgeService::BridgeListenerMgr::BridgeListenerMgr(const Ice::Comm
ListenerManagerT<AsteriskSCF::SessionCommunications::Bridging::V1::BridgeListenerPrx>(comm, name),
mPrx(bridgeProxy)
{
- mPublisher = AsteriskSCF::SessionCommunications::Bridging::V1::BridgeListenerPrx::uncheckedCast(mTopic->getPublisher());
}
void AsteriskSCF::BridgeService::BridgeListenerMgr::sessionsAdded(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions)
diff --git a/src/BridgeListenerMgr.h b/src/BridgeListenerMgr.h
index 5c4b640..ec8fecc 100644
--- a/src/BridgeListenerMgr.h
+++ b/src/BridgeListenerMgr.h
@@ -6,6 +6,7 @@
* All rights reserved.
*/
#pragma once
+
#include <string>
#include <Ice/Ice.h>
#include "ListenerManager.h"
@@ -28,7 +29,6 @@ namespace BridgeService
private:
AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx mPrx;
- AsteriskSCF::SessionCommunications::Bridging::V1::BridgeListenerPrx mPublisher;
};
typedef IceUtil::Handle<BridgeListenerMgr> BridgeListenerMgrPtr;
diff --git a/src/BridgeManagerImpl.cpp b/src/BridgeManagerImpl.cpp
index 8998871..812dfb5 100644
--- a/src/BridgeManagerImpl.cpp
+++ b/src/BridgeManagerImpl.cpp
@@ -3,6 +3,7 @@
#include <IceUtil/UUID.h>
#include <boost/thread/locks.hpp>
#include "BridgeListenerMgr.h"
+#include "BridgeManagerListenerMgr.h"
//
// Compiled in constants.
@@ -18,10 +19,10 @@ namespace BridgeService
//
// Functor used with for_each on shutdown.
//
- class ShutdownImpl : public std::unary_function<BridgeManagerImpl::BridgeInfo, void>
+ class BridgeMgrShutdownImpl : public std::unary_function<BridgeManagerImpl::BridgeInfo, void>
{
public:
- ShutdownImpl(const Ice::Current& c) :
+ BridgeMgrShutdownImpl(const Ice::Current& c) :
mCurrent(c)
{
}
@@ -40,18 +41,26 @@ namespace BridgeService
AsteriskSCF::BridgeService::BridgeManagerImpl::BridgeManagerImpl(
const Ice::ObjectAdapterPtr& adapter,
- const std::string& name,
- const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerListenerPrx& listener) :
+ const std::string& name) :
mName(name),
mShuttingDown(false),
mSuspended(false),
mAdapter(adapter)
{
mLogger.getInfoStream() << "Created AsteriskSCF Session-Oriented Bridge Manager." << std::endl;
- mListeners = new ListenerManager(adapter->getCommunicator(), TopicPrefix + mName);
- if(listener)
+}
+
+void AsteriskSCF::BridgeService::BridgeManagerImpl::setPublishProxy(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& prx)
+{
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ mSourceProxy = prx;
+ if(!mListeners)
+ {
+ mListeners = new AsteriskSCF::BridgeService::BridgeManagerListenerMgr(mAdapter->getCommunicator(), mName, mSourceProxy);
+ }
+ else
{
- mListeners->addListener(listener);
+ mListeners->setSource(mSourceProxy);
}
}
@@ -83,10 +92,15 @@ AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx AsteriskSCF::BridgeS
AsteriskSCF::BridgeService::BridgeImplPtr bridge = new AsteriskSCF::BridgeService::BridgeImpl(mAdapter, listener, mgr);
Ice::ObjectPrx obj = mAdapter->add(bridge, id);
+
mLogger.getInfoStream() << current.adapter->getCommunicator()->identityToString(current.id) << ": creating new bridge " << obj->ice_toString() << "." << std::endl;
BridgeInfo info;
info.servant = bridge;
info.proxy = AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx::uncheckedCast(obj);
+ if(mListeners)
+ {
+ mListeners->bridgeCreated(info.proxy);
+ }
mBridges.push_back(info);
//
@@ -99,10 +113,44 @@ AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx AsteriskSCF::BridgeS
void AsteriskSCF::BridgeService::BridgeManagerImpl::addListener(const SessionCommunications::Bridging::V1::BridgeManagerListenerPrx& listener, const Ice::Current& current)
{
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ if(mShuttingDown)
+ {
+ mLogger.getDebugStream() << __FUNCTION__ << ": called when shutting down." << std::endl;
+ throw AsteriskSCF::System::Component::V1::ShuttingDown();
+ }
+ if(mSuspended)
+ {
+ mLogger.getDebugStream() << __FUNCTION__ << ": called when suspended." << std::endl;
+ throw AsteriskSCF::System::Component::V1::Suspended();
+ }
+ if(!mListeners)
+ {
+ mSourceProxy = AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx::uncheckedCast(mAdapter->createProxy(current.id));
+ mListeners = new AsteriskSCF::BridgeService::BridgeManagerListenerMgr(mAdapter->getCommunicator(), mName, mSourceProxy);
+ }
+ mListeners->addListener(listener);
}
void AsteriskSCF::BridgeService::BridgeManagerImpl::removeListener(const SessionCommunications::Bridging::V1::BridgeManagerListenerPrx& listener, const Ice::Current& current)
{
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ if(mShuttingDown)
+ {
+ mLogger.getDebugStream() << __FUNCTION__ << ": called when shutting down." << std::endl;
+ throw AsteriskSCF::System::Component::V1::ShuttingDown();
+ }
+ if(mSuspended)
+ {
+ mLogger.getDebugStream() << __FUNCTION__ << ": called when suspended." << std::endl;
+ throw AsteriskSCF::System::Component::V1::Suspended();
+ }
+ if(!mListeners)
+ {
+ mSourceProxy = AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx::uncheckedCast(mAdapter->createProxy(current.id));
+ mListeners = new AsteriskSCF::BridgeService::BridgeManagerListenerMgr(mAdapter->getCommunicator(), mName, mSourceProxy);
+ }
+ mListeners->removeListener(listener);
}
AsteriskSCF::SessionCommunications::Bridging::V1::BridgeSeq
@@ -131,14 +179,22 @@ void AsteriskSCF::BridgeService::BridgeManagerImpl::shutdown(const Ice::Current&
mLogger.getDebugStream() << __FUNCTION__ << ": called when suspended." << std::endl;
throw AsteriskSCF::System::Component::V1::Suspended();
}
+ if(mListeners)
+ {
+ mListeners->stopping();
+ }
mLogger.getInfoStream() << current.adapter->getCommunicator()->identityToString(current.id) << ": shutting down." << std::endl;
mShuttingDown = true;
reap();
if(mBridges.size() > 0)
{
- std::for_each(mBridges.begin(), mBridges.end(), AsteriskSCF::BridgeService::ShutdownImpl(current));
+ std::for_each(mBridges.begin(), mBridges.end(), AsteriskSCF::BridgeService::BridgeMgrShutdownImpl(current));
}
+ if(mListeners)
+ {
+ mListeners->stopped();
+ }
mAdapter->getCommunicator()->shutdown();
}
diff --git a/src/BridgeManagerImpl.h b/src/BridgeManagerImpl.h
index 530ecec..80c657f 100644
--- a/src/BridgeManagerImpl.h
+++ b/src/BridgeManagerImpl.h
@@ -7,7 +7,7 @@
#include "BridgeImpl.h"
#include "Logger.h"
-#include "ListenerManager.h"
+#include "BridgeManagerListenerMgr.h"
namespace AsteriskSCF
{
@@ -17,8 +17,10 @@ namespace BridgeService
{
public:
- BridgeManagerImpl(const Ice::ObjectAdapterPtr& adapter, const std::string& name,
- const SessionCommunications::Bridging::V1::BridgeManagerListenerPrx& listener);
+ BridgeManagerImpl(const Ice::ObjectAdapterPtr& adapter, const std::string& name);
+
+ void setPublishProxy(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& prx);
+
//
// AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManager Interface
@@ -48,9 +50,8 @@ namespace BridgeService
bool mSuspended;
Ice::ObjectAdapterPtr mAdapter;
Logger mLogger;
- typedef ListenerManagerT<SessionCommunications::Bridging::V1::BridgeManagerListenerPrx> ListenerManager;
- typedef IceUtil::Handle<ListenerManager> ListenerManagerPtr;
- ListenerManagerPtr mListeners;
+ AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx mSourceProxy;
+ BridgeManagerListenerMgrPtr mListeners;
void reap();
};
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d9f55a1..9259d90 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,9 +5,15 @@ hydra_component_add_slice(bridgeservice SessionCommunicationsIf)
hydra_component_add_slice(bridgeservice BridgingIf)
hydra_component_add_slice(bridgeservice ServiceLocatorIf)
hydra_component_add_file(bridgeservice Service.cpp)
+hydra_component_add_file(bridgeservice BridgeImpl.h)
hydra_component_add_file(bridgeservice BridgeImpl.cpp)
+hydra_component_add_file(bridgeservice BridgeListenerMgr.h)
hydra_component_add_file(bridgeservice BridgeListenerMgr.cpp)
+hydra_component_add_file(bridgeservice BridgeManagerListenerMgr.h)
+hydra_component_add_file(bridgeservice BridgeManagerListenerMgr.cpp)
+hydra_component_add_file(bridgeservice BridgeManagerImpl.h)
hydra_component_add_file(bridgeservice BridgeManagerImpl.cpp)
+hydra_component_add_file(bridgeservice MediaSplicer.h)
hydra_component_add_file(bridgeservice MediaSplicer.cpp)
hydra_component_add_ice_libraries(bridgeservice IceStorm)
hydra_component_add_boost_libraries(bridgeservice thread)
diff --git a/src/ListenerManager.h b/src/ListenerManager.h
index a307fd3..17ac0ea 100644
--- a/src/ListenerManager.h
+++ b/src/ListenerManager.h
@@ -77,6 +77,7 @@ namespace BridgeService
throw ConfigException(propertyName,
std::string("unable to create topic with the provided configuration :") + mTopicName);
}
+ mPublisher = T::uncheckedCast(mTopic->getPublisher());
}
virtual ~ListenerManagerT()
@@ -135,6 +136,7 @@ namespace BridgeService
std::string mTopicName;
IceStorm::TopicPrx mTopic;
IceStorm::TopicManagerPrx mTopicManager;
+ T mPublisher;
ListenerSeq mListeners;
};
}
diff --git a/src/Service.cpp b/src/Service.cpp
index 83de1c1..f10f825 100644
--- a/src/Service.cpp
+++ b/src/Service.cpp
@@ -37,8 +37,12 @@ int BridgingApp::run(int, char*[])
mLogger.getTraceStream() << "Launching AsteriskSCF Session-Oriented Bridging Service." << std::endl;
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("AsteriskSCF.BridgeService");
- AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPtr f(new AsteriskSCF::BridgeService::BridgeManagerImpl(adapter, ManagerName, 0));
- AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx s = AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx::uncheckedCast(adapter->add(f, communicator()->stringToIdentity(ManagerName)));
+
+ AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPtr servant(new AsteriskSCF::BridgeService::BridgeManagerImpl(adapter, ManagerName));
+ AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx s(
+ AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx::uncheckedCast(adapter->add(servant, communicator()->stringToIdentity(ManagerName))
+ )
+ );
adapter->activate();
AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx management = AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx::checkedCast(communicator()->propertyToProxy("ServiceLocatorManagementProxy"));
diff --git a/test/BridgeManagerListenerI.cpp b/test/BridgeManagerListenerI.cpp
index 408b2d3..9dd3364 100644
--- a/test/BridgeManagerListenerI.cpp
+++ b/test/BridgeManagerListenerI.cpp
@@ -11,8 +11,10 @@ void BridgeManagerListenerI::bridgeCreated(const AsteriskSCF::SessionCommunicati
void BridgeManagerListenerI::stopped(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& manager, const Ice::Current&)
{
+ std::cerr << __FILE__ << ":" << __FUNCTION__ << " from " << manager->ice_toString() << std::endl;
}
void BridgeManagerListenerI::stopping(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& manager, const Ice::Current&)
{
+ std::cerr << __FILE__ << ":" << __FUNCTION__ << " from " << manager->ice_toString() << std::endl;
}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index f50b566..22c240e 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -23,6 +23,8 @@ hydra_component_add_file(bridging_unit_test "../src/BridgeManagerImpl.h")
hydra_component_add_file(bridging_unit_test "../src/MediaSplicer.cpp")
hydra_component_add_file(bridging_unit_test "../src/BridgeListenerMgr.cpp")
hydra_component_add_file(bridging_unit_test "../src/BridgeListenerMgr.h")
+hydra_component_add_file(bridging_unit_test "../src/BridgeManagerListenerMgr.cpp")
+hydra_component_add_file(bridging_unit_test "../src/BridgeManagerListenerMgr.h")
hydra_component_add_file(bridging_unit_test "../src/MediaSplicer.h")
hydra_component_add_ice_libraries(bridging_unit_test IceStorm)
hydra_component_add_ice_libraries(bridging_unit_test IceBox)
diff --git a/test/TestBridging.cpp b/test/TestBridging.cpp
index 30dbe90..b24cc6f 100644
--- a/test/TestBridging.cpp
+++ b/test/TestBridging.cpp
@@ -101,8 +101,8 @@ BOOST_AUTO_TEST_CASE(CreateBridgeFactory)
);
Ice::ObjectAdapterPtr bridgeAdapter = communicator->createObjectAdapter("TestBridgeAdapter");
- AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPtr mgrServant(
- new AsteriskSCF::BridgeService::BridgeManagerImpl(bridgeAdapter, "TestBridgeManager", listenerPrx));
+ AsteriskSCF::BridgeService::BridgeManagerImplPtr mgrServant(
+ new AsteriskSCF::BridgeService::BridgeManagerImpl(bridgeAdapter, "TestBridgeManager"));
AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx mgrPrx(
AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx::uncheckedCast(
testAdapter->add(mgrServant,
@@ -110,6 +110,9 @@ BOOST_AUTO_TEST_CASE(CreateBridgeFactory)
)
)
);
+ mgrServant->setPublishProxy(mgrPrx);
+ mgrPrx->addListener(listenerPrx);
+
mgrPrx->shutdown();
}
catch(const Ice::Exception& ex)
@@ -134,6 +137,70 @@ BOOST_AUTO_TEST_CASE(CreateBridgeFactory)
BOOST_AUTO_TEST_CASE(CreateEmptyBridge)
{
+ Ice::PropertiesPtr p = Ice::createProperties();
+ p->setProperty("TestStorm.TopicManager.Endpoints","default -p 55555");
+ p->setProperty("TestStorm.Publish.Endpoints", "default -p 55556");
+ p->setProperty("TestStorm.InstanceName", "TestStorm");
+ p->setProperty("TestStorm.Transient", "1");
+ IceStormInstancePtr iceStorm(IceStormInstance::getInstance());
+ iceStorm->start("TestStorm", p);
+ try
+ {
+ p = Ice::createProperties();
+ p->setProperty("TopicManager.Proxy", "TestStorm/TopicManager:default -p 55555");
+ p->setProperty("TestUtilAdapter.Endpoints", "default -p 55557");
+ p->setProperty("TestBridgeAdapter.Endpoints", "default -p 55558");
+
+ Ice::InitializationData initData;
+ initData.properties = p;
+ Ice::CommunicatorPtr communicator = Ice::initialize(initData);
+ try
+ {
+ Ice::ObjectAdapterPtr testAdapter = communicator->createObjectAdapter("TestUtilAdapter");
+ BridgeManagerListenerIPtr servant = new BridgeManagerListenerI;
+ AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerListenerPrx listenerPrx =
+ AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerListenerPrx::uncheckedCast(
+ testAdapter->add(servant,
+ communicator->stringToIdentity("testBridgeManagerListener")
+ )
+ );
+
+ Ice::ObjectAdapterPtr bridgeAdapter = communicator->createObjectAdapter("TestBridgeAdapter");
+ AsteriskSCF::BridgeService::BridgeManagerImplPtr mgrServant(
+ new AsteriskSCF::BridgeService::BridgeManagerImpl(bridgeAdapter, "TestBridgeManager"));
+ AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx mgrPrx(
+ AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx::uncheckedCast(
+ testAdapter->add(mgrServant,
+ communicator->stringToIdentity("testBridgeManager")
+ )
+ )
+ );
+ mgrServant->setPublishProxy(mgrPrx);
+ mgrPrx->addListener(listenerPrx);
+
+ AsteriskSCF::SessionCommunications::V1::SessionSeq sessions;
+ AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx bridge(mgrPrx->createBridge(sessions, 0));
+
+ mgrPrx->shutdown();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ std::cerr << ex << std::endl;
+ BOOST_CHECK(false);
+ }
+ catch(...)
+ {
+ BOOST_CHECK(false);
+ }
+ communicator->destroy();
+ }
+ catch(...)
+ {
+ BOOST_CHECK(false);
+ }
+
+ iceStorm->stop();
+
}
#if 0
-----------------------------------------------------------------------
--
asterisk-scf/integration/bridging.git
More information about the asterisk-scf-commits
mailing list