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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Jul 12 19:55:37 CDT 2011


branch "bridge-cookies" has been updated
       via  3c7658a6b05a45adfcd11963e9851eb7c7213c24 (commit)
      from  96d470ec32c37b0602c6bb537d86688ed8a1a144 (commit)

Summary of changes:
 .../BridgeService/BridgeReplicatorIf.ice           |    2 +
 src/BridgeImpl.cpp                                 |  117 +++++++++++++++++---
 src/BridgeListenerMgr.cpp                          |   16 ++--
 src/BridgeListenerMgr.h                            |   10 +-
 test/BridgeListenerI.cpp                           |   12 ++-
 test/BridgeListenerI.h                             |   14 ++-
 6 files changed, 137 insertions(+), 34 deletions(-)


- Log -----------------------------------------------------------------
commit 3c7658a6b05a45adfcd11963e9851eb7c7213c24
Author: Brent Eagles <beagles at digium.com>
Date:   Tue Jul 12 22:23:10 2011 -0230

    Initial set of bridge cookie changes.

diff --git a/slice/AsteriskSCF/Replication/BridgeService/BridgeReplicatorIf.ice b/slice/AsteriskSCF/Replication/BridgeService/BridgeReplicatorIf.ice
index 4b404cb..6f5c177 100644
--- a/slice/AsteriskSCF/Replication/BridgeService/BridgeReplicatorIf.ice
+++ b/slice/AsteriskSCF/Replication/BridgeService/BridgeReplicatorIf.ice
@@ -203,6 +203,8 @@ class BridgeStateItem extends ReplicatedStateItem
     ServiceState runningState;
 
     MediaOperationReplicationPolicy mediaReplicationPolicy;
+
+    AsteriskSCF::SessionCommunications::V1::BridgeCookieDict cookies;
 };
 
 class BridgeListenerStateItem extends ReplicatedStateItem
diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index f669b40..c5c646f 100755
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -92,6 +92,10 @@ public:
     void replaceSession_async(const AMD_Bridge_replaceSessionPtr& callbac, const SessionPrx& sessionToReplace,
             const SessionSeq& newSessions, const Ice::Current& current);
 
+    void setCookies(const BridgeCookies& cookies, const Ice::Current&);
+    void removeCookies(const BridgeCookies& cookies, const Ice::Current&);
+    BridgeCookies getCookies(const BridgeCookies& cookies, const Ice::Current&);
+
     //
     // BridgeServant methods
     //
@@ -112,6 +116,16 @@ public:
 
     void getAddSessionsTasks(QueuedTasks& tasks, const SessionSeq& sessions);
 
+    BridgeCookies getCookies()
+    {
+        BridgeCookies result;
+        for (BridgeCookieDict::const_iterator i = mState->cookies.begin(); i != mState->cookies.end(); ++i)
+        {
+            result.push_back(i->second);
+        }
+        return result;
+    }
+
 private:
 
     boost::shared_mutex mLock;
@@ -246,10 +260,11 @@ class RemoveSessionsNotify : public QueuedTask
 {
 public:
     RemoveSessionsNotify(const BridgeListenerMgrPtr& bridgeListeners,
-            const SessionsTrackerPtr& tracker) :
+            const SessionsTrackerPtr& tracker, const BridgeCookies& cookies) :
         QueuedTask("RemoveSessionsNotify"),
         mBridgeListeners(bridgeListeners),
-        mTracker(tracker)
+        mTracker(tracker),
+        mCookies(cookies)
     {
     }
     
@@ -259,7 +274,7 @@ protected:
         SessionSeq sessions = mTracker->getSessions();
         if (!sessions.empty())
         {
-            mBridgeListeners->sessionsRemoved(sessions);
+            mBridgeListeners->sessionsRemoved(sessions, mCookies);
         }
         return true;
     }
@@ -267,6 +282,7 @@ protected:
 private:
     BridgeListenerMgrPtr mBridgeListeners;
     SessionsTrackerPtr mTracker;
+    BridgeCookies mCookies;
 };
 
 class SetBridgeTask : public QueuedTask
@@ -368,23 +384,26 @@ private:
 class AddToListeners : public QueuedTask
 {
 public:
-    AddToListeners(const BridgeListenerMgrPtr& listeners, const SessionsTrackerPtr& tracker) :
+    AddToListeners(const BridgeListenerMgrPtr& listeners, const SessionsTrackerPtr& tracker,
+        const BridgeCookies& cookies) :
         QueuedTask("AddToListeners"),
         mListeners(listeners),
-        mTracker(tracker)
+        mTracker(tracker),
+        mCookies(cookies)
     {
     }
     
 protected:
     bool executeImpl()
     {
-        mListeners->sessionsAdded(mTracker->getSessions());
+        mListeners->sessionsAdded(mTracker->getSessions(), mCookies);
         return true;
     }
     
 private:
     BridgeListenerMgrPtr mListeners;
     SessionsTrackerPtr mTracker;
+    BridgeCookies mCookies;
 };
 
 class CheckShutdown : public QueuedTask
