[asterisk-scf-commits] asterisk-scf/integration/routing.git branch "retry_deux" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Apr 3 18:24:34 CDT 2012
branch "retry_deux" has been updated
via 9b583ef4d6129967afab4f27c312850d69a3fe43 (commit)
from cbd70a3609f162267313600dc9219f9cf66c8cf7 (commit)
Summary of changes:
src/ConnectBridgedSessionsOperation.cpp | 5 +-
src/ConnectBridgedSessionsOperation.h | 4 +-
...nectBridgedSessionsWithDestinationOperation.cpp | 5 +-
...onnectBridgedSessionsWithDestinationOperation.h | 4 +-
src/EndpointRegistry.cpp | 54 +++++++++++----
src/RouteSessionOperation.cpp | 5 +-
src/RouteSessionOperation.h | 5 +-
src/SessionRouter.cpp | 72 +++++++------------
src/SessionRouterOperation.h | 69 ++-----------------
9 files changed, 89 insertions(+), 134 deletions(-)
- Log -----------------------------------------------------------------
commit 9b583ef4d6129967afab4f27c312850d69a3fe43
Author: Ken Hunt <ken.hunt at digium.com>
Date: Tue Apr 3 18:23:57 2012 -0500
Migrated to the cookie types defined in OperationMonitor.h
diff --git a/src/ConnectBridgedSessionsOperation.cpp b/src/ConnectBridgedSessionsOperation.cpp
index 48a2524..878278e 100644
--- a/src/ConnectBridgedSessionsOperation.cpp
+++ b/src/ConnectBridgedSessionsOperation.cpp
@@ -26,6 +26,7 @@ using namespace AsteriskSCF::Core::Routing::V1;
using namespace AsteriskSCF::SessionCommunications::V1;
using namespace AsteriskSCF::System::Logging;
using namespace AsteriskSCF::System::V1;
+using namespace AsteriskSCF::Operations;
namespace
{
@@ -64,7 +65,7 @@ namespace BasicRoutingService
*/
ConnectBridgedSessionsOperation::ConnectBridgedSessionsOperation
- (const SessionRouterOperationCookie<AMD_SessionRouter_connectBridgedSessionsPtr>::Ptr& cookie,
+ (const AMDContextData<AMD_SessionRouter_connectBridgedSessionsPtr>::Ptr& cookie,
const OperationContextPtr& operationContext,
const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace,
const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& bridgedSession,
@@ -93,7 +94,7 @@ ConnectBridgedSessionsOperation::ConnectBridgedSessionsOperation
* Factory method for the operation.
*/
ConnectBridgedSessionsOperationPtr ConnectBridgedSessionsOperation::create
- (const SessionRouterOperationCookie<AMD_SessionRouter_connectBridgedSessionsPtr>::Ptr& cookie,
+ (const AMDContextData<AMD_SessionRouter_connectBridgedSessionsPtr>::Ptr& cookie,
const OperationContextPtr& operationContext,
const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace,
const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& bridgedSession,
diff --git a/src/ConnectBridgedSessionsOperation.h b/src/ConnectBridgedSessionsOperation.h
index b0779e7..283fd46 100644
--- a/src/ConnectBridgedSessionsOperation.h
+++ b/src/ConnectBridgedSessionsOperation.h
@@ -60,7 +60,7 @@ class ConnectBridgedSessionsOperation : public SessionRouterOperation<AsteriskS
{
public:
static ConnectBridgedSessionsOperationPtr create(
- const SessionRouterOperationCookie<AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_connectBridgedSessionsPtr>::Ptr& cookie,
+ const AsteriskSCF::Operations::AMDContextData<AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_connectBridgedSessionsPtr>::Ptr& cookie,
const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
const AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace,
const AsteriskSCF::SessionCommunications::V1::SessionPrx& bridgedSession,
@@ -73,7 +73,7 @@ public:
protected:
ConnectBridgedSessionsOperation(
- const SessionRouterOperationCookie<AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_connectBridgedSessionsPtr>::Ptr& cookie,
+ const AsteriskSCF::Operations::AMDContextData<AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_connectBridgedSessionsPtr>::Ptr& cookie,
const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
const AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace,
const AsteriskSCF::SessionCommunications::V1::SessionPrx& bridgedSession,
diff --git a/src/ConnectBridgedSessionsWithDestinationOperation.cpp b/src/ConnectBridgedSessionsWithDestinationOperation.cpp
index 9a3abf2..0361170 100644
--- a/src/ConnectBridgedSessionsWithDestinationOperation.cpp
+++ b/src/ConnectBridgedSessionsWithDestinationOperation.cpp
@@ -31,6 +31,7 @@ using namespace AsteriskSCF::BasicRoutingService;
using namespace AsteriskSCF::Replication::BasicRoutingService::V1;
using namespace AsteriskSCF::StateMachine;
using namespace AsteriskSCF::System::V1;
+using namespace AsteriskSCF::Operations;
namespace
{
@@ -214,7 +215,7 @@ void ConnectBridgedSessionsWithDestinationOperation::initStateMachine()
* This object is an instance of WorkQueue::Work so that it can enqueued to a worker thread.
*/
ConnectBridgedSessionsWithDestinationOperation::ConnectBridgedSessionsWithDestinationOperation(
- const SessionRouterOperationCookie<AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr>::Ptr& cookie,
+ const AMDContextData<AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr>::Ptr& cookie,
const OperationContextPtr& operationContext,
const SessionPrx& sessionToReplace,
const ::std::string& destination,
@@ -244,7 +245,7 @@ ConnectBridgedSessionsWithDestinationOperation::ConnectBridgedSessionsWithDestin
* This is the factory method for this operation.
*/
ConnectBridgedSessionsWithDestinationOperationPtr ConnectBridgedSessionsWithDestinationOperation::create(
- const SessionRouterOperationCookie<AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr>::Ptr& cookie,
+ const AMDContextData<AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr>::Ptr& cookie,
const OperationContextPtr& operationContext,
const SessionPrx& sessionToReplace,
const ::std::string& destination,
diff --git a/src/ConnectBridgedSessionsWithDestinationOperation.h b/src/ConnectBridgedSessionsWithDestinationOperation.h
index a7a23f8..9158dd6 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 SessionRouterOperationCookie<AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr>::Ptr& cookie,
+ const AsteriskSCF::Operations::AMDContextData<AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr>::Ptr& cookie,
const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
const AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace,
const std::string& destination,
@@ -117,7 +117,7 @@ public:
protected:
ConnectBridgedSessionsWithDestinationOperation(
- const SessionRouterOperationCookie<AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr>::Ptr& cookie,
+ const AsteriskSCF::Operations::AMDContextData<AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr>::Ptr& cookie,
const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
const AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionToReplace,
const std::string& destination,
diff --git a/src/EndpointRegistry.cpp b/src/EndpointRegistry.cpp
index 22f7f66..b31cc94 100644
--- a/src/EndpointRegistry.cpp
+++ b/src/EndpointRegistry.cpp
@@ -21,6 +21,7 @@
#include <AsteriskSCF/Discovery/SmartProxy.h>
#include <AsteriskSCF/Operations/OperationContext.h>
#include <AsteriskSCF/Operations/OperationContextCache.h>
+#include <AsteriskSCF/Operations/OperationMonitor.h>
#include "RoutingServiceEventPublisher.h"
#include "EndpointRegistry.h"
@@ -459,11 +460,12 @@ void EndpointRegistry::addEndpointLocator(
const EndpointLocatorPrx& locator,
const Ice::Current&)
{
+ ContextDataPtr contextData;
try
{
- if (!mImpl->mOperationContextCache->addOperationContext(operationContext))
+ if (!(contextData = Operations::checkAndThrow(mImpl->mOperationContextCache, operationContext)))
{
- lg(Debug) << "EndpointRegistry::addEndpointLocator() detected and ignoring duplicate call for operation " << operationContext->id;
+ lg(Debug) << "EndpointRegistry::addEndpointLocator() detected retry for operation " << operationContext->id;
return;
}
@@ -482,12 +484,14 @@ void EndpointRegistry::addEndpointLocator(
mImpl->insertLocatorMapItem(locatorId, newLocator);
mImpl->forwardAddEndpointLocator(operationContext, locatorId, regexList, locator, Event::SUCCESS);
+ contextData->setCompleted();
}
- catch (...)
+ catch (const std::exception& e)
{
- lg(Error) << "Exception adding EndpointLocator.";
+ lg(Error) << "Exception adding EndpointLocator:" << e.what();
mImpl->forwardAddEndpointLocator(operationContext, locatorId, regexList, locator, Event::FAILURE);
- return;
+ contextData->setException(ExceptionWrapper::create(e));
+ throw;
}
}
@@ -497,11 +501,12 @@ void EndpointRegistry::addEndpointLocator(
*/
void EndpointRegistry::removeEndpointLocator(const OperationContextPtr& operationContext, const std::string& locatorId, const Ice::Current&)
{
+ ContextDataPtr contextData;
try
{
- if (!mImpl->mOperationContextCache->addOperationContext(operationContext))
+ if (!(contextData = Operations::checkAndThrow(mImpl->mOperationContextCache, operationContext)))
{
- lg(Debug) << "EndpointRegistry::removeEndpointLocator() detected and ignoring duplicate call for operation " << operationContext->id;
+ lg(Debug) << "EndpointRegistry::removeEndpointLocator() detected retry for operation " << operationContext->id;
return;
}
@@ -514,6 +519,7 @@ void EndpointRegistry::removeEndpointLocator(const OperationContextPtr& operatio
{
lg(Warning) << "Received request to remove Endpoint Locator not currently registered. Id = " << locatorId;
mImpl->forwardRemoveEndpointLocator(operationContext, locatorId, Event::FAILURE);
+ contextData->setCompleted();
return;
}
@@ -522,11 +528,13 @@ void EndpointRegistry::removeEndpointLocator(const OperationContextPtr& operatio
mImpl->forwardRemoveEndpointLocator(operationContext, locatorId, Event::SUCCESS);
lg(Info) << "Removed Endpoint Locator with Id = " << locatorId;
+ contextData->setCompleted();
}
catch(const std::exception &e)
{
mImpl->forwardRemoveEndpointLocator(operationContext, locatorId, Event::FAILURE);
- lg(Error) << e.what();
+ lg(Error) << "Exception removing EndpointLocator:" << e.what();
+ contextData->setException(ExceptionWrapper::create(e));
}
}
@@ -542,11 +550,12 @@ void EndpointRegistry::setEndpointLocatorDestinationIds(
const AsteriskSCF::Core::Routing::V1::RegExSeq& regExList,
const Ice::Current&)
{
+ ContextDataPtr contextData;
try
{
- if (!mImpl->mOperationContextCache->addOperationContext(operationContext))
+ if (!(contextData = Operations::checkAndThrow(mImpl->mOperationContextCache, operationContext)))
{
- lg(Debug) << "EndpointRegistry::setEndpointLocatorDestinationIds() detected and ignoring duplicate call for operation " << operationContext->id;
+ lg(Debug) << "EndpointRegistry::setEndpointLocatorDestinationIds() detected retry for operation " << operationContext->id;
return;
}
@@ -555,19 +564,21 @@ void EndpointRegistry::setEndpointLocatorDestinationIds(
if (!exists)
{
- mImpl->forwardEndpointLocatorDestIdChange(operationContext, locatorId, regExList, 0, Event::FAILURE);
throw DestinationNotFoundException(locatorId);
}
// Replace the regular expression.
existing->second.setRegEx(regExList);
mImpl->forwardEndpointLocatorDestIdChange(operationContext, locatorId, regExList, existing->second.locator, Event::SUCCESS);
+ contextData->setCompleted();
}
catch(const std::exception &e)
{
mImpl->forwardEndpointLocatorDestIdChange(operationContext, locatorId, regExList, 0, Event::FAILURE);
lg(Error) << "Exception modifying the destination specifications for EndpointLocator " << locatorId;
lg(Error) << " - " << e.what();
+ contextData->setException(ExceptionWrapper::create(e));
+ throw;
}
}
@@ -585,7 +596,8 @@ void EndpointRegistry::setScriptProcessor(const ScriptProcessorPtr& scriptProces
*/
void EndpointRegistry::clearEndpointLocators(const OperationContextPtr& operationContext)
{
- if (!mImpl->mOperationContextCache->addOperationContext(operationContext))
+ ContextDataPtr contextData;
+ if (!(contextData = Operations::checkAndThrow(mImpl->mOperationContextCache, operationContext)))
{
lg(Debug) << "EndpointRegistry::clearEndpointLocators() detected and ignoring duplicate call for operation " << operationContext->id;
return;
@@ -593,6 +605,7 @@ void EndpointRegistry::clearEndpointLocators(const OperationContextPtr& operatio
mImpl->clearEndpointLocatorMap();
mImpl->mEventPublisher->clearEndpointLocatorsEvent(operationContext);
+ contextData->setCompleted();
}
/**
@@ -603,14 +616,25 @@ void EndpointRegistry::clearEndpointLocators(const OperationContextPtr& operatio
*/
void EndpointRegistry::setPolicy(const OperationContextPtr& operationContext, const std::string& policy)
{
- if (!mImpl->mOperationContextCache->addOperationContext(operationContext))
+ ContextDataPtr contextData;
+ if (!(contextData = Operations::checkAndThrow(mImpl->mOperationContextCache, operationContext)))
{
lg(Debug) << "EndpointRegistry::setPolicy() detected and ignoring duplicate call for operation " << operationContext->id;
return;
}
- mImpl->mScriptProcessor->setPolicy(policy);
- mImpl->mEventPublisher->setPolicyEvent(operationContext, policy);
+ try
+ {
+ mImpl->mScriptProcessor->setPolicy(policy);
+ mImpl->mEventPublisher->setPolicyEvent(operationContext, policy);
+ contextData->setCompleted();
+ }
+ catch (const std::exception& e)
+ {
+ lg(Error) << "Exception setting polocy:" << e.what();
+ contextData->setException(ExceptionWrapper::create(e));
+ throw;
+ }
}
} // end BasicRoutingService
diff --git a/src/RouteSessionOperation.cpp b/src/RouteSessionOperation.cpp
index 40e3f88..0297a8c 100644
--- a/src/RouteSessionOperation.cpp
+++ b/src/RouteSessionOperation.cpp
@@ -32,6 +32,7 @@ using namespace AsteriskSCF::BasicRoutingService;
using namespace AsteriskSCF::Replication::BasicRoutingService::V1;
using namespace AsteriskSCF::StateMachine;
using namespace AsteriskSCF::System::V1;
+using namespace AsteriskSCF::Operations;
namespace
{
@@ -214,7 +215,7 @@ void RouteSessionOperation::initStateMachine()
* This object is an instance of WorkQueue::Work so that
* it can be enqueued to a worker thread.
*/
-RouteSessionOperation::RouteSessionOperation(const SessionRouterOperationCookie<AMD_SessionRouter_routeSessionPtr>::Ptr& cookie,
+RouteSessionOperation::RouteSessionOperation(const AMDContextData<AMD_SessionRouter_routeSessionPtr>::Ptr& cookie,
const OperationContextPtr& operationContext,
const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& source,
const ::std::string& destination,
@@ -245,7 +246,7 @@ RouteSessionOperation::RouteSessionOperation(const SessionRouterOperationCookie<
/**
* This is the factory method for RouteSessionOperation.
*/
-RouteSessionOperationPtr RouteSessionOperation::create(const SessionRouterOperationCookie<AMD_SessionRouter_routeSessionPtr>::Ptr& cookie,
+RouteSessionOperationPtr RouteSessionOperation::create(const AMDContextData<AMD_SessionRouter_routeSessionPtr>::Ptr& cookie,
const OperationContextPtr& operationContext,
const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& source,
const ::std::string& destination,
diff --git a/src/RouteSessionOperation.h b/src/RouteSessionOperation.h
index 01e4620..f6b6fc0 100644
--- a/src/RouteSessionOperation.h
+++ b/src/RouteSessionOperation.h
@@ -18,6 +18,7 @@
#include <boost/function.hpp>
#include <AsteriskSCF/Core/Routing/RoutingIf.h>
+#include <AsteriskSCF/Operations/OperationMonitor.h>
#include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.h>
#include "BasicRoutingStateReplicationIf.h"
@@ -65,7 +66,7 @@ public:
/**
* Factory method for the class. This method creates an active routing operation.
*/
- static RouteSessionOperationPtr create(const SessionRouterOperationCookie<AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_routeSessionPtr>::Ptr& cookie,
+ static RouteSessionOperationPtr create(const AsteriskSCF::Operations::AMDContextData<AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_routeSessionPtr>::Ptr& cookie,
const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& source,
const ::std::string& destination,
@@ -106,7 +107,7 @@ public:
protected:
// Normal constructor
- RouteSessionOperation(const SessionRouterOperationCookie<AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_routeSessionPtr>::Ptr& cookie,
+ RouteSessionOperation(const AsteriskSCF::Operations::AMDContextData<AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_routeSessionPtr>::Ptr& cookie,
const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
const ::AsteriskSCF::SessionCommunications::V1::SessionPrx& source,
const ::std::string& destination,
diff --git a/src/SessionRouter.cpp b/src/SessionRouter.cpp
index 1b51d69..19925c1 100644
--- a/src/SessionRouter.cpp
+++ b/src/SessionRouter.cpp
@@ -28,6 +28,7 @@
#include <AsteriskSCF/Core/Endpoint/EndpointIf.h>
#include <AsteriskSCF/Logger.h>
#include <AsteriskSCF/Operations/OperationContextCache.h>
+#include <AsteriskSCF/Operations/OperationMonitor.h>
#include "SessionRouter.h"
#include "RouteSessionOperation.h"
@@ -175,21 +176,15 @@ void SessionRouter::routeSession_async(const AMD_SessionRouter_routeSessionPtr&
const RedirectionsPtr& redirects,
const ::Ice::Current& current)
{
- SessionRouterOperationCookie<AMD_SessionRouter_routeSessionPtr>::Ptr newCookie(new
- SessionRouterOperationCookie<AMD_SessionRouter_routeSessionPtr>(cb));
- OperationContextCookiePtr existingCookie;
- if (!mImpl->mOperationContextCache->addOperationContext(operationContext, newCookie, existingCookie))
+ boost::shared_ptr<AMDContextData<AMD_SessionRouter_routeSessionPtr> > cookie =
+ getContext<boost::shared_ptr<AMDContextData<AMD_SessionRouter_routeSessionPtr> >, AMD_SessionRouter_routeSessionPtr>(
+ mImpl->mOperationContextCache,
+ operationContext,
+ cb);
+ if (!cookie)
{
- SessionRouterOperationCookie<AMD_SessionRouter_routeSessionPtr>::Ptr cookie =
- boost::dynamic_pointer_cast<SessionRouterOperationCookie<AMD_SessionRouter_routeSessionPtr> >(existingCookie);
-
- if (cookie != 0)
- {
- cookie->addCallback(cb);
- }
-
- lg(Debug) << "Duplicate routeSession() operation detected and rejected for operation " << operationContext->id;
+ lg(Debug) << "Retry of routeSession() detected for operation " << operationContext->id;
return;
}
@@ -197,14 +192,14 @@ void SessionRouter::routeSession_async(const AMD_SessionRouter_routeSessionPtr&
RouteSessionOperationPtr routeSessionOp;
if (mImpl->mOperationReplicaCache->getRouteSessionCache()->fetchOperation(operationContext->id, routeSessionOp))
{
- routeSessionOp->rehostReplica(newCookie, current, mImpl.get());
+ routeSessionOp->rehostReplica(cookie, current, mImpl.get());
WorkPtr replicaOp(routeSessionOp);
mImpl->scheduleOperation(replicaOp);
return;
}
- WorkPtr op(RouteSessionOperation::create(newCookie,
+ WorkPtr op(RouteSessionOperation::create(cookie,
operationContext,
source,
destination,
@@ -236,21 +231,14 @@ void SessionRouter::connectBridgedSessionsWithDestination_async(const AMD_Sessio
const SessionCreationHookPrx& oneShotHook,
const ::Ice::Current& current)
{
- SessionRouterOperationCookie<AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr>::Ptr newCookie(new
- SessionRouterOperationCookie<AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr>(cb));
-
- OperationContextCookiePtr existingCookie;
- if (!mImpl->mOperationContextCache->addOperationContext(operationContext, newCookie, existingCookie))
+ boost::shared_ptr<AMDContextData<AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr> > cookie =
+ getContext<boost::shared_ptr<AMDContextData<AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr> >, AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr>(
+ mImpl->mOperationContextCache,
+ operationContext,
+ cb);
+ if (!cookie)
{
- SessionRouterOperationCookie<AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr>::Ptr cookie =
- boost::dynamic_pointer_cast<SessionRouterOperationCookie<AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr> >(existingCookie);
-
- if (cookie != 0)
- {
- cookie->addCallback(cb);
- }
-
- lg(Debug) << "Duplicate connectBridgedSessionsWithDestination() operation detected and rejected for operation " << operationContext->id;
+ lg(Debug) << "Retry of connectBridgedSessionsWithDestination() operation detected for operation " << operationContext->id;
return;
}
@@ -258,14 +246,14 @@ void SessionRouter::connectBridgedSessionsWithDestination_async(const AMD_Sessio
ConnectBridgedSessionsWithDestinationOperationPtr connectBridgedSessionsWithDestOp;
if (mImpl->mOperationReplicaCache->getConnectBridgedSessionsWithDestCache()->fetchOperation(operationContext->id, connectBridgedSessionsWithDestOp))
{
- connectBridgedSessionsWithDestOp->rehostReplica(newCookie, current, mImpl.get());
+ connectBridgedSessionsWithDestOp->rehostReplica(cookie, current, mImpl.get());
WorkPtr replicaOp(connectBridgedSessionsWithDestOp);
mImpl->scheduleOperation(replicaOp);
return;
}
- WorkPtr op(ConnectBridgedSessionsWithDestinationOperation::create(newCookie,
+ WorkPtr op(ConnectBridgedSessionsWithDestinationOperation::create(cookie,
operationContext,
sessionToReplace,
destination,
@@ -288,24 +276,18 @@ void SessionRouter::connectBridgedSessions_async(const ::AsteriskSCF::SessionCom
bool replaceSession,
const ::Ice::Current& current)
{
- SessionRouterOperationCookie<AMD_SessionRouter_connectBridgedSessionsPtr>::Ptr newCookie(new
- SessionRouterOperationCookie<AMD_SessionRouter_connectBridgedSessionsPtr>(cb));
-
- OperationContextCookiePtr existingCookie;
- if (!mImpl->mOperationContextCache->addOperationContext(operationContext, newCookie, existingCookie))
+ boost::shared_ptr<AMDContextData<AMD_SessionRouter_connectBridgedSessionsPtr> > cookie =
+ getContext<boost::shared_ptr<AMDContextData<AMD_SessionRouter_connectBridgedSessionsPtr> >, AMD_SessionRouter_connectBridgedSessionsPtr>(
+ mImpl->mOperationContextCache,
+ operationContext,
+ cb);
+ if (!cookie)
{
- SessionRouterOperationCookie<AMD_SessionRouter_connectBridgedSessionsPtr>::Ptr cookie =
- boost::dynamic_pointer_cast<SessionRouterOperationCookie<AMD_SessionRouter_connectBridgedSessionsPtr> >(existingCookie);
-
- if (cookie != 0)
- {
- cookie->addCallback(cb);
- }
- lg(Debug) << "Duplicate connectBridgedSessions() operation detected and rejected for operation " << operationContext->id;
+ lg(Debug) << "Retry of connectBridgedSessions() detected for operation " << operationContext->id;
return;
}
- WorkPtr op(ConnectBridgedSessionsOperation::create(newCookie,
+ WorkPtr op(ConnectBridgedSessionsOperation::create(cookie,
operationContext,
sessionToReplace,
bridgedSession,
diff --git a/src/SessionRouterOperation.h b/src/SessionRouterOperation.h
index 794d03e..417b6b3 100644
--- a/src/SessionRouterOperation.h
+++ b/src/SessionRouterOperation.h
@@ -30,6 +30,7 @@
#include <AsteriskSCF/System/OperationsIf.h>
#include <AsteriskSCF/Operations/OperationContext.h>
#include <AsteriskSCF/Operations/OperationContextCache.h>
+#include <AsteriskSCF/Operations/OperationMonitor.h>
#include "RoutingReplicationContext.h"
#include "RoutingServiceEventPublisher.h"
@@ -102,44 +103,6 @@ protected:
// Forward-declaration
template <typename T, typename S> class LookupCallback;
-/**
- * This template provides a cookie to associate with a SessionRouter operation.
- * The cookie collects AMD callback objects (of type T) so that retries of
- * operations can be called back.
- */
-template<typename T>
-class SessionRouterOperationCookie : public AsteriskSCF::Operations::OperationContextCookie
-{
-public:
- SessionRouterOperationCookie(const T& callback)
- {
- mCallbacks.push_back(callback);
- }
-
- ~SessionRouterOperationCookie() {}
-
- void addCallback(const T& callback)
- {
- boost::unique_lock<boost::shared_mutex> lock(mLock);
- mCallbacks.push_back(callback);
- }
-
- /**
- * Get a copy of the callback set.
- */
- std::vector<T> getCallbacks()
- {
- boost::unique_lock<boost::shared_mutex> lock(mLock);
- return mCallbacks;
- }
-
- typedef boost::shared_ptr<SessionRouterOperationCookie<T> > Ptr;
-
-private:
- std::vector<T> mCallbacks;
- boost::shared_mutex mLock;
-};
-
/**
* This is a base class for worker objects that offload SessionRouter operations
* to a worker thead during an AMD invocation. It implements the WorkQueue::Work
@@ -159,7 +122,7 @@ public:
* @param manager
* @param defaultState The initial state of the operation's state machine.
*/
- SessionRouterOperation(const typename SessionRouterOperationCookie<T>::Ptr& cookie,
+ SessionRouterOperation(const typename AsteriskSCF::Operations::AMDContextData<T>::Ptr& cookie,
const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
const SessionContextPtr& context,
const ::Ice::Current& current,
@@ -219,13 +182,7 @@ public:
{
// Forward to this operation's callers. (Support plural in case of retries).
- std::vector<T> callbacks = mCookie->getCallbacks();
- for(typename std::vector<T>::iterator it = callbacks.begin();
- it != callbacks.end(); ++it)
- {
- (*it)->ice_exception(e);
- }
-
+ mCookie->getProxy()->ice_exception(e);
finish();
}
@@ -235,13 +192,7 @@ public:
*/
void finishWithException()
{
- std::vector<T> callbacks = mCookie->getCallbacks();
- for(typename std::vector<T>::iterator it = callbacks.begin();
- it != callbacks.end(); ++it)
- {
- (*it)->ice_exception();
- }
-
+ mCookie->getProxy()->ice_exception();
finish();
}
@@ -251,13 +202,7 @@ public:
*/
void finishAndSendResult()
{
- std::vector<T> callbacks = mCookie->getCallbacks();
- for(typename std::vector<T>::iterator it = callbacks.begin();
- it != callbacks.end(); ++it)
- {
- (*it)->ice_response();
- }
-
+ mCookie->getProxy()->ice_response();
finish();
}
@@ -367,7 +312,7 @@ public:
/**
* Sets a replicated operation's non-replicated state related to the specific host process.
*/
- void rehostReplica(const typename SessionRouterOperationCookie<T>::Ptr& cookie, const ::Ice::Current& current, OperationsManager* manager)
+ void rehostReplica(const typename AsteriskSCF::Operations::AMDContextData<T>::Ptr& cookie, const ::Ice::Current& current, OperationsManager* manager)
{
mCookie = cookie;
mIceCurrent = current;
@@ -385,7 +330,7 @@ public:
}
protected:
- typename SessionRouterOperationCookie<T>::Ptr mCookie;
+ typename AsteriskSCF::Operations::AMDContextData<T>::Ptr mCookie;
AsteriskSCF::System::V1::OperationContextPtr mOperationContext;
SessionContextPtr mSessionContext;
::Ice::Current mIceCurrent;
-----------------------------------------------------------------------
--
asterisk-scf/integration/routing.git
More information about the asterisk-scf-commits
mailing list