[asterisk-scf-commits] asterisk-scf/integration/routing.git branch "retry_deux" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Feb 14 18:43:00 CST 2012


branch "retry_deux" has been created
        at  d3261c499f89fd218e21f8b409ab1b7fda22a2ef (commit)

- Log -----------------------------------------------------------------
commit d3261c499f89fd218e21f8b409ab1b7fda22a2ef
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue Feb 14 18:42:27 2012 -0600

    Introduced operation context handling

diff --git a/slice/AsteriskSCF/Replication/BasicRoutingService/BasicRoutingStateReplicationIf.ice b/slice/AsteriskSCF/Replication/BasicRoutingService/BasicRoutingStateReplicationIf.ice
index 6082325..bf12701 100644
--- a/slice/AsteriskSCF/Replication/BasicRoutingService/BasicRoutingStateReplicationIf.ice
+++ b/slice/AsteriskSCF/Replication/BasicRoutingService/BasicRoutingStateReplicationIf.ice
@@ -20,6 +20,7 @@
 #include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.ice>
 #include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.ice>
 #include <AsteriskSCF/SessionCommunications/SessionCommunicationsExtensionPointsIf.ice>
+#include <AsteriskSCF/System/OperationsIf.ice>
 
 module AsteriskSCF
 {
@@ -61,9 +62,9 @@ module V1
      */
     interface RoutingStateReplicatorListener
     {
-        void stateRemoved(Ice::StringSeq itemKeys);
-        void stateRemovedForItems(RoutingStateItemSeq items);
-        void stateSet(RoutingStateItemSeq items);
+        idempotent void stateRemoved(AsteriskSCF::System::V1::OperationContext operationContext, Ice::StringSeq itemKeys);
+        idempotent void stateRemovedForItems(AsteriskSCF::System::V1::OperationContext operationContext, RoutingStateItemSeq items);
+        idempotent void stateSet(AsteriskSCF::System::V1::OperationContext operationContext, RoutingStateItemSeq items);
     };
 
     /**
@@ -71,11 +72,14 @@ module V1
      */
     interface RoutingStateReplicator
     {
-       void addListener(RoutingStateReplicatorListener *listener);
-       void removeListener(RoutingStateReplicatorListener *listener);
-       void setState (RoutingStateItemSeq items);
-       void removeState(Ice::StringSeq items);
-       void removeStateForItems(RoutingStateItemSeq items);
+       idempotent void addListener(RoutingStateReplicatorListener *listener);
+       idempotent void removeListener(RoutingStateReplicatorListener *listener);
+       idempotent void setState (AsteriskSCF::System::V1::OperationContext operationContext, RoutingStateItemSeq items) throws 
+           AsteriskSCF::System::V1::OperationCallCancelledException;
+       idempotent void removeState(AsteriskSCF::System::V1::OperationContext operationContext, Ice::StringSeq items) throws
+           AsteriskSCF::System::V1::OperationCallCancelledException;
+       idempotent void removeStateForItems(AsteriskSCF::System::V1::OperationContext operationContext, RoutingStateItemSeq items) throws 
+           AsteriskSCF::System::V1::OperationCallCancelledException;
        idempotent RoutingStateItemSeq getState(Ice::StringSeq itemKeys);
        idempotent RoutingStateItemSeq getAllState();
     };
diff --git a/src/BasicRoutingStateReplicatorApp.cpp b/src/BasicRoutingStateReplicatorApp.cpp
index 0e385dd..0623ec6 100644
--- a/src/BasicRoutingStateReplicatorApp.cpp
+++ b/src/BasicRoutingStateReplicatorApp.cpp
@@ -24,6 +24,7 @@
 #include <AsteriskSCF/Logger.h>
 #include <AsteriskSCF/Logger/IceLogger.h>
 #include <AsteriskSCF/Replication/StateReplicator.h>
+#include <AsteriskSCF/Helpers/OperationContext.h>
 #include "BasicRoutingStateReplicationIf.h"
 
 using namespace std;
@@ -139,7 +140,7 @@ void setCategory(const Discovery::V1::ServiceManagementPrx& serviceManagement,
     genericparams->category = category;
     genericparams->service = service;
     genericparams->id = id;
-    serviceManagement->addLocatorParams(genericparams, "");
+    serviceManagement->addLocatorParams(AsteriskSCF::createContext(), genericparams, "");
 }
 
 /**
diff --git a/src/ConnectBridgedSessionsOperation.cpp b/src/ConnectBridgedSessionsOperation.cpp
index e3955cc..9e789ca 100644
--- a/src/ConnectBridgedSessionsOperation.cpp
+++ b/src/ConnectBridgedSessionsOperation.cpp
@@ -24,6 +24,7 @@ using namespace AsteriskSCF;
 using namespace AsteriskSCF::Core::Routing::V1;
 using namespace AsteriskSCF::SessionCommunications::V1;
 using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::System::V1;
 
 namespace
 {
@@ -48,7 +49,7 @@ namespace BasicRoutingService
 
 ConnectBridgedSessionsOperation::ConnectBridgedSessionsOperation
                            (const AMD_SessionRouter_connectBridgedSessionsPtr& cb,
-                            const std::string& operationId,
+                            const OperationContextPtr& operationContext,
                             const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace, 
                             const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& bridgedSession, 
                             bool replaceSession,
@@ -62,7 +63,7 @@ ConnectBridgedSessionsOperation::ConnectBridgedSessionsOperation
                                       current,
                                       listener,
                                       ConnectBridgedSessionsOp::STATE_CONNECT,
-                                      operationId),
+                                      operationContext),
            mSessionToReplace(sessionToReplace),
            mBridgedSession(bridgedSession),
            mReplaceSession(replaceSession)
@@ -76,7 +77,7 @@ ConnectBridgedSessionsOperation::ConnectBridgedSessionsOperation
  */
 ConnectBridgedSessionsOperationPtr ConnectBridgedSessionsOperation::create
                     (const AMD_SessionRouter_connectBridgedSessionsPtr& cb,
-                    const std::string& operationId,
+                    const OperationContextPtr& operationContext,
                     const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace, 
                     const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& bridgedSession, 
                     bool replaceSession,
@@ -86,7 +87,7 @@ ConnectBridgedSessionsOperationPtr ConnectBridgedSessionsOperation::create
 {
   
     ConnectBridgedSessionsOperationPtr ptr(new ConnectBridgedSessionsOperation(cb,
-                                                                               operationId,
+                                                                               operationContext,
                                                                                sessionToReplace,
                                                                                bridgedSession,
                                                                                replaceSession,
@@ -150,7 +151,7 @@ void ConnectBridgedSessionsOperation::connectBridgedSessionsState()
         return;
     }
 
-    SessionSeq migratingSessions = removeSessionsFromBridge(oldBridge, mBridgedSession);
+    SessionSeq migratingSessions = removeSessionsFromBridge(mOperationContext, oldBridge, mBridgedSession);
 
     SessionWithSessionInfoSeq infoSeq;
     for (SessionSeq::iterator sessionIter = migratingSessions.begin(); sessionIter != migratingSessions.end(); ++sessionIter)
@@ -180,12 +181,12 @@ void ConnectBridgedSessionsOperation::connectBridgedSessionsState()
         if (mReplaceSession)
         {
             lg(Debug) << BOOST_CURRENT_FUNCTION << ": Asking bridge to add sessions." ;
-            mergeBridge->replaceSession(mSessionToReplace, infoSeq);
+            mergeBridge->replaceSession(mOperationContext, mSessionToReplace, infoSeq);
         }
         else
         {
             lg(Debug) << BOOST_CURRENT_FUNCTION << ": Asking bridge to replace sessions." ;
-            mergeBridge->addSessions(infoSeq);
+            mergeBridge->addSessions(mOperationContext, infoSeq);
         }
     }
     catch(const Ice::Exception& e)
diff --git a/src/ConnectBridgedSessionsOperation.h b/src/ConnectBridgedSessionsOperation.h
index 3313664..c8a244f 100644
--- a/src/ConnectBridgedSessionsOperation.h
+++ b/src/ConnectBridgedSessionsOperation.h
@@ -61,7 +61,7 @@ class  ConnectBridgedSessionsOperation : public SessionRouterOperation<AsteriskS
 public:
     static ConnectBridgedSessionsOperationPtr create(
                           const AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_connectBridgedSessionsPtr& cb,
-                          const std::string& operationId,
+                          const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
                           const AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace, 
                           const AsteriskSCF::SessionCommunications::V1::SessionPrx& bridgedSession, 
                           bool replaceSession,
@@ -73,7 +73,7 @@ public:
 
 protected:
     ConnectBridgedSessionsOperation(const AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_connectBridgedSessionsPtr& cb,
-                                    const std::string& operationId,
+                                    const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
                                     const AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace, 
                                     const AsteriskSCF::SessionCommunications::V1::SessionPrx& bridgedSession, 
                                     bool replaceSession,
diff --git a/src/ConnectBridgedSessionsWithDestinationOperation.cpp b/src/ConnectBridgedSessionsWithDestinationOperation.cpp
index 03d54f6..3d00d7b 100644
--- a/src/ConnectBridgedSessionsWithDestinationOperation.cpp
+++ b/src/ConnectBridgedSessionsWithDestinationOperation.cpp
@@ -17,6 +17,7 @@
 #include <boost/bind.hpp>
 
 #include <AsteriskSCF/Logger.h>
+#include <AsteriskSCF/Helpers/OperationContext.h>
 
 #include "BasicRoutingStateReplicationIf.h"
 #include "ConnectBridgedSessionsWithDestinationOperation.h"
@@ -29,6 +30,7 @@ using namespace AsteriskSCF::System::Logging;
 using namespace AsteriskSCF::BasicRoutingService;
 using namespace AsteriskSCF::Replication::BasicRoutingService::V1;
 using namespace AsteriskSCF::StateMachine;
+using namespace AsteriskSCF::System::V1;
 
 namespace
 {
@@ -49,7 +51,7 @@ class ConnectBridgedSessionsWithDestReplicatingListener :
 public:
     ConnectBridgedSessionsWithDestReplicatingListener(ConnectBridgedSessionsWithDestinationOperationPtr op, 
                                                       const RoutingReplicationContextPtr& replication)  
-                                                         : mOperationId(op->getOperationId()),
+                                                         : mOperationContext(op->getOperationContext()),
                                                            mOperation(op), 
                                                            mReplicationContext(replication)
     {
@@ -57,7 +59,7 @@ public:
 
     ~ConnectBridgedSessionsWithDestReplicatingListener()
     {
-        lg(Debug) << "ConnectBridgedSessionsWithDestReplicatingListener() being destroyed for operation " << mOperationId;
+        lg(Debug) << "ConnectBridgedSessionsWithDestReplicatingListener() being destroyed for operation " << mOperationContext->id;
     }
 
     /**
@@ -77,8 +79,8 @@ public:
                 // Push this information to the state replicator.
                 ConnectBridgedSessionsWithDestinationOpStartPtr 
                      opStart(new ConnectBridgedSessionsWithDestinationOpStart());
-                opStart->operationId = mOperation->getOperationId();
-                opStart->key = mOperation->getOperationId() + 
+                opStart->operationId = mOperationContext->id;
+                opStart->key = mOperationContext->id + 
                      ConnectBridgedSessionsWithDestStartKeyMod;
                 opStart->sessionToReplace = mOperation->getSessionToReplace();
                 opStart->destination = mOperation->getDestination();
@@ -93,8 +95,8 @@ public:
             // We've obtained a result from our AMI lookup request.
             ConnectBridgedSessionsWithDestinationOpWaitLookupStatePtr 
                  waitLookup(new ConnectBridgedSessionsWithDestinationOpWaitLookupState());
-            waitLookup->operationId = mOperation->getOperationId();
-            waitLookup->key = mOperation->getOperationId() + 
+            waitLookup->operationId = mOperationContext->id;
+            waitLookup->key = mOperationContext->id + 
                  RouteSessionOpWaitLookupKeyMod;
             waitLookup->endpoints = mOperation->getLookupResult();
             waitLookup->remainingSessions = mOperation->getRemainingSessions();
@@ -113,7 +115,7 @@ public:
         RoutingStateItemSeq setItems;
 
         setItems.push_back(item);
-        mReplicationContext->getReplicator()->setState(setItems);
+        mReplicationContext->getReplicator()->setState(AsteriskSCF::createContext(), setItems);
         
         // Cache the replicated items.
         mReplicatedState.push_back(item);
@@ -137,7 +139,7 @@ public:
             {
                 // We just completed the entire operation. 
                 // Remove the items that represented this operation's state transitions from the state replicator.
-                mReplicationContext->getReplicator()->removeStateForItems(mReplicatedState);
+                mReplicationContext->getReplicator()->removeStateForItems(AsteriskSCF::createContext(), mReplicatedState);
             }
         }
         catch(...)
@@ -169,8 +171,8 @@ public:
             // Push this information to the state replicator.
             ConnectBridgedSessionsWithDestinationOpBridgingStatePtr 
                  bridgeOp(new ConnectBridgedSessionsWithDestinationOpBridgingState());
-            bridgeOp->operationId = mOperation->getOperationId();
-            bridgeOp->key = mOperation->getOperationId() + 
+            bridgeOp->operationId = mOperationContext->id;
+            bridgeOp->key = mOperationContext->id + 
                     RouteSessionOpBridgingKeyMod;
             bridgeOp->bridge = mOperation->getBridge();
 
@@ -186,7 +188,7 @@ public:
 
 private:
     RoutingStateItemSeq mReplicatedState;
-    std::string mOperationId;
+    OperationContextPtr mOperationContext;
     ConnectBridgedSessionsWithDestinationOperationPtr mOperation;
     RoutingReplicationContextPtr mReplicationContext;
 
@@ -212,7 +214,7 @@ void ConnectBridgedSessionsWithDestinationOperation::initStateMachine()
  */
 ConnectBridgedSessionsWithDestinationOperation::ConnectBridgedSessionsWithDestinationOperation(
                           const AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr& cb,
-                          const std::string& operationId,
+                          const OperationContextPtr& operationContext,
                           const SessionPrx& sessionToReplace, 
                           const ::std::string& destination, 
                           bool replaceSession,
@@ -226,7 +228,7 @@ ConnectBridgedSessionsWithDestinationOperation::ConnectBridgedSessionsWithDestin
                                 current,
                                 listener,
                                 ConnectBridgedSessionsWithDestinationOp::STATE_LOOKUP,
-                                operationId),
+                                operationContext),
         mSessionToReplace(sessionToReplace),
         mDestination(destination),
         mReplaceSession(replaceSession),
@@ -240,7 +242,7 @@ ConnectBridgedSessionsWithDestinationOperation::ConnectBridgedSessionsWithDestin
  */
 ConnectBridgedSessionsWithDestinationOperationPtr ConnectBridgedSessionsWithDestinationOperation::create(
                           const AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr& cb,
-                          const std::string& operationId,
+                          const OperationContextPtr& operationContext,
                           const SessionPrx& sessionToReplace, 
                           const ::std::string& destination, 
                           bool replaceSession,
@@ -251,7 +253,7 @@ ConnectBridgedSessionsWithDestinationOperationPtr ConnectBridgedSessionsWithDest
 {
 
     ConnectBridgedSessionsWithDestinationOperationPtr op( new ConnectBridgedSessionsWithDestinationOperation(cb,
-                                                        operationId,
+                                                        operationContext,
                                                         sessionToReplace,
                                                         destination,
                                                         replaceSession,
@@ -320,7 +322,7 @@ void ConnectBridgedSessionsWithDestinationOperation::reflectUpdate(
 {
     mSessionToReplace = item->sessionToReplace;
     mDestination = item->destination;
-    mOperationId = item->operationId;
+    mOperationContext = new OperationContext(item->operationId);
     mReplaceSession = item->replaceSession;
 
     mReplicatedStates.push_back(ConnectBridgedSessionsWithDestinationOp::STATE_LOOKUP);
@@ -461,7 +463,7 @@ void ConnectBridgedSessionsWithDestinationOperation::establishBridgeState()
     }
 
     // Add a session 
-    SessionSeq newSessions = createSessionForEndpoints(mLookupResult, mDestination, mHook, mListenerManager);
+    SessionSeq newSessions = createSessionForEndpoints(mOperationContext, mLookupResult, mDestination, mHook, mListenerManager);
     SessionWithSessionInfoSeq infoSeq;
     for (SessionSeq::iterator sessionIter = newSessions.begin(); sessionIter != newSessions.end(); ++sessionIter)
     {
@@ -494,12 +496,12 @@ void ConnectBridgedSessionsWithDestinationOperation::establishBridgeState()
         if (mReplaceSession)
         {
             lg(Debug) << BOOST_CURRENT_FUNCTION << ": Replacing session with newly routed destination " << mDestination;
-            mBridge->replaceSession(mSessionToReplace, infoSeq);
+            mBridge->replaceSession(mOperationContext, mSessionToReplace, infoSeq);
         }
         else
         {
             lg(Debug) << BOOST_CURRENT_FUNCTION << ": Adding newly routed destination to session's bridge " << mDestination;
-            mBridge->addSessions(infoSeq);
+            mBridge->addSessions(mOperationContext, infoSeq);
         }
     }
     catch (const Ice::Exception &e)
diff --git a/src/ConnectBridgedSessionsWithDestinationOperation.h b/src/ConnectBridgedSessionsWithDestinationOperation.h
index b9f2fb0..4b3183a 100644
--- a/src/ConnectBridgedSessionsWithDestinationOperation.h
+++ b/src/ConnectBridgedSessionsWithDestinationOperation.h
@@ -68,7 +68,7 @@ public:
      * Factory method for the class. This method creates an active operation. 
      */
     static ConnectBridgedSessionsWithDestinationOperationPtr create(const AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr& cb,
-                                                                    const std::string& operationId,
+                                                                    const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
                                                                     const AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace, 
                                                                     const std::string& destination, 
                                                                     bool replaceSession,
@@ -112,7 +112,7 @@ public:
 
 protected:
     ConnectBridgedSessionsWithDestinationOperation(const AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr& cb,
-                        const std::string& operationId,
+                        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
                         const AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace, 
                         const std::string& destination, 
                         bool replaceSession,
diff --git a/src/EndpointRegistry.cpp b/src/EndpointRegistry.cpp
index 0f37e78..b7dce0f 100644
--- a/src/EndpointRegistry.cpp
+++ b/src/EndpointRegistry.cpp
@@ -19,6 +19,7 @@
 
 #include <AsteriskSCF/Logger.h>
 #include <AsteriskSCF/Discovery/SmartProxy.h>
+#include <AsteriskSCF/Helpers/OperationContext.h>
 
 #include "RoutingServiceEventPublisher.h"
 #include "EndpointRegistry.h"
@@ -142,7 +143,7 @@ public:
                 removeItems.push_back(addEndpointItem);
 
                 lg(Debug) << BOOST_CURRENT_FUNCTION << ": Sending replicator state removal for locator " << locatorId;
-                mReplicationContext->getReplicator()->removeStateForItems(removeItems);
+                mReplicationContext->getReplicator()->removeStateForItems(AsteriskSCF::createContext(), removeItems);
             }
             catch(const Ice::Exception& e)
             {
@@ -183,7 +184,7 @@ public:
                 setItems.push_back(addEndpointItem);
 
                 lg(Debug) << BOOST_CURRENT_FUNCTION << ": Sending replicator state update for new locator " << locatorId;
-                mReplicationContext->getReplicator()->setState(setItems);
+                mReplicationContext->getReplicator()->setState(AsteriskSCF::createContext(), setItems);
 
             }
             catch(const Ice::Exception& e)
@@ -219,7 +220,7 @@ public:
                     removeItem->key = locatorId;
                     removeItems.push_back(removeItem);
 
-                    mReplicationContext->getReplicator()->removeStateForItems(removeItems);
+                    mReplicationContext->getReplicator()->removeStateForItems(AsteriskSCF::createContext(), removeItems);
 
                     // Now add the item with the new values. 
                     RoutingStateItemSeq setItems;
@@ -230,7 +231,7 @@ public:
 
                     setItems.push_back(addEndpointItem);
 
-                    mReplicationContext->getReplicator()->setState(setItems);
+                    mReplicationContext->getReplicator()->setState(AsteriskSCF::createContext(), setItems);
                 }
             }
             catch(const Ice::Exception& e)
diff --git a/src/RouteSessionOperation.cpp b/src/RouteSessionOperation.cpp
index 445ee9b..2ebb8da 100644
--- a/src/RouteSessionOperation.cpp
+++ b/src/RouteSessionOperation.cpp
@@ -16,6 +16,7 @@
 #include <boost/shared_ptr.hpp>
 #include <boost/bind.hpp>
 
+#include <AsteriskSCF/Helpers/OperationContext.h>
 #include <AsteriskSCF/Logger.h>
 #include <AsteriskSCF/Component/TestContext.h>
 
@@ -23,7 +24,6 @@
 #include "RoutingReplicationContext.h"
 #include "RouteSessionOperation.h"
 
-
 using namespace AsteriskSCF;
 using namespace AsteriskSCF::Core::Routing::V1;
 using namespace AsteriskSCF::SessionCommunications::V1;
@@ -31,6 +31,7 @@ using namespace AsteriskSCF::System::Logging;
 using namespace AsteriskSCF::BasicRoutingService;
 using namespace AsteriskSCF::Replication::BasicRoutingService::V1;
 using namespace AsteriskSCF::StateMachine;
+using namespace AsteriskSCF::System::V1;
 
 namespace
 {
@@ -52,7 +53,7 @@ class RouteSessionReplicatingListener :
 public:
     RouteSessionReplicatingListener(RouteSessionOperationPtr op, 
                                     const RoutingReplicationContextPtr& replicationContext)  
-                                       : mTransactionId(op->getOperationId()),
+                                       : mOperationContext(op->getOperationContext()),
                                          mOperation(op), 
                                          mReplicationContext(replicationContext)
     {
@@ -60,7 +61,7 @@ public:
 
     ~RouteSessionReplicatingListener()
     {
-        lg(Debug) << "RouteSessionReplicatingListener() being destroyed for transaction " << mTransactionId;
+        lg(Debug) << "RouteSessionReplicatingListener() being destroyed for operation context " << mOperationContext;
     }
 
     /**
@@ -80,8 +81,8 @@ public:
                 // This is the initial state. All the state of interest is what's been passed in.
                 // Push this information to the state replicator.
                 RouteSessionOpStartPtr routeSessionOpStart(new RouteSessionOpStart());
-                routeSessionOpStart->operationId =  mOperation->getOperationId();
-                routeSessionOpStart->key = mOperation->getOperationId() + RouteSessionOpStartKeyMod;
+                routeSessionOpStart->operationId =  mOperation->getOperationContext()->id;
+                routeSessionOpStart->key = mOperation->getOperationContext()->id + RouteSessionOpStartKeyMod;
                 routeSessionOpStart->source = mOperation->getSource();
                 routeSessionOpStart->destination = mOperation->getDestination();
 
@@ -93,8 +94,8 @@ public:
             {
             // We've obtained a result from our AMI lookup request.
             RouteSessionOpWaitLookupStatePtr routeSessionOpWaitLookup(new RouteSessionOpWaitLookupState());
-            routeSessionOpWaitLookup->operationId =  mOperation->getOperationId();
-            routeSessionOpWaitLookup->key = mOperation->getOperationId() + RouteSessionOpWaitLookupKeyMod;
+            routeSessionOpWaitLookup->operationId =  mOperation->getOperationContext()->id;
+            routeSessionOpWaitLookup->key = mOperation->getOperationContext()->id + RouteSessionOpWaitLookupKeyMod;
             routeSessionOpWaitLookup->endpoints = mOperation->getLookupResult();
 
             pushState(routeSessionOpWaitLookup);
@@ -111,7 +112,7 @@ public:
         RoutingStateItemSeq setItems;
 
         setItems.push_back(item);
-        mReplicationContext->getReplicator()->setState(setItems);
+        mReplicationContext->getReplicator()->setState(AsteriskSCF::createContext(), setItems);
         
         // Cache the replication state items.
         mReplicatedState.push_back(item);
@@ -136,7 +137,7 @@ public:
             {
                 // We just completed the entire operation. 
                 // Remove the items that represented this operation's state transitions.
-                mReplicationContext->getReplicator()->removeStateForItems(mReplicatedState);
+                mReplicationContext->getReplicator()->removeStateForItems(AsteriskSCF::createContext(), mReplicatedState);
             }
         }
         catch(...)
@@ -165,8 +166,8 @@ public:
             // We just completed the bridge creation.
             // Push this information to the state replicator.
             RouteSessionOpBridgingStatePtr routeSessionOpBridging(new RouteSessionOpBridgingState());
-            routeSessionOpBridging->operationId =  mOperation->getOperationId();
-            routeSessionOpBridging->key = mOperation->getOperationId() + RouteSessionOpBridgingKeyMod;
+            routeSessionOpBridging->operationId =  mOperation->getOperationContext()->id;
+            routeSessionOpBridging->key = mOperation->getOperationContext()->id + RouteSessionOpBridgingKeyMod;
             routeSessionOpBridging->bridge = mOperation->getBridge();
 
             pushState(routeSessionOpBridging);
@@ -184,7 +185,7 @@ public:
 
 private:
     RoutingStateItemSeq mReplicatedState;
-    std::string mTransactionId;
+    OperationContextPtr mOperationContext;
     RouteSessionOperationPtr mOperation;
     RoutingReplicationContextPtr mReplicationContext;
 };
@@ -212,7 +213,7 @@ void RouteSessionOperation::initStateMachine()
  * it can be enqueued to a worker thread. 
  */
 RouteSessionOperation::RouteSessionOperation(const AMD_SessionRouter_routeSessionPtr& cb,
-                                             const std::string& operationId,
+                                             const OperationContextPtr& operationContext,
                                              const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& source, 
                                              const ::std::string& destination, 
                                              const ::AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& oneShotHook,
@@ -227,7 +228,7 @@ RouteSessionOperation::RouteSessionOperation(const AMD_SessionRouter_routeSessio
                                                                  current,
                                                                  listener,
                                                                  RouteSessionOp::STATE_LOOKUP,
-                                                                 operationId),
+                                                                 operationContext),
            mSource(source),
            mDestination(destination),
            mHook(oneShotHook),
@@ -241,7 +242,7 @@ RouteSessionOperation::RouteSessionOperation(const AMD_SessionRouter_routeSessio
  * This is the factory method for RouteSessionOperation.
  */
 RouteSessionOperationPtr RouteSessionOperation::create(const AMD_SessionRouter_routeSessionPtr& cb,
-                              const std::string& operationId,
+                              const OperationContextPtr& operationContext,
                               const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& source, 
                               const ::std::string& destination, 
                               const ::AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& oneShotHook,
@@ -253,7 +254,7 @@ RouteSessionOperationPtr RouteSessionOperation::create(const AMD_SessionRouter_r
 {
 
     RouteSessionOperationPtr op (new RouteSessionOperation(cb,
-                                                           operationId,
+                                                           operationContext,
                                                             source,
                                                             destination,
                                                             oneShotHook,
@@ -317,7 +318,7 @@ void RouteSessionOperation::reflectUpdate(const AsteriskSCF::Replication::BasicR
     mDestination = item->destination;
     mHook = item->hook;
     mCallerID = item->callerID;
-    mOperationId = item->operationId;
+    mOperationContext = new OperationContext(item->operationId);
 
     mReplicatedStates.push_back(RouteSessionOp::STATE_LOOKUP);
 }
@@ -364,7 +365,7 @@ bool RouteSessionOperation::fastForwardReplica()
   
     addListenerManager();
 
-    lg(Debug) << "Fast-forwarded replica of RouteSessionOperation to STATE_BRIDGING for " << mOperationId;
+    lg(Debug) << "Fast-forwarded replica of RouteSessionOperation to STATE_BRIDGING for " << mOperationContext->id;
 
     mStateMachine.resetStartState(RouteSessionOp::STATE_BRIDGING);
 
@@ -376,7 +377,8 @@ bool RouteSessionOperation::fastForwardReplica()
     }
 
     // Apparently nothing left to do but reply to the AMD callback. 
-    lg(Debug) << "Fast-forwarded replica of RouteSessionOperation to STATE_SEND_RESPONSE for " << mOperationId;
+    lg(Debug) << "Fast-forwarded replica of RouteSessionOperation to STATE_SEND_RESPONSE for " << mOperationContext->id;
+
     mStateMachine.resetStartState(RouteSessionOp::STATE_SEND_RESPONSE);
     return true;
 }
@@ -476,7 +478,7 @@ void RouteSessionOperation::establishBridgeState()
     }
 
     // Add a session to the endpoints.
-    SessionSeq newSessions = createSessionForEndpoints(mLookupResult, mDestination, mHook, mListenerManager);
+    SessionSeq newSessions = createSessionForEndpoints(mOperationContext, mLookupResult, mDestination, mHook, mListenerManager);
 
     if (mListenerManager->getListener()->getNumSessions() < 2)
     {
@@ -505,7 +507,7 @@ void RouteSessionOperation::establishBridgeState()
         bridgedSessions.insert(bridgedSessions.end(), newSessions.begin(), newSessions.end());
 
         lg(Debug) <<  BOOST_CURRENT_FUNCTION << ": Creating bridge.";
-        bridge = mSessionContext->bridgeManager->createBridge(mSource, bridgedSessions, 0, mCallerID, mRedirects);
+        bridge = mSessionContext->bridgeManager->createBridge(mOperationContext, mSource, bridgedSessions, 0, mCallerID, mRedirects);
     }
     catch (const Ice::Exception &e)
     {
diff --git a/src/RouteSessionOperation.h b/src/RouteSessionOperation.h
index 6a725cb..3afd3df 100644
--- a/src/RouteSessionOperation.h
+++ b/src/RouteSessionOperation.h
@@ -66,7 +66,7 @@ public:
      * Factory method for the class. This method creates an active routing operation. 
      */
     static RouteSessionOperationPtr create(const AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_routeSessionPtr& cb,
-                                           const std::string& operationId,
+                                           const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
                                            const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& source, 
                                            const ::std::string& destination, 
                                            const ::AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& oneShotHook,
@@ -103,7 +103,7 @@ public:
 protected:
     // Normal constructor
     RouteSessionOperation(const AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_routeSessionPtr& cb,
-                          const std::string& operationId,                          
+                          const AsteriskSCF::System::V1::OperationContextPtr& operationContext,                          
                           const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& source, 
                           const ::std::string& destination, 
                           const ::AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& oneShotHook,
diff --git a/src/RoutingStateReplicatorListener.cpp b/src/RoutingStateReplicatorListener.cpp
index d237d46..c4a27b6 100644
--- a/src/RoutingStateReplicatorListener.cpp
+++ b/src/RoutingStateReplicatorListener.cpp
@@ -19,6 +19,7 @@
 #include <boost/thread.hpp>
 
 #include <AsteriskSCF/Logger.h>
+#include <AsteriskSCF/Helpers/OperationContextCache.h>
 
 #include "RoutingStateReplicatorListener.h"
 #include "OperationReplicaCache.h"
@@ -28,6 +29,8 @@
 using namespace AsteriskSCF::BasicRoutingService;
 using namespace AsteriskSCF::Replication::BasicRoutingService::V1;
 using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::System::V1;
+using namespace AsteriskSCF::Helpers;
 
 namespace
 {
@@ -47,7 +50,8 @@ public:
    RoutingStateReplicatorListenerPriv(const EndpointRegistryPtr& registry, const boost::shared_ptr<OperationReplicaCache>& opCache)
         : mId(IceUtil::generateUUID()),
           mEndpointRegistry(registry),
-          mOperationReplicaCache(opCache)
+          mOperationReplicaCache(opCache),
+          mOperationContextCache(new OperationContextCache(180))
    {
    }
 
@@ -273,6 +277,7 @@ public:
     std::string mId;
     EndpointRegistryPtr mEndpointRegistry;
     boost::shared_ptr<OperationReplicaCache> mOperationReplicaCache;
+    OperationContextCachePtr mOperationContextCache;
 };
 
 RoutingStateReplicatorListenerImpl::RoutingStateReplicatorListenerImpl(const EndpointRegistryPtr& registry, const boost::shared_ptr<OperationReplicaCache>& opCache)
@@ -284,18 +289,48 @@ RoutingStateReplicatorListenerImpl::~RoutingStateReplicatorListenerImpl()
 {
 }
 
-void RoutingStateReplicatorListenerImpl::stateRemoved(const Ice::StringSeq& itemKeys, const Ice::Current& current)
+void RoutingStateReplicatorListenerImpl::stateRemoved(
+    const OperationContextPtr& operationContext,
+    const Ice::StringSeq& itemKeys, 
+    const Ice::Current& current)
 {
+    // Is this a retry for an operation we're already processing?
+    if (!mImpl->mOperationContextCache->addOperationContext(operationContext))
+    {
+        lg(Debug) << "Retry of previously processed stateRemoved() operation detected and rejected for operation " << operationContext->id;
+        return;
+    }
+
     mImpl->stateRemoved(itemKeys, current);
 }
 
-void RoutingStateReplicatorListenerImpl::stateRemovedForItems(const RoutingStateItemSeq& items, const Ice::Current& current)
+void RoutingStateReplicatorListenerImpl::stateRemovedForItems(
+    const OperationContextPtr& operationContext,
+    const RoutingStateItemSeq& items, 
+    const Ice::Current& current)
 {
+    // Is this a retry for an operation we're already processing?
+    if (!mImpl->mOperationContextCache->addOperationContext(operationContext))
+    {
+        lg(Debug) << "Retry of previously processed stateRemovedForItems() operation detected and rejected for operation " << operationContext->id;
+        return;
+    }
+
     mImpl->stateRemovedForItems(items, current);
 }
 
-void RoutingStateReplicatorListenerImpl::stateSet(const RoutingStateItemSeq& items, const Ice::Current& current)
+void RoutingStateReplicatorListenerImpl::stateSet(
+    const OperationContextPtr& operationContext,
+    const RoutingStateItemSeq& items, 
+    const Ice::Current& current)
 {
+    // Is this a retry for an operation we're already processing?
+    if (!mImpl->mOperationContextCache->addOperationContext(operationContext))
+    {
+        lg(Debug) << "Retry of previously processed stateSet() operation detected and rejected for operation " << operationContext->id;
+        return;
+    }
+
     mImpl->stateSet(items, current);
 }
 
diff --git a/src/RoutingStateReplicatorListener.h b/src/RoutingStateReplicatorListener.h
index d483a13..1b16388 100644
--- a/src/RoutingStateReplicatorListener.h
+++ b/src/RoutingStateReplicatorListener.h
@@ -20,6 +20,7 @@
 #include <boost/shared_ptr.hpp>
 
 #include <AsteriskSCF/Replication/StateReplicator.h>
+#include <AsteriskSCF/System/OperationsIf.h>
 
 #include "BasicRoutingStateReplicationIf.h"
 #include "OperationReplicaCache.h"
@@ -41,9 +42,9 @@ class RoutingStateReplicatorListenerImpl : public AsteriskSCF::Replication::Basi
 public:
     RoutingStateReplicatorListenerImpl(const EndpointRegistryPtr& registry, const boost::shared_ptr<OperationReplicaCache>& opCache);
     ~RoutingStateReplicatorListenerImpl();
-    void stateRemoved(const Ice::StringSeq&, const Ice::Current&);
-    void stateRemovedForItems(const AsteriskSCF::Replication::BasicRoutingService::V1::RoutingStateItemSeq&, const Ice::Current&);
-    void stateSet(const AsteriskSCF::Replication::BasicRoutingService::V1::RoutingStateItemSeq&, const Ice::Current&);
+    void stateRemoved(const AsteriskSCF::System::V1::OperationContextPtr& operationContext, const Ice::StringSeq&, const Ice::Current&);
+    void stateRemovedForItems(const AsteriskSCF::System::V1::OperationContextPtr& operationContext, const AsteriskSCF::Replication::BasicRoutingService::V1::RoutingStateItemSeq&, const Ice::Current&);
+    void stateSet(const AsteriskSCF::System::V1::OperationContextPtr& operationContext, const AsteriskSCF::Replication::BasicRoutingService::V1::RoutingStateItemSeq&, const Ice::Current&);
     bool operator==(RoutingStateReplicatorListenerImpl &rhs);
 
 private:
diff --git a/src/SessionListener.cpp b/src/SessionListener.cpp
index 8661543..b5736c8 100644
--- a/src/SessionListener.cpp
+++ b/src/SessionListener.cpp
@@ -25,6 +25,7 @@
 using namespace AsteriskSCF;
 using namespace AsteriskSCF::SessionCommunications::V1;
 using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::System::V1;
 
 namespace
 {
@@ -46,7 +47,8 @@ SessionListenerImpl::~SessionListenerImpl()
 }
 
 
-void SessionListenerImpl::indicated(const SessionPrx& session, 
+void SessionListenerImpl::indicated(const OperationContextPtr& operationContext,
+                                    const SessionPrx& session, 
                                     const IndicationPtr& event,
                                     const SessionCookies&,
                                     const Ice::Current&)
diff --git a/src/SessionListener.h b/src/SessionListener.h
index 0e41940..42b2286 100644
--- a/src/SessionListener.h
+++ b/src/SessionListener.h
@@ -39,8 +39,9 @@ public:
 
 public: // Overrides for SessionListener
 
-    void indicated(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, 
-                   const ::AsteriskSCF::SessionCommunications::V1::IndicationPtr& event,
+    void indicated(const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+                   const AsteriskSCF::SessionCommunications::V1::SessionPrx& session, 
+                   const AsteriskSCF::SessionCommunications::V1::IndicationPtr& event,
                    const AsteriskSCF::SessionCommunications::V1::SessionCookies&,
                    const Ice::Current&);
 
diff --git a/src/SessionRouter.cpp b/src/SessionRouter.cpp
index efe5fb7..de69d74 100644
--- a/src/SessionRouter.cpp
+++ b/src/SessionRouter.cpp
@@ -41,8 +41,11 @@ using namespace AsteriskSCF;
 using namespace AsteriskSCF::Core::Routing::V1;
 using namespace AsteriskSCF::Core::Endpoint::V1;
 using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::System::V1;
 using namespace AsteriskSCF::SessionCommunications::V1;
 using namespace AsteriskSCF::Core::Routing::V1::Event;
+using namespace AsteriskSCF::SessionCommunications::ExtensionPoints::V1;
+using namespace AsteriskSCF::SessionCommunications::PartyIdentification::V1;
 using namespace AsteriskSCF::Core::Routing::V1;
 using namespace AsteriskSCF::Threading;
 using namespace std;
@@ -159,18 +162,18 @@ SessionRouter::~SessionRouter()
 /**
  * Route the session by looking up the destination endpoint and configuring a complimentary session for the destination.
  */
-void SessionRouter::routeSession_async(const ::AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_routeSessionPtr& cb,
-                                       const ::std::string& operationId, 
+void SessionRouter::routeSession_async(const AMD_SessionRouter_routeSessionPtr& cb,
+                                       const OperationContextPtr& operationContext, 
                                        const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& source, 
                                        const ::std::string& destination, 
-                                       const ::AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& oneShotHook,
-                                       const ::AsteriskSCF::SessionCommunications::PartyIdentification::V1::CallerPtr& callerID,
-                                       const ::AsteriskSCF::SessionCommunications::PartyIdentification::V1::RedirectionsPtr& redirects,
+                                       const SessionCreationHookPrx& oneShotHook,
+                                       const CallerPtr& callerID,
+                                       const RedirectionsPtr& redirects,
                                        const ::Ice::Current& current)
 {
     // Check the cache for a replica with this transaction Id.
     RouteSessionOperationPtr routeSessionOp;
-    if (mImpl->mOperationReplicaCache->getRouteSessionCache()->fetchOperation(operationId, routeSessionOp))
+    if (mImpl->mOperationReplicaCache->getRouteSessionCache()->fetchOperation(operationContext->id, routeSessionOp))
     {
         routeSessionOp->rehostReplica(cb, current, mImpl.get());
         WorkPtr replicaOp(routeSessionOp);
@@ -180,7 +183,7 @@ void SessionRouter::routeSession_async(const ::AsteriskSCF::SessionCommunication
     }
 
     WorkPtr op(RouteSessionOperation::create(cb, 
-                                             operationId,
+                                             operationContext,
                                              source, 
                                              destination, 
                                              oneShotHook,
@@ -203,17 +206,17 @@ void SessionRouter::routeSession_async(const ::AsteriskSCF::SessionCommunication
  *
  * This object is an instance of WorkQueue::Work so that it can enqueued to a worker thread. 
  */
-void SessionRouter::connectBridgedSessionsWithDestination_async(const ::AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr& cb, 
-                                                                const ::std::string& operationId, 
-                                                                const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace, 
+void SessionRouter::connectBridgedSessionsWithDestination_async(const AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr& cb, 
+                                                                const OperationContextPtr& operationContext, 
+                                                                const SessionPrx& sessionToReplace, 
                                                                 const ::std::string& destination, 
                                                                 bool replaceSession,
-                                                                const ::AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& oneShotHook,
+                                                                const SessionCreationHookPrx& oneShotHook,
                                                                 const ::Ice::Current& current)
 {
     // Check the cache for a replica with this transaction Id.
     ConnectBridgedSessionsWithDestinationOperationPtr connectBridgedSessionsWithDestOp;
-    if (mImpl->mOperationReplicaCache->getConnectBridgedSessionsWithDestCache()->fetchOperation(operationId, connectBridgedSessionsWithDestOp))
+    if (mImpl->mOperationReplicaCache->getConnectBridgedSessionsWithDestCache()->fetchOperation(operationContext->id, connectBridgedSessionsWithDestOp))
     {
         connectBridgedSessionsWithDestOp->rehostReplica(cb, current, mImpl.get());
         WorkPtr replicaOp(connectBridgedSessionsWithDestOp);
@@ -223,7 +226,7 @@ void SessionRouter::connectBridgedSessionsWithDestination_async(const ::Asterisk
     }
 
     WorkPtr op(ConnectBridgedSessionsWithDestinationOperation::create(cb, 
-                                                                      operationId,
+                                                                      operationContext,
                                                                       sessionToReplace, 
                                                                       destination, 
                                                                       replaceSession,
@@ -239,14 +242,14 @@ void SessionRouter::connectBridgedSessionsWithDestination_async(const ::Asterisk
  * Private operations and state of the SessionRouter. 
  */
 void SessionRouter::connectBridgedSessions_async(const ::AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_connectBridgedSessionsPtr& cb, 
-                                                 const ::std::string& operationId, 
+                                                 const OperationContextPtr& operationContext, 
                                                  const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace, 
                                                  const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& bridgedSession,
                                                  bool replaceSession,
                                                  const ::Ice::Current& current)
 {
     WorkPtr op(ConnectBridgedSessionsOperation::create(cb, 
-                                                       operationId,
+                                                       operationContext,
                                                        sessionToReplace, 
                                                        bridgedSession, 
                                                        replaceSession,
diff --git a/src/SessionRouter.h b/src/SessionRouter.h
index f71aa5e..3edca53 100644
--- a/src/SessionRouter.h
+++ b/src/SessionRouter.h
@@ -47,18 +47,18 @@ public:
     /**
      * Execute the routing functionality for the given session. The given session
      * will be bridged with the destination if it is successfully routed.
-     *   @param operationId Unique id for this operation.
+     *   @param operationContext Unique id for this operation.
      *   @param source The session initiating the routing event.
      *   @param destination The address or id of the destination to be routed.
      */
-    void routeSession(const std::string& operationId,
+    void routeSession(const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
                       const AsteriskSCF::SessionCommunications::V1::SessionPrx& source,
                       const std::string& destination,
                       const Ice::Current&);
 
     virtual void routeSession_async
                    (const ::AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_routeSessionPtr& cb,
-                    const std::string& operationId,
+                    const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
                     const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& source, 
                     const ::std::string& destination, 
                     const ::AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& oneShotHook,
@@ -68,19 +68,19 @@ public:
 
     /**
      * Replace a session in a bridge with a destination. The desintation will be routed.
-     *   @param operationId  Unique id for this operation.
+     *   @param operationContext  Unique id for this operation.
      *   @param sessionToReplace The session to be replaced in a bridge. The affected Bridge interface is
      *    obtained via an accessor on this interface.
      *   @param destination The address or id of a destination to be used as a replacement for the specified session.
      */
-    void connectBridgedSessionsWithDestination(const std::string& operationId, 
+    void connectBridgedSessionsWithDestination(const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
                                                const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace,
                                                const ::std::string& destination,
                                                const Ice::Current&);
 
     virtual void connectBridgedSessionsWithDestination_async
                    (const ::AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr& cb, 
-                    const std::string& operationId, 
+                    const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
                     const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace, 
                     const ::std::string& destination, 
                     bool replaceSession,
@@ -90,19 +90,19 @@ public:
     /**
      * Replace a session in a bridge with another session. If the newSession is already participating in a Bridge,
      * it will be removed from it's current bridge prior to be used as a replacement.
-     *   @param operationId  Unique id for this operation.
+     *   @param operationContext Unique id for this operation.
      *   @param sessionToReplace The session to be replaced in a bridge. The affected Bridge interface is
      *    obtained via an accessor on this interface.
      *   @param newSession The session to be used as a replacement for the specified session.
      */
-    void connectBridgedSessions(const std::string& operationId, 
+    void connectBridgedSessions(const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
                                 const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace,
                                 const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& bridgedSession,
                                 const Ice::Current&);
 
     virtual void connectBridgedSessions_async
                    (const ::AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_connectBridgedSessionsPtr& cb, 
-                    const std::string& operationId, 
+                    const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
                     const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace, 
                     const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& bridgedSession,  
                     bool replaceSession,
diff --git a/src/SessionRouterOperation.cpp b/src/SessionRouterOperation.cpp
index f642dc5..bb13127 100644
--- a/src/SessionRouterOperation.cpp
+++ b/src/SessionRouterOperation.cpp
@@ -17,6 +17,7 @@
 #include <boost/shared_ptr.hpp>
 
 #include <AsteriskSCF/Logger.h>
+#include <AsteriskSCF/Helpers/Retry.h>
 
 #include "SessionRouterOperation.h"
 
@@ -24,6 +25,7 @@ using namespace AsteriskSCF;
 using namespace AsteriskSCF::SessionCommunications::V1;
 using namespace AsteriskSCF::Core::Endpoint::V1;
 using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::System::V1;
 
 namespace
 {
@@ -35,69 +37,6 @@ namespace AsteriskSCF
 namespace BasicRoutingService
 {
 
-/**
- * A simple utility to make the retry process a little cleaner until a SmartProxy
- * or other such mechanism has this functionality built-in. 
- */
-class RetryPolicy
-{
-public:
-    /**
-     * Constructor:
-     *  @param maxRetries Maximum number of times to retry. 
-     *  @intervalInMilliseconds Will sleep this amount in the retry() method. 
-     */
-    RetryPolicy(size_t maxRetriesIn, size_t intervalInMillisecondsIn) :
-        mMaxRetries(maxRetriesIn),
-        mRetryIntervalMilliseconds(intervalInMillisecondsIn),
-        mCounter(0)
-    {
-        assert(maxRetriesIn < 0xffff);
-    }
-
-    /**
-     * Indicates whether additional retries are warrented. 
-     */
-    bool canRetry()
-    {
-        return mCounter <= mMaxRetries;
-    }
-
-    /**
-     * User must call this after each failed attempt. Applies the delay between calls and does
-     * bookkeeping.
-     */
-    bool retry()
-    {
-        ++mCounter;
-        lg(Debug) << "Retrying for the " << mCounter << " time.";
-
-        bool doRetry = canRetry();
-
-        if (doRetry)
-        {
-            IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(mRetryIntervalMilliseconds));
-        }
-
-        return doRetry;
-    }
-
-    /**
-     * Accessor for the number of retries allowed. 
-     */
-    size_t maxRetries()
-    {
-        return mMaxRetries;
-    }
-
-private:
-    size_t mMaxRetries;
-    size_t mRetryIntervalMilliseconds;
-    size_t mCounter;
-
-}; // class RetryPolicy
-
-
 //////////////////////////////////////////////////
 // Non-member utility functions.
 
@@ -132,7 +71,7 @@ BridgePrx getBridge(SessionPrx session)
         {
             if(!policy.retry())
             {
-                lg(Error) << "getBridge(): ConnectionLostException getting bridge for session, failed "  << policy.maxRetries() << " retries." ;
+                lg(Error) << "getBridge(): ConnectionLostException getting bridge for session, failed "  << policy.getMaxRetries() << " retries." ;
                 throw cle; 
             }
         }
@@ -155,10 +94,12 @@ BridgePrx getBridge(SessionPrx session)
  * Create a session to each of a given set of endpoints, and return a collection of the 
  * newly added sessions. 
  */
-SessionSeq createSessionForEndpoints(const EndpointSeq& endpoints, 
-                                     const std::string& destination, 
-                                     const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& oneShotHook,
-                                     const SessionListenerManagerPtr& listenerManager)
+SessionSeq createSessionForEndpoints(
+    const OperationContextPtr& operationContext,
+    const EndpointSeq& endpoints, 
+    const std::string& destination, 
+    const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& oneShotHook,
+    const SessionListenerManagerPtr& listenerManager)
 {
     // Add a session
     SessionSeq newSessions;
@@ -170,7 +111,7 @@ SessionSeq createSessionForEndpoints(const EndpointSeq& endpoints,
 
             // Create a session on the destination.
             lg(Debug) << "createSessionForEndpoints(): Creating a session at destination " << destination;
-            SessionPrx destSession = sessionEndpoint->createSession(destination, listenerManager->getListener()->getProxy(), oneShotHook);
+            SessionPrx destSession = sessionEndpoint->createSession(operationContext, destination, listenerManager->getListener()->getProxy(), oneShotHook);
             if(!destSession)
             {
                 lg(Debug) << " Session endpoint returned a null proxy, continuing with other endpoints";
@@ -243,7 +184,7 @@ SessionSeq getSessionsInBridge(const BridgePrx& bridge, const SessionPrx& except
  *   @param bridge The bridge whose sessions are to be removed.
  *   @param except The only session to be left in the bridge. 
  */
-SessionSeq removeSessionsFromBridge(BridgePrx bridge, SessionPrx except)
+SessionSeq removeSessionsFromBridge(const OperationContextPtr& operationContext, BridgePrx bridge, SessionPrx except)
 {
     SessionSeq removedSessions;
     try
@@ -258,7 +199,7 @@ SessionSeq removeSessionsFromBridge(BridgePrx bridge, SessionPrx except)
         }
 
         lg(Debug) << "Removing sessions from bridge." ;
-        bridge->removeSessions(removedSessions);
+        bridge->removeSessions(operationContext, removedSessions);
     }
     catch(const Ice::Exception& ex)
     {
diff --git a/src/SessionRouterOperation.h b/src/SessionRouterOperation.h
index a93c058..dcc732f 100644
--- a/src/SessionRouterOperation.h
+++ b/src/SessionRouterOperation.h
@@ -27,6 +27,8 @@
 #include <AsteriskSCF/Discovery/SmartProxy.h>
 #include <AsteriskSCF/Core/Routing/RoutingIf.h>
 #include <AsteriskSCF/Logger.h>
+#include <AsteriskSCF/System/OperationsIf.h>
+
 #include "RoutingReplicationContext.h"
 
 #include "SessionListener.h"
@@ -114,21 +116,21 @@ public:
      *  @param context The SessionContext provides references to key objects needed by each operation. 
      *  @param manager 
      *  @param defaultState The initial state of the operation's state machine.
-     *  @param operationId Unique ID for this operation as assigned by the caller. 
+     *  @param operationContext Unique ID for this operation as assigned by the caller. 
      */
     SessionRouterOperation(const T& amdCallback,
                            const SessionContextPtr& context,
                            const ::Ice::Current& current,
                            OperationsManager* manager, 
                            S defaultState,
-                           std::string operationId) 
+                           const AsteriskSCF::System::V1::OperationContextPtr& operationContext) 
         : mInitiatorCallback(amdCallback),
           mSessionContext(context),
           mIceCurrent(current),
           mFinished(false),
           mOperationsManager(manager),
           mStateMachine(defaultState),
-          mOperationId(operationId)
+          mOperationContext(operationContext)
     {
     }
 
@@ -267,14 +269,14 @@ public:
         return mLookupResult;
     }
 
-    void setOperationId(const std::string& operationId)
+    void setOperationContext(const AsteriskSCF::System::V1::OperationContextPtr& operationContext)
     {
-        mOperationId = operationId;
+        mOperationContext = operationContext;
     }
 
-    std::string getOperationId()
+    AsteriskSCF::System::V1::OperationContextPtr getOperationContext()
     {
-        return mOperationId;
+        return mOperationContext;
     }
 
     void addStateMachineListener(const boost::shared_ptr< typename AsteriskSCF::StateMachine::SimpleStateMachine<S>::StateMachineListener >& listener)
@@ -306,7 +308,7 @@ protected:
     SessionListenerManagerPtr mListenerManager;
     OperationsManager* mOperationsManager;
     AsteriskSCF::StateMachine::SimpleStateMachine<S> mStateMachine;
-    std::string mOperationId;
+    AsteriskSCF::System::V1::OperationContextPtr mOperationContext;
 
     AsteriskSCF::Core::Endpoint::V1::EndpointSeq mLookupResult;
 
@@ -370,10 +372,12 @@ AsteriskSCF::SessionCommunications::V1::BridgePrx getBridge(AsteriskSCF::Session
  * Create a session to each of a given set of endpoints, and return a collection of the 
  * newly added sessions. 
  */
-AsteriskSCF::SessionCommunications::V1::SessionSeq createSessionForEndpoints(const AsteriskSCF::Core::Endpoint::V1::EndpointSeq& endpoints, 
-                                                                             const std::string& destination,
-                                                                             const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& oneShotHook,
-                                                                             const SessionListenerManagerPtr& listenerManager);
+AsteriskSCF::SessionCommunications::V1::SessionSeq createSessionForEndpoints(    
+    const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+    const AsteriskSCF::Core::Endpoint::V1::EndpointSeq& endpoints, 
+    const std::string& destination,
+    const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& oneShotHook,
+    const SessionListenerManagerPtr& listenerManager);
 
 /**
  * Accessor for the sessions in a bridge.
@@ -394,8 +398,10 @@ AsteriskSCF::SessionCommunications::V1::SessionSeq getSessionsInBridge(const Ast
  *   @param bridge The bridge whose sessions are to be removed.
  *   @param except The only session to be left in the bridge. 
  */
-AsteriskSCF::SessionCommunications::V1::SessionSeq removeSessionsFromBridge(AsteriskSCF::SessionCommunications::V1::BridgePrx bridge, 
-                                                                            AsteriskSCF::SessionCommunications::V1::SessionPrx except);
+AsteriskSCF::SessionCommunications::V1::SessionSeq removeSessionsFromBridge(
+    const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+    AsteriskSCF::SessionCommunications::V1::BridgePrx bridge, 
+    AsteriskSCF::SessionCommunications::V1::SessionPrx except);
 
 } // end BasicRoutingService
 } // end AsteriskSCF
diff --git a/test/MockBridge.cpp b/test/MockBridge.cpp
index 3ce705c..48eb970 100644
--- a/test/MockBridge.cpp
+++ b/test/MockBridge.cpp
@@ -15,9 +15,11 @@
  */
 #include <Ice/Ice.h>
 
+#include <AsteriskSCF/System/OperationsIf.h>
 #include "MockBridge.h"
 #include "SharedTestData.h"
 
+using namespace AsteriskSCF::System::V1;
 using namespace AsteriskSCF::SessionCommunications::V1;
 using namespace AsteriskSCF::SessionCommunications::PartyIdentification::V1;
 
@@ -34,7 +36,7 @@ public:
     }
 
     // Overrides
-    virtual void indicated(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
+    virtual void indicated(const AsteriskSCF::System::V1::OperationContextPtr& operationId, const AsteriskSCF::SessionCommunications::V1::SessionPrx& session,
 	const AsteriskSCF::SessionCommunications::V1::IndicationPtr& indication, 
 	const AsteriskSCF::SessionCommunications::V1::SessionCookies&, const Ice::Current&)
     {
diff --git a/test/MockSession.cpp b/test/MockSession.cpp
index ba7dd32..decc761 100644
--- a/test/MockSession.cpp
+++ b/test/MockSession.cpp
@@ -14,6 +14,8 @@
  * at the top of the source tree.
  */
 #include <Ice/Ice.h>
+#include <IceUtil/UUID.h>
+
 #include <boost/test/unit_test.hpp>
 
 #include "MockSession.h"
@@ -21,6 +23,7 @@
 
 using namespace AsteriskSCF::SessionCommunications::V1;
 using namespace AsteriskSCF::SessionCommunications::PartyIdentification::V1;
+using namespace AsteriskSCF::System::V1;
 using namespace std;
 
 namespace AsteriskSCF
@@ -44,7 +47,7 @@ public:
     {
 	AsteriskSCF::SessionCommunications::V1::StoppedIndicationPtr stopped(new  AsteriskSCF::SessionCommunications::V1::StoppedIndication());
 	stopped->response = mResponse;
-	l->indicated(mMyProxy, stopped, AsteriskSCF::SessionCommunications::V1::SessionCookies());
+	l->indicated(new OperationContext(::IceUtil::generateUUID()), mMyProxy, stopped, AsteriskSCF::SessionCommunications::V1::SessionCookies());
     }
 
 private:
@@ -133,7 +136,7 @@ void MockSession::indicate_async(
     {
 	for(vector<SessionListenerPrx>::iterator i = mListeners.begin(); i != mListeners.end(); ++i)
 	{
-	    (*i)->indicated(mMyPrx, new AsteriskSCF::SessionCommunications::V1::ConnectedIndication(), AsteriskSCF::SessionCommunications::V1::SessionCookies());
+	    (*i)->indicated(new OperationContext(::IceUtil::generateUUID()), mMyPrx, new AsteriskSCF::SessionCommunications::V1::ConnectedIndication(), AsteriskSCF::SessionCommunications::V1::SessionCookies());
 	}
     }
     cb->ice_response();
@@ -180,7 +183,7 @@ void MockSession::start(const Ice::Current&)
     for(vector<SessionListenerPrx>::iterator i = mListeners.begin(); i != mListeners.end(); ++i)
     {
         // Auto-answer!
-	(*i)->indicated(mMyPrx, new AsteriskSCF::SessionCommunications::V1::ConnectedIndication(), AsteriskSCF::SessionCommunications::V1::SessionCookies());
+	(*i)->indicated(new OperationContext(::IceUtil::generateUUID()), mMyPrx, new AsteriskSCF::SessionCommunications::V1::ConnectedIndication(), AsteriskSCF::SessionCommunications::V1::SessionCookies());
     }
 }
 
diff --git a/test/TestRouting.cpp b/test/TestRouting.cpp
index a9f4a0f..95f44b9 100644
--- a/test/TestRouting.cpp
+++ b/test/TestRouting.cpp
@@ -43,6 +43,7 @@ using namespace AsteriskSCF::SessionCommunications::PartyIdentification::V1;
 using namespace AsteriskSCF::Core::Discovery::V1;
 using namespace AsteriskSCF::RoutingTest;
 using namespace AsteriskSCF::System::Component::V1;
+using namespace AsteriskSCF::System::V1;
 
 /**
  * Instantiate our shared data.
@@ -397,7 +398,7 @@ BOOST_FIXTURE_TEST_CASE(RouteSession, PerTestFixture)
         SharedTestData::instance.mBridgeConnected = false;
 
         BOOST_TEST_MESSAGE("Routing the session...");
-        SharedTestData::instance.sessionRouter->routeSession(IceUtil::generateUUID(), session, "102", 0, session->getCaller(), session->getRedirections());
+        SharedTestData::instance.sessionRouter->routeSession(new OperationContext(IceUtil::generateUUID()), session, "102", 0, session->getCaller(), session->getRedirections());
 
         BOOST_CHECK(SharedTestData::instance.mBridgeConnected);
 
@@ -452,14 +453,14 @@ BOOST_FIXTURE_TEST_CASE(BlindTransfer, PerTestFixture)
         SharedTestData::instance.mSessionReplaced = false;
 
         BOOST_TEST_MESSAGE("Routing the session...");
-        SharedTestData::instance.sessionRouter->routeSession(IceUtil::generateUUID(), session, "102", 0, session->getCaller(), session->getRedirections());
+        SharedTestData::instance.sessionRouter->routeSession(new OperationContext(IceUtil::generateUUID()), session, "102", 0, session->getCaller(), session->getRedirections());
 
         BridgePrx bridge = session->getBridge();
         BOOST_CHECK(bridge != 0);
         BOOST_CHECK(SharedTestData::instance.mBridgeConnected);
 
         // Now transfer to a new extension.
-        SharedTestData::instance.sessionRouter->connectBridgedSessionsWithDestination(IceUtil::generateUUID(), session, "103", true, 0);
+        SharedTestData::instance.sessionRouter->connectBridgedSessionsWithDestination(new OperationContext(IceUtil::generateUUID()), session, "103", true, 0);
 
         BOOST_CHECK(SharedTestData::instance.mSessionReplaced);
 
@@ -509,7 +510,7 @@ BOOST_FIXTURE_TEST_CASE(AttendedTransfer, PerTestFixture)
         SharedTestData::instance.mBridgeConnected = false;
 
         BOOST_TEST_MESSAGE("Routing for the first pair...");
-        SharedTestData::instance.sessionRouter->routeSession("Test_AttendedTransfer_102_" + IceUtil::generateUUID(), session101, "102", 0, session101->getCaller(), session101->getRedirections());
+        SharedTestData::instance.sessionRouter->routeSession(new OperationContext(IceUtil::generateUUID()), session101, "102", 0, session101->getCaller(), session101->getRedirections());
 
         BOOST_CHECK(SharedTestData::instance.mBridgeConnected);
 
@@ -525,13 +526,13 @@ BOOST_FIXTURE_TEST_CASE(AttendedTransfer, PerTestFixture)
 
         BOOST_TEST_MESSAGE("Routing the second pair...");
 
-        SharedTestData::instance.sessionRouter->routeSession("Test_AttendedTransfer_104_" + IceUtil::generateUUID(), session103, "104", 0, session103->getCaller(), session103->getRedirections());
+        SharedTestData::instance.sessionRouter->routeSession(new OperationContext(IceUtil::generateUUID()), session103, "104", 0, session103->getCaller(), session103->getRedirections());
 
         BOOST_CHECK(SharedTestData::instance.mBridgeConnected);
 
         // Now bridge 102 and 104 into the first pair's bridge
         BridgePrx survivingBridge = session101->getBridge(); // Cache for testing.
-        SharedTestData::instance.sessionRouter->connectBridgedSessions("Test_BlindTransfer_" + IceUtil::generateUUID(), session101, session103, true);
+        SharedTestData::instance.sessionRouter->connectBridgedSessions(new OperationContext(IceUtil::generateUUID()), session101, session103, true);
 
         BOOST_CHECK(SharedTestData::instance.mSessionReplaced);
 
@@ -717,7 +718,7 @@ BOOST_FIXTURE_TEST_CASE(FailoverRouteSession, PerTestFixture)
 
         // Note we're routing using AMI with no callback. The callback would never come due to the
         // way the test mode shuts down the operation. Simulates failure.
-        SharedTestData::instance.sessionRouter->begin_routeSession(operationId, session, "102", 0, session->getCaller(), session->getRedirections());
+        SharedTestData::instance.sessionRouter->begin_routeSession(new OperationContext(operationId), session, "102", 0, session->getCaller(), session->getRedirections());
 
         for (int counter=0; SharedTestData::instance.endpointLocator->mLookupCalled == false; counter++)
         {
@@ -746,7 +747,7 @@ BOOST_FIXTURE_TEST_CASE(FailoverRouteSession, PerTestFixture)
         BOOST_CHECK(SharedTestData::instance.serviceReplicaMgmt->isActive() == true);
 
         // Let the backup session router try to route using same operationId.
-        SharedTestData::instance.backupSessionRouter->routeSession(operationId, session, "102", 0, session->getCaller(), session->getRedirections());
+        SharedTestData::instance.backupSessionRouter->routeSession(new OperationContext(operationId), session, "102", 0, session->getCaller(), session->getRedirections());
 
         // The lookup should not be done again. 
         BOOST_CHECK(!SharedTestData::instance.endpointLocator->mLookupCalled);
@@ -802,7 +803,7 @@ BOOST_FIXTURE_TEST_CASE(FailoverConnectBridgedSessWithDest, PerTestFixture)
         SharedTestData::instance.mSessionReplaced = false;
 
         BOOST_TEST_MESSAGE("Routing the session...");
-        SharedTestData::instance.sessionRouter->routeSession(IceUtil::generateUUID(), session, "102", 0, session->getCaller(), session->getRedirections());
+        SharedTestData::instance.sessionRouter->routeSession(new OperationContext(IceUtil::generateUUID()), session, "102", 0, session->getCaller(), session->getRedirections());
 
         BridgePrx bridge = session->getBridge();
         BOOST_CHECK(bridge != 0);
@@ -811,7 +812,7 @@ BOOST_FIXTURE_TEST_CASE(FailoverConnectBridgedSessWithDest, PerTestFixture)
         string operationId = IceUtil::generateUUID();
 
         // Now transfer to a new extension. In our test mode, this operation will never complete.
-        SharedTestData::instance.sessionRouter->begin_connectBridgedSessionsWithDestination(operationId, session, "103", true, 0);
+        SharedTestData::instance.sessionRouter->begin_connectBridgedSessionsWithDestination(new OperationContext(operationId), session, "103", true, 0);
 
         for (int counter=0; SharedTestData::instance.mSessionReplaced == false; counter++)
         {
@@ -842,7 +843,7 @@ BOOST_FIXTURE_TEST_CASE(FailoverConnectBridgedSessWithDest, PerTestFixture)
         BOOST_CHECK(SharedTestData::instance.serviceReplicaMgmt->isActive() == true);
 
         // Let the backup session router try to route using same operationId. Synchronous call.
-        SharedTestData::instance.backupSessionRouter->connectBridgedSessionsWithDestination(operationId, session, "103", true, 0);
+        SharedTestData::instance.backupSessionRouter->connectBridgedSessionsWithDestination(new OperationContext(operationId), session, "103", true, 0);
 
         // The lookup should not be done again. 
         BOOST_CHECK(SharedTestData::instance.endpointLocator->mLookupCalled == false);

commit 5642fdc45554ff4b46af29f1a06515e26608b0f5
Author: Brent Eagles <beagles at digium.com>
Date:   Mon Jan 9 16:44:28 2012 -0330

    Fix ambiguity issue for enum.

diff --git a/test/MockSession.cpp b/test/MockSession.cpp
index cc48d47..ba7dd32 100644
--- a/test/MockSession.cpp
+++ b/test/MockSession.cpp
@@ -92,7 +92,7 @@ MockSession::MockSession(const string& legId,
     mConnectedLine = new ConnectedLine(idSeq2);
 
     RedirectionSeq redirects;
-    RedirectionReasonPtr reason(new RedirectionReason(Unknown));
+    RedirectionReasonPtr reason(new RedirectionReason(AsteriskSCF::SessionCommunications::PartyIdentification::V1::Unknown));
     RedirectionPtr redirect = new Redirection(dialedId, connectedId, reason);
     redirects.push_back(redirect);
     mRedirections = new Redirections(redirects);

commit 9dad302c2ab825bff449ac347b878c2c0a92c1d1
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Jan 3 14:37:38 2012 -0600

    Adjust component library names and update test config files

diff --git a/config/routingtest.conf b/config/routingtest.conf
index 85ffd38..6edda35 100644
--- a/config/routingtest.conf
+++ b/config/routingtest.conf
@@ -10,7 +10,7 @@ Ice.ThreadPool.Client.Size=10
 IceBox.InstanceName=IceBox
 IceBox.ServiceManager.Endpoints=tcp -h 127.0.0.1 -p 10007
 
-IceBox.Service.ServiceDiscovery=service_locator:create
+IceBox.Service.ServiceDiscovery=ServiceLocator:create
 IceBox.Service.RoutingService=BasicRoutingService:create
 IceBox.Service.RoutingService2=BasicRoutingService:create
 IceBox.Service.Replicator=BasicRoutingStateReplicator:create

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


-- 
asterisk-scf/integration/routing.git



More information about the asterisk-scf-commits mailing list