@@ -543,7 +562,7 @@ void BridgeImpl::addSessions_async(const AMD_Bridge_addSessionsPtr& callback, co
         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 AddToListeners(mListeners, tracker, getCookies()));
         tasks.push_back(new GenericAMDCallback<AMD_Bridge_addSessionsPtr>(callback, tracker));
         tasks.push_back(new UpdateTask(this));
         ExecutorPtr executor(new Executor(tasks, mLogger));
@@ -596,7 +615,13 @@ void BridgeImpl::removeSessions_async(const AMD_Bridge_removeSessionsPtr& callba
             }
         }
         QueuedTasks tasks;
-        tasks.push_back(new RemoveSessionsNotify(mListeners, removed));
+
+        BridgeCookies cookies;
+        {
+            boost::shared_lock<boost::shared_mutex> lock(mLock);
+            cookies = getCookies();
+        }
+        tasks.push_back(new RemoveSessionsNotify(mListeners, removed, cookies));
         tasks.push_back(new GenericAMDCallback<AMD_Bridge_removeSessionsPtr>(callback, removed));
         tasks.push_back(new CheckShutdown(this, mPrx));
         ExecutorPtr runner(new Executor(tasks, mLogger));
@@ -648,7 +673,7 @@ void BridgeImpl::shutdown(const Ice::Current& current)
         }
         mState->runningState = ShuttingDown;
 
-        mListeners->stopping();
+        mListeners->stopping(getCookies());
         update = createUpdate();
     }
     pushUpdate(update);
@@ -661,8 +686,8 @@ void BridgeImpl::shutdown(const Ice::Current& current)
         ResponseCodePtr responseCode = new ResponseCode;
         ShutdownSessionOperation shutdownOp(mSessionListenerPrx, responseCode, mLogger);
         mSessions->visitSessions(shutdownOp);
-        mListeners->stopped();
         boost::unique_lock<boost::shared_mutex> lock(mLock);
+        mListeners->stopped(getCookies());
         mLogger(Info) << objectIdFromCurrent(current) << ": is shutdown." ;
         mState->runningState = Destroyed;
         //
@@ -694,7 +719,7 @@ void BridgeImpl::destroy(const Ice::Current& current)
         }
         mState->runningState = Destroyed;
         mLogger(Info) << objectIdFromCurrent(current) << ": is now destroyed." ;
-        mListeners->stopped();
+        mListeners->stopped(getCookies());
         mSessionListener = 0;
         update = createUpdate();
     }
@@ -794,9 +819,14 @@ void BridgeImpl::replaceSession_async(const AMD_Bridge_replaceSessionPtr& callba
         
         SessionsTrackerPtr tracker(new SessionsTracker);
         QueuedTasks tasks;
-        tasks.push_back(new RemoveSessionsNotify(mListeners, removeTracker));
+        BridgeCookies cookies;
+        {
+            boost::shared_lock<boost::shared_mutex> lock(mLock);
+            cookies = getCookies();
+        }
+        tasks.push_back(new RemoveSessionsNotify(mListeners, removeTracker, cookies));
         tasks.push_back(new SetBridgeTask(mSessions, mPrx, mSessionListenerPrx, newSessions, tracker));
-        tasks.push_back(new AddToListeners(mListeners, tracker));
+        tasks.push_back(new AddToListeners(mListeners, tracker, cookies));
         tasks.push_back(new GenericAMDCallback<AMD_Bridge_replaceSessionPtr>(callback, tracker));
         tasks.push_back(new UpdateTask(this));
         ExecutorPtr executor(new Executor(tasks, mLogger));
@@ -812,6 +842,65 @@ void BridgeImpl::replaceSession_async(const AMD_Bridge_replaceSessionPtr& callba
     }
 }
 
