[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "session_cookies" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Apr 26 12:21:12 CDT 2011
branch "session_cookies" has been updated
via aaa00dffff26685b33b00f988d699370ea4d3908 (commit)
via d904018732faf4dc3c2fbef6784fb70d6f72a9f6 (commit)
via 665b6a29b567c13c6bbce45fab4ca422bf2e17aa (commit)
via 99fbea34400b3eedcbee29014104cf60b332555a (commit)
via bae047c389685f743ff52036ee82429913bfe775 (commit)
via bf4ba3621565c7ed6b02c35dea2a66255db51dcb (commit)
via 252f5aae48c75f150ddc3935a9b9a44ba74cde76 (commit)
from 6755289ef4b962bee87ddbf0e156857d4b87bb64 (commit)
Summary of changes:
CMakeLists.txt | 5 +-
README.txt | 2 +-
config/test_bridging.conf.in | 160 ++++-
src/BridgeImpl.cpp | 1394 ++++++++++++++++----------------
src/BridgeImpl.h | 266 +++----
src/BridgeListenerMgr.cpp | 19 +-
src/BridgeListenerMgr.h | 2 +-
src/BridgeManagerImpl.cpp | 470 ++++++++---
src/BridgeManagerImpl.h | 93 +--
src/BridgeManagerListenerMgr.cpp | 19 +-
src/BridgeManagerListenerMgr.h | 2 +-
src/BridgeReplicatorIf.ice | 245 ++++++
src/BridgeReplicatorService.cpp | 197 +++++
src/BridgeReplicatorStateListenerI.cpp | 290 +++++++
src/BridgeReplicatorStateListenerI.h | 42 +
src/BridgeServiceConfig.h | 35 +-
src/BridgeServiceImpl.h | 22 -
src/CMakeLists.txt | 36 +-
src/DebugUtil.h | 115 +++
src/InternalExceptions.h | 10 +-
src/ListenerManager.h | 34 +-
src/MediaSplicer.cpp | 962 ++++++++++++++++++-----
src/MediaSplicer.h | 59 ++-
src/Service.cpp | 322 +++++---
src/ServiceUtil.h | 208 +++++
src/SessionCollection.cpp | 211 +++++
src/SessionCollection.h | 138 ++++
src/SessionListener.cpp | 138 ++++
src/SessionListener.h | 38 +
src/SessionOperations.cpp | 85 ++
src/SessionOperations.h | 206 +++++
src/SessionWrapper.cpp | 568 +++++++++++++
src/SessionWrapper.h | 162 ++++
src/Tasks.h | 471 +++++++++++
test/BridgeListenerI.cpp | 10 +-
test/BridgeListenerI.h | 2 +-
test/BridgeManagerListenerI.cpp | 10 +-
test/BridgeManagerListenerI.h | 2 +-
test/CMakeLists.txt | 60 +-
test/SessionListenerI.cpp | 26 +-
test/SessionListenerI.h | 2 +-
test/TestBridging.cpp | 343 ++++++--
test/TestCommandDriver.cpp | 2 +-
test/TestCommandDriver.h | 2 +-
test/UnitTests.cpp | 390 +++++++++
45 files changed, 6337 insertions(+), 1538 deletions(-)
create mode 100644 src/BridgeReplicatorIf.ice
create mode 100644 src/BridgeReplicatorService.cpp
create mode 100644 src/BridgeReplicatorStateListenerI.cpp
create mode 100644 src/BridgeReplicatorStateListenerI.h
delete mode 100644 src/BridgeServiceImpl.h
create mode 100644 src/DebugUtil.h
create mode 100644 src/ServiceUtil.h
create mode 100644 src/SessionCollection.cpp
create mode 100644 src/SessionCollection.h
create mode 100644 src/SessionListener.cpp
create mode 100644 src/SessionListener.h
create mode 100644 src/SessionOperations.cpp
create mode 100644 src/SessionOperations.h
create mode 100644 src/SessionWrapper.cpp
create mode 100644 src/SessionWrapper.h
create mode 100644 src/Tasks.h
create mode 100644 test/UnitTests.cpp
- Log -----------------------------------------------------------------
commit aaa00dffff26685b33b00f988d699370ea4d3908
Merge: 6755289 d904018
Author: Joshua Colp <jcolp at digium.com>
Date: Tue Apr 26 14:00:29 2011 -0300
Merge remote branch 'origin/master' into session_cookies
Conflicts:
src/BridgeImpl.cpp
diff --cc src/BridgeImpl.cpp
index 5f3e61c,0ce1947..986aa73
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@@ -466,88 -522,44 +522,44 @@@ BridgeImpl::~BridgeImpl(
//
}
- void AsteriskSCF::BridgeService::BridgeImpl::addSessions(
- const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, const Ice::Current& current)
+ void BridgeImpl::addSessions_async(const AMD_Bridge_addSessionsPtr& callback, const SessionSeq& sessions,
- const Ice::Current&)
++ const Ice::Current& current)
{
- if(sessions.size() == 0)
- {
- return;
- }
- checkSessions(sessions);
- AsteriskSCF::SessionCommunications::V1::SessionSeq addedSessions;
+ try
{
- boost::unique_lock<boost::shared_mutex> lock(mLock);
- statePreCheck();
- lg(Debug) << __FUNCTION__ << ": adding " << sessions.size() << " sessions to "
- << current.adapter->getCommunicator()->identityToString(current.id);
- for(AsteriskSCF::SessionCommunications::V1::SessionSeq::const_iterator i = sessions.begin();
- i != sessions.end(); ++i)
+ if (sessions.empty())
{
- //
- // TODO: how do we want to handle sessions that have already been added to the bridge. Its pretty much
- // impossible to guard against race conditions where multiple call paths might want to add a session
- // more than once for some reason. We should probably just log it and move on.
- //
- std::vector<BridgeSessionPtr>::iterator j =
- find_if(mSessions.begin(), mSessions.end(), AsteriskSCF::BridgeService::FindImpl(*i));
- if(j != mSessions.end())
- {
- lg(Debug) << __FUNCTION__ << ": " << (*i)->ice_toString()
- << " is already registered with this bridge.";
- continue;
- }
-
- AsteriskSCF::SessionCommunications::V1::SessionInfoPtr info;
- try
+ if (callback)
{
- RetryPolicy policy(5, 500);
- //
- // canRetry should never return false since we throw ourselves out of this loop. But
- // we'll do it here in case we decide to do something else.
- //
- while(policy.canRetry())
- {
- try
- {
- info = (*i)->setBridge(mPrx, mSessionListenerPrx);
- break;
- }
- catch(const Ice::ConnectionLostException&)
- {
- if(!policy.retry())
- {
- throw;
- }
- }
- }
+ callback->ice_response();
}
- catch(const Ice::Exception& ex)
- {
- lg(Debug) << __FUNCTION__ << ": " << (*i)->ice_toString() << " threw " << ex.what()
- << " continuing";
- }
- //
- // We need to define these states! Especially the ones that define when start is called or not.
- //
- if(info->currentState == "ready")
- {
- lg(Debug) << __FUNCTION__ << ": " << (*i)->ice_toString()
- << " current state is ready (not yet connected), not establishing media connections.";
- mSessions.push_back(new BridgeSession(*i, 0, false));
- }
- else
- {
- lg(Debug) << __FUNCTION__ << ": " << (*i)->ice_toString()
- << " media is expected to be establishing, plugging media into bridge.";
- mSessions.push_back(new BridgeSession(*i, mSplicer.connect(*i), false));;
- }
-
- addedSessions.push_back(*i);
+ return;
}
+ checkSessions(sessions);
+ statePreCheck();
+ mLogger(Debug) << FUNLOG << ": adding " << sessions.size() << " sessions";
+
+ SessionsTrackerPtr tracker(new SessionsTracker);
+ QueuedTasks tasks;
+ tasks.push_back(new SetBridgeTask(mSessions, mPrx, mSessionListenerPrx, sessions, tracker));
+ tasks.push_back(new AddToListeners(mListeners, tracker));
+ tasks.push_back(new GenericAMDCallback<AMD_Bridge_addSessionsPtr>(callback, tracker));
+ tasks.push_back(new UpdateTask(this));
+ ExecutorPtr executor(new Executor(tasks, mLogger));
+ executor->start();
+ //
+ // When the operations have all completed, that last task will take care of handling
+ // the callback. It's all left withing the try/catch in the event something happens during
+ // task startup.
+ //
}
- if(addedSessions.size())
+ catch (const std::exception& ex)
{
- mListeners->sessionsAdded(addedSessions);
+ callback->ice_exception(ex);
+ }
+ catch (...)
+ {
+ callback->ice_exception();
}
}
diff --cc src/SessionListener.cpp
index 0000000,b55ef67..6179999
mode 000000,100644..100644
--- a/src/SessionListener.cpp
+++ b/src/SessionListener.cpp
@@@ -1,0 -1,137 +1,138 @@@
+ /*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010-2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+ #include "SessionListener.h"
+ #include "ServiceUtil.h"
+ #include "SessionOperations.h"
+
+ using namespace AsteriskSCF::System::Logging;
+ using namespace AsteriskSCF::SessionCommunications::V1;
+ using namespace AsteriskSCF::BridgeService;
+ using namespace AsteriskSCF::Bridge::V1;
+ using namespace AsteriskSCF;
+ using namespace std;
+
+ namespace
+ {
+
+ //
+ // For events that require modification to the bridge, we use helper methods on the bridge itself.
+ // For events result in distribution to the bridge sessions, we copy the current sessions and
+ // run the calls from the listener itself.
+ //
+ class SessionListenerImpl : public SessionListener
+ {
+ public:
+ SessionListenerImpl(const SessionCollectionPtr& b, const Logger& logger) :
+ mSessions(b),
+ mLogger(logger)
+ {
+ }
+
+ void indicated(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source,
- const AsteriskSCF::SessionCommunications::V1::IndicationPtr& indication, const Ice::Current& current)
++ const AsteriskSCF::SessionCommunications::V1::IndicationPtr& indication,
++ const AsteriskSCF::SessionCommunications::V1::SessionCookies&, const Ice::Current& current)
+ {
+ AsteriskSCF::SessionCommunications::V1::ConnectedIndicationPtr connected;
+ AsteriskSCF::SessionCommunications::V1::RingingIndicationPtr ringing;
+ AsteriskSCF::SessionCommunications::V1::StoppedIndicationPtr stopped;
+
+ if ((connected = AsteriskSCF::SessionCommunications::V1::ConnectedIndicationPtr::dynamicCast(indication)))
+ {
+ string proxyString = source->ice_toString();
+ mLogger(Debug) << FUNLOG << ": session connected " << proxyString;
+
+ try
+ {
+ SessionWrapperPtr session = mSessions->getSession(source);
+ if (!session)
+ {
+ mLogger(Info) << "Attempt to respond to connected notification for session with proxy "
+ << proxyString << " that does not match known sessions. Possible out of order operations.";
+ return;
+ }
+
+ session->setup();
+
+ ConnectSessionOperation connector(source, mLogger);
+ mSessions->visitSessions(connector);
+ }
+ catch (const Ice::Exception& ex)
+ {
+ mLogger(Debug) << FUNLOG << ": " << ex.what();
+ throw;
+ }
+ }
+ else if ((ringing = AsteriskSCF::SessionCommunications::V1::RingingIndicationPtr::dynamicCast(indication)))
+ {
+ //
+ // TODO: Who gets the ring notifications will likely depend on configuration, etc.
+ //
+ RingSessionOperation ringer(source, mLogger);
+ mSessions->visitSessions(ringer);
+ }
+ else if ((stopped = AsteriskSCF::SessionCommunications::V1::StoppedIndicationPtr::dynamicCast(indication)))
+ {
+ string proxyString = source->ice_toString();
+ mLogger(Debug) << FUNLOG << ": session stopped " << proxyString;
+
+ //
+ // IMPLNOTE: The AMI approach.
+ // Stack some operations in a callback. In this case it will be:
+ // 1. getSession()
+ // 2. removeBridge()
+ // 3. disconnect() or destroy()
+ //
+ // The latter two should be coupled as a transaction. One way to go about this would be to replicate the
+ // operations that need to be done together and checkpoint after each one completes. Actually, there are lots of
+ // ways to go about it. Need to think on this more.
+ //
+ // Q. What is the proper order of operations here, should removeBridge be called before or after we
+ // "disconnect" the session?
+ //
+ SessionWrapperPtr session;
+ session = mSessions->getSession(source);
+ if (!session)
+ {
+ mLogger(Info) << "Attempt to respond to connected notification for session with proxy "
+ << proxyString << " that does not match known sessions. Possible out of order operations.";
+ return;
+ }
+
+ //
+ // We don't actually have the proxy for this object, but we can create one on the fly.
+ //
+ SessionListenerPrx listenerPrx = SessionListenerPrx::uncheckedCast(current.adapter->createProxy(current.id));
+
+ //
+ // Shutdown is handled asynchronously, so there won't be any exceptions that need to be caught here.
+ //
+ session->shutdown(listenerPrx, new ResponseCode);
+ }
+ }
+
+ private:
+ SessionCollectionPtr mSessions;
+ Logger mLogger;
+ };
+
+ }
+
+ SessionListenerPtr AsteriskSCF::BridgeService::createSessionListener(const SessionCollectionPtr& sessions,
+ const Logger& logger)
+ {
+ return new SessionListenerImpl(sessions, logger);
+ }
-----------------------------------------------------------------------
--
asterisk-scf/integration/bridging.git
More information about the asterisk-scf-commits
mailing list