[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "retry_deux" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Apr 12 08:56:19 CDT 2012


branch "retry_deux" has been updated
       via  937db791a5ae711b267c9ea3b36d372b78993bb3 (commit)
       via  469b218b95aa39895db49ead7945f002187868e8 (commit)
      from  151285f4a6d29b8796b639978a97a4890266f723 (commit)

Summary of changes:
 src/BridgeImpl.cpp        |   96 ++++++++++++++++++++++++++-------------------
 src/BridgeManagerImpl.cpp |    3 +-
 src/BridgeServiceConfig.h |    8 ++++
 src/MediaSplicer.cpp      |   28 +++++++++----
 src/SessionListener.cpp   |    2 +-
 src/SessionWrapper.cpp    |   24 ++++++++---
 src/SessionWrapper.h      |    2 +-
 7 files changed, 103 insertions(+), 60 deletions(-)


- Log -----------------------------------------------------------------
commit 937db791a5ae711b267c9ea3b36d372b78993bb3
Author: Brent Eagles <beagles at digium.com>
Date:   Thu Apr 12 11:23:31 2012 -0230

    Updates for recent changes to getContext() in OperationMonitor.h.

diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index bc52972..4858b23 100755
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -935,11 +935,9 @@ typedef ContextResultData<AsteriskSCF::Media::V1::StreamInformationDict> StreamI
 typedef AMDContextResultData<
     AsteriskSCF::Media::V1::StreamInformationDict,
     AsteriskSCF::SessionCommunications::V1::AMD_SessionController_addStreamsPtr> AddStreamsContextData;
-typedef boost::shared_ptr<AddStreamsContextData> AddStreamsContextDataPtr;
 
 typedef AMDContextData<
     AsteriskSCF::SessionCommunications::V1::AMD_SessionController_removeStreamsPtr> RemoveStreamsContextData;
-typedef boost::shared_ptr<RemoveStreamsContextData> RemoveStreamsContextDataPtr;
 
 class BridgeSessionController : public SessionController
 {
@@ -968,8 +966,7 @@ public:
     {
         try
         {
-            AddStreamsContextDataPtr data(
-                getContext<AddStreamsContextData>(mOperationCache,
+            AddStreamsContextData::ptr_type data(getContext<AddStreamsContextData>(mOperationCache,
                     context, cb));
             if (data)
             {
@@ -1008,9 +1005,8 @@ public:
     {
         try
         {
-            RemoveStreamsContextDataPtr data(
+            RemoveStreamsContextData::ptr_type data(
                 getContext<RemoveStreamsContextData>(mOperationCache, context, cb));
-
             if (data)
             {
                 RemoveStreamsOperation op(context, mSelf, streams);
@@ -1723,14 +1719,13 @@ static SessionPrx extractSession(const SessionWithSessionInfo& swsi)
 }
 
 typedef AMDContextData<AMD_Bridge_addSessionsPtr> AddSessionsContextData;
-typedef boost::shared_ptr<AddSessionsContextData> AddSessionsContextDataPtr;
 
 void BridgeImpl::addSessions_async(const AMD_Bridge_addSessionsPtr& callback,
     const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
     const SessionWithSessionInfoSeq& sessionInfos,
     const Ice::Current&)
 {
-    AddSessionsContextDataPtr data(
+    AddSessionsContextData::ptr_type data(
         getContext<AddSessionsContextData>(
             mOperationContextCache, operationContext, callback));
 
@@ -1814,15 +1809,13 @@ void BridgeImpl::addSessions_async(const AMD_Bridge_addSessionsPtr& callback,
 }
 
 typedef AMDContextData<AMD_Bridge_removeSessionsPtr> RemoveSessionsContextData;
-typedef boost::shared_ptr<RemoveSessionsContextData> RemoveSessionsContextDataPtr;
 
 void BridgeImpl::removeSessions_async(const AMD_Bridge_removeSessionsPtr& callback,
     const AsteriskSCF::System::V1::OperationContextPtr& operationContext, const SessionSeq& sessions,
     const Ice::Current&)
 {
-    RemoveSessionsContextDataPtr data(
-        getContext<RemoveSessionsContextData>(
-            mOperationContextCache, operationContext, callback));
+   RemoveSessionsContextData::ptr_type data(
+        getContext<RemoveSessionsContextData>(mOperationContextCache, operationContext, callback));
     if (data)
     {
         try
@@ -2154,7 +2147,6 @@ void BridgeImpl::removeListener(const AsteriskSCF::System::V1::OperationContextP
 }
 
 typedef AMDContextData<AMD_Bridge_replaceSessionPtr> ReplaceSessionContextData;
-typedef boost::shared_ptr<ReplaceSessionContextData> ReplaceSessionContextDataPtr;
 
 void BridgeImpl::replaceSession_async(const AMD_Bridge_replaceSessionPtr& callback,
     const AsteriskSCF::System::V1::OperationContextPtr& context,
@@ -2162,9 +2154,8 @@ void BridgeImpl::replaceSession_async(const AMD_Bridge_replaceSessionPtr& callba
     const SessionWithSessionInfoSeq& newSessionInfos,
     const Ice::Current& current)
 {
-    ReplaceSessionContextDataPtr data(getContext<ReplaceSessionContextData>(
-            mOperationContextCache, context,
-            callback));
+    ReplaceSessionContextData::ptr_type data(getContext<ReplaceSessionContextData>(mOperationContextCache,
+            context, callback));
     if (data)
     {
         try

commit 469b218b95aa39895db49ead7945f002187868e8
Author: Brent Eagles <beagles at digium.com>
Date:   Thu Apr 12 11:13:17 2012 -0230

    All outgoing contexts related to large scale transactions should now be
    computed according to consistent, reproduceable data.

diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index 895a2bb..bc52972 100755
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -401,7 +401,10 @@ protected:
             {
                 try
                 {
-                    // Apply this hook. 
+                    // Apply this hook.
+                    //
+                    // TODO: Are hooks stateful? Do I have to care about consistent contexts?
+                    //
                     AsteriskSCF::System::Hook::V1::HookResult hookResult = (*i)->modifyForwardingRedirections(
                         AsteriskSCF::Operations::createContext(mRootContext), mSourceSession,
                         destinationSession->getSession(),
@@ -422,8 +425,11 @@ protected:
         SessionControllerPrx sessionController = destinationSession->getSessionController();
         if (sessionController)
         {
+            
             // Forward the info via the SessionController for this session.
-            sessionController->updateRedirections(AsteriskSCF::Operations::createContext(mRootContext), currentRedirections);
+            sessionController->updateRedirections(
+                addContextSuffix(mRootContext, identityToString(sessionController->ice_getIdentity())),
+                currentRedirections);
         }
     }
 
@@ -557,7 +563,8 @@ protected:
         if (sessionController)
         {
             // Forward the info via the SessionController for this session.
-            sessionController->updateConnectedLine(AsteriskSCF::Operations::createContext(mRootContext), currentConnectedLine);
+            sessionController->updateConnectedLine(addContextSuffix(mRootContext, identityToString(sessionController->ice_getIdentity())),
+                currentConnectedLine);
         }
     }
 
@@ -670,7 +677,9 @@ protected:
         SessionControllerPrx sessionController =  destinationSession->getSessionController();
         if (sessionController)
         {
-            sessionController->updateCallerID(AsteriskSCF::Operations::createContext(mRootContext), currentCallerID);
+            sessionController->updateCallerID(
+                addContextSuffix(mRootContext, identityToString(sessionController->ice_getIdentity())),
+                    currentCallerID);
         }
     }
 
@@ -855,9 +864,9 @@ protected:
                 continue;
             }
             tasksDispatched = true;
-            (*i)->begin_setBridge(AsteriskSCF::Operations::createContext(mRootContext), mBridge, mSessionListener,
-                    newCallback_Session_setBridge(this, &SetBridgeTask::set,
-                            &SetBridgeTask::failed), session);
+            (*i)->begin_setBridge(addContextSuffix(mRootContext, identityToString(mBridge->ice_getIdentity())), mBridge,
+                mSessionListener, newCallback_Session_setBridge(this, &SetBridgeTask::set,
+                    &SetBridgeTask::failed), session);
         }
         return !tasksDispatched;
     }
@@ -1125,14 +1134,15 @@ protected:
             }
             tasksDispatched = true;
             SessionControllerPtr controller = new BridgeSessionController(mBridge, session, mLogger);
-	        std::string identity = (*i)->ice_getIdentity().name;
-	        identity += ".bridgecontroller";
-	        SessionControllerPrx controllerPrx =
-                    SessionControllerPrx::uncheckedCast(mAdapter->add(controller, mAdapter->getCommunicator()->stringToIdentity(identity)));
-
-                (*i)->begin_setAndGetSessionController(AsteriskSCF::Operations::createContext(mRootContext), 
-                    controllerPrx, 
-                    newCallback_Session_setAndGetSessionController(this, &SetAndGetSessionControllerTask::get, 
+            std::string identity = (*i)->ice_getIdentity().name;
+            identity += ".bridgecontroller";
+            SessionControllerPrx controllerPrx =
+                SessionControllerPrx::uncheckedCast(mAdapter->add(controller, mAdapter->getCommunicator()->stringToIdentity(identity)));
+            
+            (*i)->begin_setAndGetSessionController(
+                addContextSuffix(mRootContext, identityToString((*i)->ice_getIdentity())), 
+                controllerPrx, 
+                newCallback_Session_setAndGetSessionController(this, &SetAndGetSessionControllerTask::get, 
                     &SetAndGetSessionControllerTask::failed), session);
         }
         return !tasksDispatched;
@@ -1230,8 +1240,8 @@ protected:
 
             // Remove the session controller from the session itself
             SessionControllerPrx controller = SessionControllerPrx::uncheckedCast(mAdapter->createProxy(
-                                                                                      mAdapter->getCommunicator()->stringToIdentity(identity)));
-            (*i)->removeSessionController(AsteriskSCF::Operations::createContext(mRootContext), controller);
+                    mAdapter->getCommunicator()->stringToIdentity(identity)));
+            (*i)->removeSessionController(addContextSuffix(mRootContext, identity), controller);
         }
         return true;
     }
@@ -1335,9 +1345,21 @@ protected:
     {
         if (mBridge->getSessions()->size() < 2 && mPrx)
         {
-            mPrx->begin_shutdown(AsteriskSCF::Operations::createContext(),
-                newCallback_Bridge_shutdown(this, &CheckShutdown::done,
-                    &CheckShutdown::failed));
+            try
+            {
+                mPrx->begin_shutdown(AsteriskSCF::Operations::createContext(),
+                    newCallback_Bridge_shutdown(this, &CheckShutdown::done,
+                        &CheckShutdown::failed));
+            }
+            catch (const Ice::Exception&)
+            {
+                //
+                // This is okay.
+                //
+            }
+            //
+            // Everything else is not.
+            //
         }
         //
         // We don't care about the result really. The CheckShutdown instance will hang
@@ -1556,7 +1578,8 @@ protected:
         for(TelephonyEventSourceSeq::iterator i=fromSources.begin();   
             i != fromSources.end(); ++i)
         {
-            (*i)->removeSinks(AsteriskSCF::Operations::createContext(mRootContext), sinksToRemove);
+            (*i)->removeSinks(addContextSuffix(mRootContext, identityToString((*i)->ice_getIdentity())),
+                sinksToRemove);
         }
     }
 
@@ -1936,7 +1959,7 @@ void BridgeImpl::shutdown(const AsteriskSCF::System::V1::OperationContextPtr& op
                 {
                     Ice::StringSeq keys;
                     keys.push_back(mState->key);
-                    mReplicator->removeState(AsteriskSCF::Operations::createContext(operationContext), keys);
+                    mReplicator->removeState(addContextSuffix(operationContext, mName), keys);
                 }
             }
             catch (const Ice::Exception&)
@@ -2010,7 +2033,7 @@ void BridgeImpl::destroy(const AsteriskSCF::System::V1::OperationContextPtr& con
         {
             Ice::StringSeq keys;
             keys.push_back(mState->key);
-            mReplicator->removeState(AsteriskSCF::Operations::createContext(context), keys);
+            mReplicator->removeState(addContextSuffix(context, mName), keys);
         }
     }
     catch (const Ice::Exception&)
@@ -2043,7 +2066,7 @@ void BridgeImpl::addListener(const AsteriskSCF::System::V1::OperationContextPtr&
             {
                 ReplicatedStateItemSeq seq;
                 seq.push_back(createFirstListenerUpdate(listener));
-                mReplicator->setState(AsteriskSCF::Operations::createContext(operationContext), seq);
+                mReplicator->setState(addContextSuffix(operationContext, mName + ".addListener"), seq);
             }
             data->getMonitor()->setCompleted();
         }
@@ -2102,7 +2125,7 @@ void BridgeImpl::removeListener(const AsteriskSCF::System::V1::OperationContextP
                     {
                         Ice::StringSeq keys;
                         keys.push_back(key);
-                        mReplicator->removeState(AsteriskSCF::Operations::createContext(operationContext), keys);
+                        mReplicator->removeState(addContextSuffix(operationContext, mName + ".removeListener"), keys);
                     }
                     catch (const std::exception& ex)
                     {
diff --git a/src/BridgeManagerImpl.cpp b/src/BridgeManagerImpl.cpp
index 44f2bb7..952b366 100755
--- a/src/BridgeManagerImpl.cpp
+++ b/src/BridgeManagerImpl.cpp
@@ -718,7 +718,8 @@ void BridgeManagerImpl::shutdown(const AsteriskSCF::System::V1::OperationContext
             {
                 if (mCreationExtensionPointServicePrx)
                 {
-                    mCreationExtensionPointServicePrx->unregister(AsteriskSCF::Operations::createContext(operationContext));
+                    mCreationExtensionPointServicePrx->unregister(
+                        addContextSuffix(operationContext, mName + ".shutdown"));
                 }
             }
             catch (const std::exception& ex)
diff --git a/src/BridgeServiceConfig.h b/src/BridgeServiceConfig.h
index b2e95ca..23482ec 100644
--- a/src/BridgeServiceConfig.h
+++ b/src/BridgeServiceConfig.h
@@ -98,5 +98,13 @@ inline AsteriskSCF::System::V1::OperationContextPtr addContextSuffix(
     return result;
 }
 
+inline std::string identityToString(const Ice::Identity& id)
+{
+    //
+    // A discouraged practice, but darn useful at the moment.
+    //
+    return id.name + '/' + id.category;
+}
+
 } // End of namespace BridgeService
 } // End of namespace AsteriskSCF
diff --git a/src/MediaSplicer.cpp b/src/MediaSplicer.cpp
index 12e4a95..9a17057 100755
--- a/src/MediaSplicer.cpp
+++ b/src/MediaSplicer.cpp
@@ -79,6 +79,7 @@ struct MediaConnectorBuilder : public IceUtil::Shared
     IncomingPairings incomingPairings;
     std::map<std::string, std::string> connections;
     DirectMediaConnectionDict directConnections;
+    AsteriskSCF::System::V1::OperationContextPtr rootContext;
 };
 typedef IceUtil::Handle<MediaConnectorBuilder> MediaConnectorBuilderPtr;
 
@@ -266,7 +267,7 @@ public:
         {
             try
             {
-                pairing->first->setSource(AsteriskSCF::Operations::createContext(rootContext), StreamSourcePrx());
+                pairing->first->setSource(addContextSuffix(rootContext, mBridgeId), StreamSourcePrx());
             }
             catch (const Ice::Exception& ex)
             {
@@ -280,7 +281,7 @@ public:
         {
             try
             {
-                pairing->first->removeSink(AsteriskSCF::Operations::createContext(rootContext), pairing->second);
+                pairing->first->removeSink(addContextSuffix(rootContext, mBridgeId), pairing->second);
             }
             catch (const Ice::Exception& ex)
             {
@@ -336,7 +337,7 @@ public:
         {
             try
             {
-                pairing->first->setSource(AsteriskSCF::Operations::createContext(context), StreamSourcePrx());
+                pairing->first->setSource(addContextSuffix(context, mBridgeId + ".disconnectMedia"), StreamSourcePrx());
             }
             catch (const Ice::Exception& ex)
             {
@@ -350,7 +351,7 @@ public:
         {
             try
             {
-                pairing->first->removeSink(AsteriskSCF::Operations::createContext(context), pairing->second);
+                pairing->first->removeSink(addContextSuffix(context, mBridgeId + ".disconnectMedia"), pairing->second);
             }
             catch (const Ice::Exception& ex)
             {
@@ -966,9 +967,13 @@ protected:
         for (OutgoingPairings::iterator i = mMaterials->outgoingPairings.begin(); i != mMaterials->outgoingPairings.end(); ++i)
         {
             OutgoingHelperPtr h(new OutgoingHelper(this, index));
-            i->second->begin_addSink(AsteriskSCF::Operations::createContext(), 
+            i->second->begin_addSink(
+                addContextSuffix(mMaterials->rootContext,
+                    identityToString(i->second->ice_getIdentity())), 
                 i->first, AsteriskSCF::Media::V1::newCallback_StreamSource_addSink(h, &OutgoingHelper::addSinkCB, &OutgoingHelper::failed));
-            i->first->begin_setSource(AsteriskSCF::Operations::createContext(), 
+            i->first->begin_setSource(
+                addContextSuffix(mMaterials->rootContext,
+                    identityToString(i->first->ice_getIdentity())), 
                 i->second, AsteriskSCF::Media::V1::newCallback_StreamSink_setSource(h, &OutgoingHelper::setSourceCB, &OutgoingHelper::failed));
             ++index;
         }
@@ -976,9 +981,13 @@ protected:
         for (IncomingPairings::iterator i = mMaterials->incomingPairings.begin(); i != mMaterials->incomingPairings.end(); ++i)
         {
             IncomingHelperPtr h(new IncomingHelper(this, index));
-            i->first->begin_addSink(AsteriskSCF::Operations::createContext(), 
+            i->first->begin_addSink(
+                addContextSuffix(mMaterials->rootContext,
+                    identityToString(i->first->ice_getIdentity())), 
                 i->second,  AsteriskSCF::Media::V1::newCallback_StreamSource_addSink(h, &IncomingHelper::addSinkCB, &IncomingHelper::failed));
-            i->second->begin_setSource(AsteriskSCF::Operations::createContext(),
+            i->second->begin_setSource(
+                addContextSuffix(mMaterials->rootContext,
+                    identityToString(i->second->ice_getIdentity())), 
                 i->first,  AsteriskSCF::Media::V1::newCallback_StreamSink_setSource(h, &IncomingHelper::setSourceCB, &IncomingHelper::failed));
             ++index;
         }
@@ -1140,7 +1149,7 @@ protected:
             directConnections.insert(make_pair(*stream, mMaterials->directConnections.find(*stream)->second));
         }
 
-        mDirectConnection->begin_connectStreams(AsteriskSCF::Operations::createContext(mRootContext), directConnections,
+        mDirectConnection->begin_connectStreams(mRootContext, directConnections,
             newCallback_DirectMediaConnection_connectStreams(this,
                 &MakeDirectConnections::done,
                 &MakeDirectConnections::failed));
@@ -1170,6 +1179,7 @@ QueuedTasks createMediaConnectTasks(const AsteriskSCF::System::V1::OperationCont
     MediaConnectorBuilderPtr materials(new MediaConnectorBuilder);
     materials->peer = peer;
     materials->sessionPrx = sessionPrx;
+    materials->rootContext = context;
     tasks.push_back(new GetStreams(context, session, materials));
     tasks.push_back(new CreateAndRegisterConnector(context, session, splicer, materials));
     tasks.push_back(new GetCompatiblePairings(context, splicer, materials, mixer));
diff --git a/src/SessionListener.cpp b/src/SessionListener.cpp
index 0e6dd24..919c90e 100644
--- a/src/SessionListener.cpp
+++ b/src/SessionListener.cpp
@@ -164,7 +164,7 @@ public:
                             return;
                         }
 
-                        session->setup(context);
+                        session->setup(addContextSuffix(context, identityToString(mBridgePrx->ice_getIdentity())));
             
                         ConnectSessionOperation connector(context, source, mLogger);
                         mSessions->visitSessions(connector);
diff --git a/src/SessionWrapper.cpp b/src/SessionWrapper.cpp
index b3d8b5b..a672776 100755
--- a/src/SessionWrapper.cpp
+++ b/src/SessionWrapper.cpp
@@ -181,9 +181,11 @@ public:
 protected:
     bool executeImpl()
     {
-        mSession->getSession()->begin_stop(AsteriskSCF::Operations::createContext(mRootContext), mCode, 
-            newCallback_Session_stop(this, &SessionStopTask::removed,
-                    &SessionStopTask::failed));
+        mSession->getSession()->begin_stop(
+            addContextSuffix(mRootContext,
+                identityToString(mSession->getSession()->ice_getIdentity()) + ".SessionStopTask"),
+            mCode, newCallback_Session_stop(this, &SessionStopTask::removed,
+                &SessionStopTask::failed));
         return false;
     }
 
@@ -431,7 +433,7 @@ void SessionWrapper::connect(const AsteriskSCF::System::V1::OperationContextPtr&
         mLogger(Trace) << FUNLOG << " sending ConnectIndication() to " << mId;
 
         mSession->session->begin_indicate(
-            AsteriskSCF::Operations::createContext(rootContext),
+            addContextSuffix(rootContext, ".bridgeConnect"),
 	    new AsteriskSCF::SessionCommunications::V1::ConnectIndication(),
             newCallback_Session_indicate(new ConnectRequestCallback(this, mLogger),
 		&ConnectRequestCallback::connectCB,
@@ -439,7 +441,7 @@ void SessionWrapper::connect(const AsteriskSCF::System::V1::OperationContextPtr&
     }
 }
 
-void SessionWrapper::ring()
+void SessionWrapper::ring(const AsteriskSCF::System::V1::OperationContextPtr& context)
 {
     {
         boost::shared_lock<boost::shared_mutex> lock(mLock);
@@ -448,7 +450,12 @@ void SessionWrapper::ring()
             return;
         }
     }
-    tryOneWay(mSession->session)->indicate(AsteriskSCF::Operations::createContext(),
+    //
+    // We don't need to adorn the context, it is sufficiently op specific
+    // when we get it.
+    //
+    tryOneWay(mSession->session)->indicate(
+        context,
         new AsteriskSCF::SessionCommunications::V1::RingIndication);
 }
 
@@ -510,7 +517,10 @@ void SessionWrapper::setupMedia(const AsteriskSCF::System::V1::OperationContextP
     // TODO: State check
     //
     mConnector = 0;
-    mSplicer->connect(AsteriskSCF::Operations::createContext(context), this, mSession->session);
+    //
+    // The context already includes bridge specific info, so all is well.
+    //
+    mSplicer->connect(addContextSuffix(context, mId), this, mSession->session);
 }
 
 void SessionWrapper::setConnector(const MediaConnectorPtr& connector)
diff --git a/src/SessionWrapper.h b/src/SessionWrapper.h
index 0c30914..29f68a1 100755
--- a/src/SessionWrapper.h
+++ b/src/SessionWrapper.h
@@ -74,7 +74,7 @@ public:
      * Passes a ring request to the encapsulated session.
      * Does not initiate replication.
      **/
-    void ring();
+    void ring(const AsteriskSCF::System::V1::OperationContextPtr& context);
 
     /**
      * Simply sets connected state without initiating additional operations.  Returns true if the state was

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list