+void BridgeImpl::setCookies(const BridgeCookies& cookies, const Ice::Current& current)
+{
+    mLogger(Debug) << FUNLOG << ":" << objectIdFromCurrent(current);
+    BridgeStateItemPtr update;
+    {
+        boost::unique_lock<boost::shared_mutex> lock(mLock);
+        for (BridgeCookies::const_iterator i = cookies.begin(); i != cookies.end(); ++i)
+        {
+            mState->cookies[(*i)->ice_id()] = (*i);
+        }
+        if (!cookies.empty())
+        {
+            update = createUpdate();
+        }
+    }
+    pushUpdate(update);
+}
+
+void BridgeImpl::removeCookies(const BridgeCookies& cookies, const Ice::Current& current)
+{
+    mLogger(Debug) << FUNLOG << ":" << objectIdFromCurrent(current);
+    BridgeStateItemPtr update;
+    {
+        boost::unique_lock<boost::shared_mutex> lock(mLock);
+        bool dirty = false;
+        for (BridgeCookies::const_iterator i = cookies.begin(); i != cookies.end(); ++i)
+        {
+            BridgeCookieDict::iterator v = mState->cookies.find((*i)->ice_id());
+            if (v != mState->cookies.end())
+            {
+                dirty = true;
+                mState->cookies.erase(v);
+            }
+        }
+
+        if (dirty)
+        {
+            update = createUpdate();
+        }
+    }
+    pushUpdate(update);
+}
+
+BridgeCookies BridgeImpl::getCookies(const BridgeCookies& cookies, const Ice::Current& current)
+{
+    BridgeCookies result;
+    mLogger(Debug) << FUNLOG << ":" << objectIdFromCurrent(current);
+    boost::shared_lock<boost::shared_mutex> lock(mLock);
+    for (BridgeCookies::const_iterator i = cookies.begin(); i != cookies.end(); ++i)
+    {
+        BridgeCookieDict::const_iterator v = mState->cookies.find((*i)->ice_id());
+        if (v != mState->cookies.end())
+        {
+            result.push_back(v->second);
+        }
+    }
+    return result;
+}
+
 bool BridgeImpl::destroyed()
 {
     boost::shared_lock<boost::shared_mutex> lock(mLock);
@@ -944,7 +1033,7 @@ void BridgeImpl::getAddSessionsTasks(QueuedTasks& tasks,
 {
     SessionsTrackerPtr tracker(new SessionsTracker);
     tasks.push_back(new SetBridgeTask(mSessions, mPrx, mSessionListenerPrx, sessions, tracker));
-    tasks.push_back(new AddToListeners(mListeners, tracker));
+    tasks.push_back(new AddToListeners(mListeners, tracker, getCookies()));
     tasks.push_back(new UpdateTask(this));
 }
 
diff --git a/src/BridgeListenerMgr.cpp b/src/BridgeListenerMgr.cpp
index 146162e..d4e214f 100644
--- a/src/BridgeListenerMgr.cpp
+++ b/src/BridgeListenerMgr.cpp
@@ -26,22 +26,22 @@ BridgeListenerMgr::BridgeListenerMgr(const Ice::CommunicatorPtr& comm,
 {
 }
 
-void BridgeListenerMgr::sessionsAdded(const SessionSeq& sessions)
+void BridgeListenerMgr::sessionsAdded(const SessionSeq& sessions, const BridgeCookies& cookies)
 {
-    mPublisher->sessionsAdded(mPrx, sessions);
+    mPublisher->sessionsAdded(mPrx, sessions, cookies);
 }
 
-void BridgeListenerMgr::sessionsRemoved(const SessionSeq& sessions)
+void BridgeListenerMgr::sessionsRemoved(const SessionSeq& sessions, const BridgeCookies& cookies)
 {
-    mPublisher->sessionsRemoved(mPrx, sessions);
+    mPublisher->sessionsRemoved(mPrx, sessions, cookies);
 }
 
-void BridgeListenerMgr::stopped()
+void BridgeListenerMgr::stopped(const BridgeCookies& cookies)
 {
-    mPublisher->stopped(mPrx);
+    mPublisher->stopped(mPrx, cookies);
 }
 
-void BridgeListenerMgr::stopping()
+void BridgeListenerMgr::stopping(const BridgeCookies& cookies)
 {
-    mPublisher->stopping(mPrx);
+    mPublisher->stopping(mPrx, cookies);
 }
diff --git a/src/BridgeListenerMgr.h b/src/BridgeListenerMgr.h
index 5c31156..6bf07b1 100644
--- a/src/BridgeListenerMgr.h
+++ b/src/BridgeListenerMgr.h
@@ -30,10 +30,12 @@ public:
     BridgeListenerMgr(const Ice::CommunicatorPtr& communicator, const std::string& name,
         const AsteriskSCF::SessionCommunications::V1::BridgePrx& source);
 
-    void sessionsAdded(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions);
-    void sessionsRemoved(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions);
-    void stopped();
-    void stopping();
+    void sessionsAdded(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, 
+        const AsteriskSCF::SessionCommunications::V1::BridgeCookies& cookies);
+    void sessionsRemoved(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, 
+        const AsteriskSCF::SessionCommunications::V1::BridgeCookies& cookies);
+    void stopped(const AsteriskSCF::SessionCommunications::V1::BridgeCookies& cookies);
+    void stopping(const AsteriskSCF::SessionCommunications::V1::BridgeCookies& cookies);
 
 private:
     AsteriskSCF::SessionCommunications::V1::BridgePrx mPrx;
diff --git a/test/BridgeListenerI.cpp b/test/BridgeListenerI.cpp
index 1499846..16dcfc1 100644
--- a/test/BridgeListenerI.cpp
+++ b/test/BridgeListenerI.cpp
@@ -23,26 +23,30 @@ BridgeListenerI::BridgeListenerI() :
 {
 }
 
-void BridgeListenerI::sessionsAdded(const AsteriskSCF::SessionCommunications::V1::BridgePrx&, const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, const Ice::Current&)
+void BridgeListenerI::sessionsAdded(const AsteriskSCF::SessionCommunications::V1::BridgePrx&, const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, 
+    const AsteriskSCF::SessionCommunications::V1::BridgeCookies&, const Ice::Current&)
 {
     IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mAddMonitor);
     mAdded.insert(mAdded.end(), sessions.begin(), sessions.end());
     mAddMonitor.notify();
 }
 
-void BridgeListenerI::sessionsRemoved(const AsteriskSCF::SessionCommunications::V1::BridgePrx&, const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, const Ice::Current&)
+void BridgeListenerI::sessionsRemoved(const AsteriskSCF::SessionCommunications::V1::BridgePrx&, const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, 
+    const AsteriskSCF::SessionCommunications::V1::BridgeCookies&, const Ice::Current&)
 {
     IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mRemoveMonitor);
     mRemoved.insert(mRemoved.end(), sessions.begin(), sessions.end());
     mRemoveMonitor.notify();
 }
 
-void BridgeListenerI::stopping(const AsteriskSCF::SessionCommunications::V1::BridgePrx&, const Ice::Current&)
+void BridgeListenerI::stopping(const AsteriskSCF::SessionCommunications::V1::BridgePrx&, 
+    const AsteriskSCF::SessionCommunications::V1::BridgeCookies&, const Ice::Current&)
 {
     mShuttingDown = true;
 }
 
-void BridgeListenerI::stopped(const AsteriskSCF::SessionCommunications::V1::BridgePrx&, const Ice::Current&)
+void BridgeListenerI::stopped(const AsteriskSCF::SessionCommunications::V1::BridgePrx&, 
+    const AsteriskSCF::SessionCommunications::V1::BridgeCookies&, const Ice::Current&)
 {
     IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mStateMonitor);
     mStopped = true;
diff --git a/test/BridgeListenerI.h b/test/BridgeListenerI.h
index c8550e5..4b40eff 100644
--- a/test/BridgeListenerI.h
+++ b/test/BridgeListenerI.h
@@ -26,10 +26,16 @@ class BridgeListenerI : public AsteriskSCF::SessionCommunications::V1::BridgeLis
 {
 public:
     BridgeListenerI();
-    void sessionsAdded(const AsteriskSCF::SessionCommunications::V1::BridgePrx& bridge, const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, const Ice::Current& current);
-    void sessionsRemoved(const AsteriskSCF::SessionCommunications::V1::BridgePrx& bridge, const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, const Ice::Current& current);
-    void stopping(const AsteriskSCF::SessionCommunications::V1::BridgePrx& bridge, const Ice::Current& current);
-    void stopped(const AsteriskSCF::SessionCommunications::V1::BridgePrx& bridge, const Ice::Current& current);
+    void sessionsAdded(const AsteriskSCF::SessionCommunications::V1::BridgePrx& bridge, 
+        const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, 
+        const AsteriskSCF::SessionCommunications::V1::BridgeCookies& cookies, const Ice::Current& current);
+    void sessionsRemoved(const AsteriskSCF::SessionCommunications::V1::BridgePrx& bridge, 
+        const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions, 
+        const AsteriskSCF::SessionCommunications::V1::BridgeCookies& cookies, const Ice::Current& current);
+    void stopping(const AsteriskSCF::SessionCommunications::V1::BridgePrx& bridge, 
+        const AsteriskSCF::SessionCommunications::V1::BridgeCookies& cookies, const Ice::Current& current);
+    void stopped(const AsteriskSCF::SessionCommunications::V1::BridgePrx& bridge, 
+        const AsteriskSCF::SessionCommunications::V1::BridgeCookies& cookies, const Ice::Current& current);
     bool resetShuttingDown();
     bool resetStopped();
 

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


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list