[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 Mar 13 19:05:25 CDT 2012
branch "retry_deux" has been updated
via be4a8051a643214fa8cc1478209bc4f18b6a0a19 (commit)
from f11c81e06cee6a82430a96062f2fe4198a7dde70 (commit)
Summary of changes:
.../BasicRoutingStateReplicationIf.ice | 2 -
src/ConnectBridgedSessionsOperation.cpp | 24 +++++++-
...nectBridgedSessionsWithDestinationOperation.cpp | 4 +-
src/EndpointRegistry.cpp | 17 +++---
src/EndpointRegistry.h | 3 +-
src/RouteSessionOperation.cpp | 4 +-
src/RoutingServiceEventPublisher.cpp | 52 +++++++++++-------
src/RoutingServiceEventPublisher.h | 33 ++++++-----
src/SessionListener.cpp | 58 ++++++++++++++------
src/SessionListener.h | 14 ++---
src/SessionRouterOperation.h | 16 ++----
11 files changed, 133 insertions(+), 94 deletions(-)
- Log -----------------------------------------------------------------
commit be4a8051a643214fa8cc1478209bc4f18b6a0a19
Author: Ken Hunt <ken.hunt at digium.com>
Date: Tue Mar 13 19:04:32 2012 -0500
Rounding out the handling of OperationContext.
diff --git a/slice/AsteriskSCF/Replication/BasicRoutingService/BasicRoutingStateReplicationIf.ice b/slice/AsteriskSCF/Replication/BasicRoutingService/BasicRoutingStateReplicationIf.ice
index d917c2c..4a5012a 100644
--- a/slice/AsteriskSCF/Replication/BasicRoutingService/BasicRoutingStateReplicationIf.ice
+++ b/slice/AsteriskSCF/Replication/BasicRoutingService/BasicRoutingStateReplicationIf.ice
@@ -104,7 +104,6 @@ module V1
string destination;
AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHook* hook;
AsteriskSCF::SessionCommunications::PartyIdentification::V1::Caller callerID;
- AsteriskSCF::System::V1::OperationContext unregisterListenerContext;
AsteriskSCF::System::V1::OperationContext createBridgeContext;
};
const string RouteSessionOpStartKeyMod = ".START";
@@ -147,7 +146,6 @@ module V1
AsteriskSCF::SessionCommunications::V1::Session *sessionToReplace;
string destination;
bool replaceSession;
- AsteriskSCF::System::V1::OperationContext unregisterListenerContext;
AsteriskSCF::System::V1::OperationContext addOrReplaceSessionContext;
};
const string ConnectBridgedSessionsWithDestStartKeyMod = ".START";
diff --git a/src/ConnectBridgedSessionsOperation.cpp b/src/ConnectBridgedSessionsOperation.cpp
index b2695fd..48a2524 100644
--- a/src/ConnectBridgedSessionsOperation.cpp
+++ b/src/ConnectBridgedSessionsOperation.cpp
@@ -30,8 +30,23 @@ using namespace AsteriskSCF::System::V1;
namespace
{
Logger lg = getLoggerFactory().getLogger("AsteriskSCF.BasicRoutingService");
+
+
+/**
+ * Create a new OperationContext using a name calculated from the sourceContext,
+ * and having the same transactionId as the source context.
+ */
+OperationContextPtr calculateOperationContext(
+ const OperationContextPtr& sourceContext,
+ const std::string& modifier)
+{
+ std::string calculateId = sourceContext->id + ".ConnectBridgedSessions." + modifier;
+
+ return new OperationContext(calculateId, sourceContext->transactionId);
}
+} // end unnamed namespace
+
namespace AsteriskSCF
{
namespace BasicRoutingService
@@ -175,7 +190,7 @@ void ConnectBridgedSessionsOperation::connectBridgedSessionsState()
// We're through listening, and we will probably interfere with the Bridge's functionality if
// we keep listening.
lg(Debug) << "connectBridgedSessions(): Removing listener. " ;
- mListenerManager->getListener()->unregister(mOperationContext);
+ mListenerManager->getListener()->unregister();
// Now replace the sessions.
try
@@ -183,12 +198,15 @@ void ConnectBridgedSessionsOperation::connectBridgedSessionsState()
if (mReplaceSession)
{
lg(Debug) << BOOST_CURRENT_FUNCTION << ": Asking bridge to add sessions." ;
- mergeBridge->replaceSession(mOperationContext, mSessionToReplace, infoSeq);
+ mergeBridge->replaceSession(
+ calculateOperationContext(mOperationContext,"replaceSessions"),
+ mSessionToReplace,
+ infoSeq);
}
else
{
lg(Debug) << BOOST_CURRENT_FUNCTION << ": Asking bridge to replace sessions." ;
- mergeBridge->addSessions(mOperationContext, infoSeq);
+ mergeBridge->addSessions(calculateOperationContext(mOperationContext,"addSessions"), infoSeq);
}
}
catch(const Ice::Exception& e)
diff --git a/src/ConnectBridgedSessionsWithDestinationOperation.cpp b/src/ConnectBridgedSessionsWithDestinationOperation.cpp
index 67262f0..9a3abf2 100644
--- a/src/ConnectBridgedSessionsWithDestinationOperation.cpp
+++ b/src/ConnectBridgedSessionsWithDestinationOperation.cpp
@@ -84,7 +84,6 @@ public:
opStart->sessionToReplace = mOperation->getSessionToReplace();
opStart->destination = mOperation->getDestination();
opStart->replaceSession = mOperation->getReplaceSession();
- opStart->unregisterListenerContext = mOperation->getUnregisterListenerContext();
opStart->addOrReplaceSessionContext = mOperation->getAddOrReplaceSessionContext();
pushState(opStart);
@@ -332,7 +331,6 @@ void ConnectBridgedSessionsWithDestinationOperation::reflectUpdate(
mDestination = item->destination;
mOperationContext = item->initiatingContext;
mReplaceSession = item->replaceSession;
- mUnregisterListenerContext = item->unregisterListenerContext;
mAddOrReplaceSessionContext = item->addOrReplaceSessionContext;
mReplicatedStates.push_back(ConnectBridgedSessionsWithDestinationOp::STATE_LOOKUP);
@@ -501,7 +499,7 @@ void ConnectBridgedSessionsWithDestinationOperation::establishBridgeState()
// We're through listening, and we will probably interfere with the Bridge's functionality if
// we keep listening.
- mListenerManager->getListener()->unregister(mUnregisterListenerContext);
+ mListenerManager->getListener()->unregister();
// Modify the bridge
try
diff --git a/src/EndpointRegistry.cpp b/src/EndpointRegistry.cpp
index 0ef8e37..22f7f66 100644
--- a/src/EndpointRegistry.cpp
+++ b/src/EndpointRegistry.cpp
@@ -24,7 +24,6 @@
#include "RoutingServiceEventPublisher.h"
#include "EndpointRegistry.h"
-#include "RoutingServiceEventPublisher.h"
#include "ScriptProcessor.h"
using namespace ::std;
@@ -85,7 +84,7 @@ class EndpointRegistryPriv
{
public:
EndpointRegistryPriv(const ScriptProcessorPtr& scriptProcessor,
- const RoutingEventsPtr& eventPublisher,
+ const RoutingServiceEventPublisherPtr& eventPublisher,
const RoutingReplicationContextPtr& replicationContext) :
mScriptProcessor(scriptProcessor),
mEventPublisher(eventPublisher),
@@ -270,7 +269,7 @@ public:
ScriptProcessorPtr mScriptProcessor;
EndpointLocatorMap mEndpointLocatorMap;
- const RoutingEventsPtr mEventPublisher;
+ const RoutingServiceEventPublisherPtr mEventPublisher;
RoutingReplicationContextPtr mReplicationContext;
OperationContextCachePtr mOperationContextCache;
};
@@ -294,7 +293,7 @@ public:
*/
LookupResultCollector(const AMD_EndpointLocator_lookupPtr& callback,
const std::string& destination,
- const RoutingEventsPtr& eventPublisher,
+ const RoutingServiceEventPublisherPtr& eventPublisher,
size_t numVotes)
: mCallback(callback),
mNumVotes(numVotes),
@@ -330,7 +329,7 @@ public:
lg(Debug) << "EndpointRegistry::lookup() found Endpoint for destination " << mDestination;
// Post event
- mEventPublisher->lookupEvent(createContext(), mDestination, Event::SUCCESS);
+ mEventPublisher->lookupEvent(mDestination, Event::SUCCESS);
}
assert(mNumVotes > 0);
@@ -360,7 +359,7 @@ public:
mCallback = 0;
// Post event
- mEventPublisher->lookupEvent(createContext(), mDestination, Event::FAILURE);
+ mEventPublisher->lookupEvent(mDestination, Event::FAILURE);
lg(Debug) << "EndpointRegistry::lookup() failed to find destination " << mDestination;
}
@@ -369,7 +368,7 @@ private:
boost::mutex mLock;
AMD_EndpointLocator_lookupPtr mCallback;
size_t mNumVotes;
- RoutingEventsPtr mEventPublisher;
+ RoutingServiceEventPublisherPtr mEventPublisher;
std::string mDestination;
};
typedef IceUtil::Handle<LookupResultCollector> LookupResultCollectorPtr;
@@ -378,7 +377,7 @@ typedef IceUtil::Handle<LookupResultCollector> LookupResultCollectorPtr;
* Constructor.
*/
EndpointRegistry::EndpointRegistry(const ScriptProcessorPtr& scriptProcessor,
- const RoutingEventsPtr& eventPublisher,
+ const RoutingServiceEventPublisherPtr& eventPublisher,
const RoutingReplicationContextPtr& replicationContext) :
mImpl(new EndpointRegistryPriv(scriptProcessor, eventPublisher, replicationContext))
{
@@ -401,7 +400,7 @@ void EndpointRegistry::lookup_async(const ::AsteriskSCF::Core::Routing::V1::AMD_
{
if (!mImpl->mScriptProcessor->confirmLookup(destination, modifiedDestination))
{
- mImpl->mEventPublisher->lookupEvent(createContext(), destination, Event::FAILURE);
+ mImpl->mEventPublisher->lookupEvent(destination, Event::FAILURE);
lg(Error) << "lookup(): denied by confirmLookup() script.";
amdcallback->ice_response(endpoints);
diff --git a/src/EndpointRegistry.h b/src/EndpointRegistry.h
index 5d0ba55..85331b2 100644
--- a/src/EndpointRegistry.h
+++ b/src/EndpointRegistry.h
@@ -21,6 +21,7 @@
#include <AsteriskSCF/Discovery/SmartProxy.h>
#include "BasicRoutingStateReplicationIf.h"
+#include "RoutingServiceEventPublisher.h"
#include "RoutingReplicationContext.h"
#include "ScriptProcessor.h"
@@ -35,7 +36,7 @@ class EndpointRegistry : public AsteriskSCF::Core::Routing::V1::LocatorRegistry
{
public:
EndpointRegistry(const ScriptProcessorPtr& scriptProcessor,
- const AsteriskSCF::Core::Routing::V1::Event::RoutingEventsPtr& eventPublisher,
+ const RoutingServiceEventPublisherPtr& eventPublisher,
const RoutingReplicationContextPtr& replicationContext);
/**
diff --git a/src/RouteSessionOperation.cpp b/src/RouteSessionOperation.cpp
index 56d029e..40e3f88 100644
--- a/src/RouteSessionOperation.cpp
+++ b/src/RouteSessionOperation.cpp
@@ -85,7 +85,6 @@ public:
routeSessionOpStart->key = mOperation->getOperationContext()->id + RouteSessionOpStartKeyMod;
routeSessionOpStart->source = mOperation->getSource();
routeSessionOpStart->destination = mOperation->getDestination();
- routeSessionOpStart->unregisterListenerContext = mOperation->getUnregisterListenerContext();
routeSessionOpStart->createBridgeContext = mOperation->getCreateBridgeContext();
pushState(routeSessionOpStart);
@@ -328,7 +327,6 @@ void RouteSessionOperation::reflectUpdate(const AsteriskSCF::Replication::BasicR
mHook = item->hook;
mCallerID = item->callerID;
mOperationContext = item->initiatingContext;
- mUnregisterListenerContext = item->unregisterListenerContext;
mCreateBridgeContext = item->createBridgeContext;
mReplicatedStates.push_back(RouteSessionOp::STATE_LOOKUP);
@@ -507,7 +505,7 @@ void RouteSessionOperation::establishBridgeState()
// We're through listening, and we will probably interfere with the
// Bridge's functionality if we keep listening.
- mListenerManager->getListener()->unregister(mUnregisterListenerContext);
+ mListenerManager->getListener()->unregister();
// Create the bridge
BridgePrx bridge;
diff --git a/src/RoutingServiceEventPublisher.cpp b/src/RoutingServiceEventPublisher.cpp
index eb58a38..91f3a36 100644
--- a/src/RoutingServiceEventPublisher.cpp
+++ b/src/RoutingServiceEventPublisher.cpp
@@ -33,6 +33,19 @@ using namespace ::AsteriskSCF::System::V1;
namespace
{
Logger lg = getLoggerFactory().getLogger("AsteriskSCF.BasicRoutingService");
+
+/**
+ * Create a new OperationContext using the id of a source context and a modifer.
+ * It will have the same transactionId as the source context.
+ */
+OperationContextPtr calculateOperationContext(
+ const OperationContextPtr& sourceContext,
+ const std::string& modifier)
+{
+ std::string calculateId = sourceContext->id + ".Event." + modifier;
+
+ return new OperationContext(calculateId, sourceContext->transactionId);
+}
}
namespace AsteriskSCF
@@ -154,11 +167,11 @@ RoutingServiceEventPublisher::RoutingServiceEventPublisher(const Ice::ObjectAdap
/**
* Send a message to the service's event topic to report a lookup event.
+ * The operation that triggers this event is idempotent.
*/
void RoutingServiceEventPublisher::lookupEvent(
- const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
const std::string& destination,
- AsteriskSCF::Core::Routing::V1::Event::OperationResult result, const Ice::Current &)
+ AsteriskSCF::Core::Routing::V1::Event::OperationResult result)
{
if (!mImpl->isInitialized())
{
@@ -167,7 +180,8 @@ void RoutingServiceEventPublisher::lookupEvent(
try
{
- mImpl->mEventTopic->lookupEvent(AsteriskSCF::Operations::createContext(operationContext), destination, result);
+ // Since the lookup itself is idempotent, we'll create a new context for the event publication.
+ mImpl->mEventTopic->lookupEvent(AsteriskSCF::Operations::createContext(), destination, result);
}
catch(const Ice::Exception &e)
{
@@ -179,12 +193,11 @@ void RoutingServiceEventPublisher::lookupEvent(
/**
* Send a message to the service's event topic to report the addEndpointLocator event.
*/
-void RoutingServiceEventPublisher::addEndpointLocatorEvent(const OperationContextPtr& operationContext,
+void RoutingServiceEventPublisher::addEndpointLocatorEvent(const OperationContextPtr& sourceContext,
const std::string& locatorId,
const ::AsteriskSCF::Core::Routing::V1::RegExSeq& regexList,
const AsteriskSCF::Core::Routing::V1::EndpointLocatorPrx& locator,
- AsteriskSCF::Core::Routing::V1::Event::OperationResult result,
- const Ice::Current &)
+ AsteriskSCF::Core::Routing::V1::Event::OperationResult result)
{
if (!mImpl->isInitialized())
{
@@ -193,7 +206,7 @@ void RoutingServiceEventPublisher::addEndpointLocatorEvent(const OperationContex
try
{
- mImpl->mEventTopic->addEndpointLocatorEvent(AsteriskSCF::Operations::createContext(operationContext), locatorId, regexList, locator, result);
+ mImpl->mEventTopic->addEndpointLocatorEvent(calculateOperationContext(sourceContext, "addLocator"), locatorId, regexList, locator, result);
}
catch(const Ice::Exception &e)
{
@@ -204,9 +217,9 @@ void RoutingServiceEventPublisher::addEndpointLocatorEvent(const OperationContex
/**
* Send a message to the service's event topic to report the removeEndpointLocator event.
*/
-void RoutingServiceEventPublisher::removeEndpointLocatorEvent(const OperationContextPtr& operationContext,
+void RoutingServiceEventPublisher::removeEndpointLocatorEvent(const OperationContextPtr& sourceContext,
const std::string& locatorId,
- AsteriskSCF::Core::Routing::V1::Event::OperationResult result, const Ice::Current &)
+ AsteriskSCF::Core::Routing::V1::Event::OperationResult result)
{
if (!mImpl->isInitialized())
{
@@ -215,7 +228,7 @@ void RoutingServiceEventPublisher::removeEndpointLocatorEvent(const OperationCon
try
{
- mImpl->mEventTopic->removeEndpointLocatorEvent(AsteriskSCF::Operations::createContext(operationContext), locatorId, result);
+ mImpl->mEventTopic->removeEndpointLocatorEvent(calculateOperationContext(sourceContext, "removeLocator"), locatorId, result);
}
catch(const Ice::Exception &e)
{
@@ -227,10 +240,9 @@ void RoutingServiceEventPublisher::removeEndpointLocatorEvent(const OperationCon
* Send a message to the service's event topic to report the setEndpointLocatorDestinationIds event.
*/
void RoutingServiceEventPublisher::setEndpointLocatorDestinationIdsEvent(
- const OperationContextPtr& operationContext,
+ const OperationContextPtr& sourceContext,
const std::string& locatorId,
- const AsteriskSCF::Core::Routing::V1::RegExSeq& regexList, AsteriskSCF::Core::Routing::V1::Event::OperationResult result,
- const Ice::Current &)
+ const AsteriskSCF::Core::Routing::V1::RegExSeq& regexList, AsteriskSCF::Core::Routing::V1::Event::OperationResult result)
{
if (!mImpl->isInitialized())
{
@@ -239,7 +251,7 @@ void RoutingServiceEventPublisher::setEndpointLocatorDestinationIdsEvent(
try
{
- mImpl->mEventTopic->setEndpointLocatorDestinationIdsEvent(AsteriskSCF::Operations::createContext(operationContext), locatorId, regexList, result);
+ mImpl->mEventTopic->setEndpointLocatorDestinationIdsEvent(calculateOperationContext(sourceContext, "setIds"), locatorId, regexList, result);
}
catch(const Ice::Exception &e)
{
@@ -250,8 +262,7 @@ void RoutingServiceEventPublisher::setEndpointLocatorDestinationIdsEvent(
/**
* Send a message to the service's event topic to report the clearEndpointLocators event.
*/
-void RoutingServiceEventPublisher::clearEndpointLocatorsEvent(const OperationContextPtr& operationContext,
- const Ice::Current &)
+void RoutingServiceEventPublisher::clearEndpointLocatorsEvent(const OperationContextPtr& sourceContext)
{
if (!mImpl->isInitialized())
{
@@ -260,7 +271,7 @@ void RoutingServiceEventPublisher::clearEndpointLocatorsEvent(const OperationCon
try
{
- mImpl->mEventTopic->clearEndpointLocatorsEvent(AsteriskSCF::Operations::createContext(operationContext));
+ mImpl->mEventTopic->clearEndpointLocatorsEvent(calculateOperationContext(sourceContext, "clearLocators"));
}
catch(const Ice::Exception &e)
{
@@ -271,9 +282,8 @@ void RoutingServiceEventPublisher::clearEndpointLocatorsEvent(const OperationCon
/**
* Send a message to the service's event topic to report the setPolicy event.
*/
-void RoutingServiceEventPublisher::setPolicyEvent(const OperationContextPtr& operationContext,
- const std::string& policy,
- const Ice::Current &)
+void RoutingServiceEventPublisher::setPolicyEvent(const OperationContextPtr& sourceContext,
+ const std::string& policy)
{
if (!mImpl->isInitialized())
{
@@ -282,7 +292,7 @@ void RoutingServiceEventPublisher::setPolicyEvent(const OperationContextPtr& ope
try
{
- mImpl->mEventTopic->setPolicyEvent(AsteriskSCF::Operations::createContext(operationContext), policy);
+ mImpl->mEventTopic->setPolicyEvent(calculateOperationContext(sourceContext, "setPolicy"), policy);
}
catch(const Ice::Exception &e)
{
diff --git a/src/RoutingServiceEventPublisher.h b/src/RoutingServiceEventPublisher.h
index 4ee2018..7a61116 100644
--- a/src/RoutingServiceEventPublisher.h
+++ b/src/RoutingServiceEventPublisher.h
@@ -16,6 +16,7 @@
#pragma once
#include <Ice/Ice.h>
+#include <IceUtil/Handle.h>
#include <boost/shared_ptr.hpp>
#include <AsteriskSCF/Core/Routing/RoutingIf.h>
@@ -32,7 +33,7 @@ class RoutingServiceEventPublisherPriv;
/**
* Publishes key events to the rest of the system.
*/
-class RoutingServiceEventPublisher : public ::AsteriskSCF::Core::Routing::V1::Event::RoutingEvents
+class RoutingServiceEventPublisher : public IceUtil::Shared
{
public:
RoutingServiceEventPublisher(const Ice::ObjectAdapterPtr& adapter);
@@ -41,65 +42,67 @@ public:
/**
* Send a message to the service's event topic to report a lookup event.
+ * @param operationContext The operation context to send with this event.
* @param destination The destination to be looked up.
* @param result Informs event listeners of the operations success or failure.
*/
void lookupEvent(
- const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
const std::string& destination,
- AsteriskSCF::Core::Routing::V1::Event::OperationResult result,
- const Ice::Current&);
+ AsteriskSCF::Core::Routing::V1::Event::OperationResult result);
/**
* Send a message to the service's event topic to report an addEndpointLocator event.
+ * @param sourceContext The context fo the operation that triggered this event.
* @param locatorId The identity of the EndpointLocator being added.
* @param regexList List of regex strings used to identify the destinations available by this locator.
* @param result Informs event listeners of the operations success or failure.
*/
- void addEndpointLocatorEvent(const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+ void addEndpointLocatorEvent(const AsteriskSCF::System::V1::OperationContextPtr& sourceContext,
const std::string& locatorId,
const AsteriskSCF::Core::Routing::V1::RegExSeq& regexList,
const AsteriskSCF::Core::Routing::V1::EndpointLocatorPrx& locator,
- AsteriskSCF::Core::Routing::V1::Event::OperationResult result,
- const Ice::Current&);
+ AsteriskSCF::Core::Routing::V1::Event::OperationResult result);
/**
* Send a message to the service's event topic to report a removeEndpointLocator event.
+ * @param sourceContext The context fo the operation that triggered this event.
* @param locatorId The identity of the EndpointLocator being removed.
* @param result Informs event listeners of the operations success or failure.
*/
- void removeEndpointLocatorEvent(const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
- const std::string& locatorId, AsteriskSCF::Core::Routing::V1::Event::OperationResult result,
- const Ice::Current&);
+ void removeEndpointLocatorEvent(const AsteriskSCF::System::V1::OperationContextPtr& sourceContext,
+ const std::string& locatorId, AsteriskSCF::Core::Routing::V1::Event::OperationResult result);
/**
* Send a message to the service's event topic to report a aetEndpointLocatorDestinationIds event.
+ * @param sourceContext The context fo the operation that triggered this event.
* @param locatorId The identity of the EndpointLocator whose destination specifications should be changed.
* @param regexList New list of regex strings to be used to identify the destinations available by this locator.
* @param result Informs event listeners of the operations success or failure.
*/
void setEndpointLocatorDestinationIdsEvent(
- const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+ const AsteriskSCF::System::V1::OperationContextPtr& sourceContext,
const std::string& locatorId,
const AsteriskSCF::Core::Routing::V1::RegExSeq& regexList,
- AsteriskSCF::Core::Routing::V1::Event::OperationResult result, const Ice::Current&);
+ AsteriskSCF::Core::Routing::V1::Event::OperationResult result);
/**
* Send a message to the service's event topic to report the clearEndpointLocators event.
+ * @param sourceContext The context fo the operation that triggered this event.
*/
- void clearEndpointLocatorsEvent(const AsteriskSCF::System::V1::OperationContextPtr& operationContext, const Ice::Current&);
+ void clearEndpointLocatorsEvent(const AsteriskSCF::System::V1::OperationContextPtr& sourceContext);
/**
* Send a message to the service's event topic to report the setPolicy event.
+ * @param sourceContext The context fo the operation that triggered this event.
*/
- void setPolicyEvent(const AsteriskSCF::System::V1::OperationContextPtr& operationContext, const std::string& policy, const Ice::Current&);
+ void setPolicyEvent(const AsteriskSCF::System::V1::OperationContextPtr& sourceContext, const std::string& policy);
private:
boost::shared_ptr<RoutingServiceEventPublisherPriv> mImpl; // pimpl idiom applied.
};
-typedef IceInternal::Handle<RoutingServiceEventPublisher> RoutingServiceEventPublisherPtr;
+typedef IceUtil::Handle<RoutingServiceEventPublisher> RoutingServiceEventPublisherPtr;
} // end BasicRoutingService
} // end AsteriskSCF
diff --git a/src/SessionListener.cpp b/src/SessionListener.cpp
index e20b765..2aab727 100644
--- a/src/SessionListener.cpp
+++ b/src/SessionListener.cpp
@@ -32,6 +32,21 @@ using namespace AsteriskSCF::Operations;
namespace
{
Logger lg = getLoggerFactory().getLogger("AsteriskSCF.BasicRoutingService");
+
+
+/**
+ * Create a new OperationContext using a name calculated from the sourceContext,
+ * and having the same transactionId as the source context.
+ */
+OperationContextPtr calculateOperationContext(
+ const OperationContextPtr& sourceContext,
+ const std::string& modifier)
+{
+ std::string calculateId = sourceContext->id + "." + modifier;
+
+ return new OperationContext(calculateId, sourceContext->transactionId);
+}
+
}
namespace AsteriskSCF
@@ -39,8 +54,8 @@ namespace AsteriskSCF
namespace BasicRoutingService
{
-SessionListenerImpl::SessionListenerImpl() :
- mTerminated(false), mListenerPrx(0)
+SessionListenerImpl::SessionListenerImpl(const AsteriskSCF::System::V1::OperationContextPtr& sourceContext) :
+ mSourceContext(sourceContext), mTerminated(false), mListenerPrx(0)
{
}
@@ -48,7 +63,6 @@ SessionListenerImpl::~SessionListenerImpl()
{
}
-
void SessionListenerImpl::indicated(const OperationContextPtr& operationContext,
const SessionPrx& session,
const IndicationPtr& event,
@@ -76,7 +90,9 @@ void SessionListenerImpl::indicated(const OperationContextPtr& operationContext,
{
if (session->ice_getIdentity() != (*s)->ice_getIdentity())
{
- (*s)->stop(createContext(operationContext), stoppedIndication->response);
+ std::string nameModifier = (*s)->ice_getIdentity().name + ".stop";
+ OperationContextPtr newContext = calculateOperationContext(operationContext, nameModifier);
+ (*s)->stop(newContext, stoppedIndication->response);
}
}
catch(const Ice::Exception &e)
@@ -96,7 +112,7 @@ void SessionListenerImpl::addSession(const SessionPrx& session)
/**
* Add a session to be tracked by this listener, and attach this listener to the session.
*/
-void SessionListenerImpl::addSessionAndListen(const OperationContextPtr& operationContext, SessionPrx session)
+void SessionListenerImpl::addSessionAndListen(SessionPrx session)
{
{ // critical scope
boost::unique_lock<boost::shared_mutex> lock(mSessionLock);
@@ -108,7 +124,11 @@ void SessionListenerImpl::addSessionAndListen(const OperationContextPtr& operati
try
{
lg(Debug) << "Adding listener to session." ;
- session->addListener(createContext(operationContext), mListenerPrx);
+
+ std::string nameModifier = session->ice_getIdentity().name + ".addListener";
+ OperationContextPtr newContext = calculateOperationContext(mSourceContext, nameModifier);
+
+ session->addListener(newContext, mListenerPrx);
}
catch(const Ice::Exception &e)
{
@@ -131,7 +151,7 @@ bool SessionListenerImpl::isTerminated() // Lots of shoring up to do for asynchr
/**
* Stop listening to all sessions we're monitoring.
*/
-void SessionListenerImpl::unregister(const OperationContextPtr& operationContext)
+void SessionListenerImpl::unregister()
{
SessionSeq sessionsToCall;
{ // critical scope
@@ -146,7 +166,11 @@ void SessionListenerImpl::unregister(const OperationContextPtr& operationContext
try
{
lg(Debug) << "Removing listener from session " << (*s)->ice_toString();
- (*s)->removeListener(createContext(operationContext), mListenerPrx);
+
+ std::string nameModifier = (*s)->ice_getIdentity().name + ".removeListener";
+ OperationContextPtr newContext = calculateOperationContext(mSourceContext, nameModifier);
+
+ (*s)->removeListener(newContext, mListenerPrx);
}
catch(const Ice::Exception &e)
{
@@ -175,11 +199,11 @@ void SessionListenerImpl::setProxy(const SessionListenerPrx& prx)
* Constructor for SessionListenerManager.
*/
SessionListenerManager::SessionListenerManager(
- const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+ const AsteriskSCF::System::V1::OperationContextPtr& sourceContext,
const Ice::ObjectAdapterPtr& adapter,
const SessionPrx& session)
- : mOperationContext(operationContext),
- mSessionListener(new SessionListenerImpl()),
+ : mSourceContext(sourceContext),
+ mSessionListener(new SessionListenerImpl(sourceContext)),
mAdapter(adapter)
{
@@ -190,7 +214,7 @@ SessionListenerManager::SessionListenerManager(
SessionListenerPrx listenerProxy = SessionListenerPrx::checkedCast(prx);
mSessionListener->setProxy(listenerProxy);
- mSessionListener->addSessionAndListen(operationContext, session);
+ mSessionListener->addSessionAndListen(session);
}
catch(...)
{
@@ -208,11 +232,11 @@ SessionListenerManager::SessionListenerManager(
* Constructor for SessionListenerManager.
*/
SessionListenerManager::SessionListenerManager(
- const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+ const AsteriskSCF::System::V1::OperationContextPtr& sourceContext,
const Ice::ObjectAdapterPtr& adapter,
const SessionSeq& sessionSequence)
- : mOperationContext(operationContext),
- mSessionListener(new SessionListenerImpl()),
+ : mSourceContext(sourceContext),
+ mSessionListener(new SessionListenerImpl(sourceContext)),
mAdapter(adapter)
{
@@ -225,7 +249,7 @@ SessionListenerManager::SessionListenerManager(
for(SessionSeq::const_iterator s = sessionSequence.begin(); s != sessionSequence.end(); ++s)
{
- mSessionListener->addSessionAndListen(operationContext, *s);
+ mSessionListener->addSessionAndListen(*s);
}
}
catch(...)
@@ -249,7 +273,7 @@ SessionListenerManager::~SessionListenerManager()
{
lg(Debug) << "About to unregister the listener..." ;
- mSessionListener->unregister(mOperationContext);
+ mSessionListener->unregister();
}
catch(const std::exception& e)
{
diff --git a/src/SessionListener.h b/src/SessionListener.h
index 738abaa..e0e0a49 100644
--- a/src/SessionListener.h
+++ b/src/SessionListener.h
@@ -34,7 +34,7 @@ namespace BasicRoutingService
class SessionListenerImpl : public AsteriskSCF::SessionCommunications::V1::SessionListener
{
public:
- SessionListenerImpl();
+ SessionListenerImpl(const AsteriskSCF::System::V1::OperationContextPtr& sourceContext);
~SessionListenerImpl();
public: // Overrides for SessionListener
@@ -50,15 +50,12 @@ public: // Impl operations
/**
* Adds a session to be tracked by the listener.
*/
- void addSession(
- const AsteriskSCF::SessionCommunications::V1::SessionPrx& session);
+ void addSession(const AsteriskSCF::SessionCommunications::V1::SessionPrx& session);
/**
* Add a session to be tracked by this listener, and attach this listener to the session.
*/
- void addSessionAndListen(
- const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
- AsteriskSCF::SessionCommunications::V1::SessionPrx session);
+ void addSessionAndListen(AsteriskSCF::SessionCommunications::V1::SessionPrx session);
size_t getNumSessions();
bool isTerminated();
@@ -66,13 +63,14 @@ public: // Impl operations
/**
* Stop listening to all sessions we're monitoring.
*/
- void unregister(const AsteriskSCF::System::V1::OperationContextPtr& operationContext);
+ void unregister();
AsteriskSCF::SessionCommunications::V1::SessionListenerPrx getProxy();
void setProxy(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& prx);
private:
boost::shared_mutex mSessionLock;
+ AsteriskSCF::System::V1::OperationContextPtr mSourceContext;
AsteriskSCF::SessionCommunications::V1::SessionSeq mSessions;
bool mTerminated;
AsteriskSCF::SessionCommunications::V1::SessionListenerPrx mListenerPrx;
@@ -101,7 +99,7 @@ public:
SessionListenerImpl* getListener() const;
private:
- AsteriskSCF::System::V1::OperationContextPtr mOperationContext;
+ AsteriskSCF::System::V1::OperationContextPtr mSourceContext;
SessionListenerImpl* mSessionListener;
Ice::ObjectAdapterPtr mAdapter;
}; // class SessionListenerManager
diff --git a/src/SessionRouterOperation.h b/src/SessionRouterOperation.h
index 187bde1..1c6cf2c 100644
--- a/src/SessionRouterOperation.h
+++ b/src/SessionRouterOperation.h
@@ -31,6 +31,7 @@
#include <AsteriskSCF/Operations/OperationContextCache.h>
#include "RoutingReplicationContext.h"
+#include "RoutingServiceEventPublisher.h"
#include "SessionListener.h"
#include "EndpointRegistry.h"
@@ -52,7 +53,7 @@ public:
*/
SessionContext(const Ice::ObjectAdapterPtr& adapterArg,
const EndpointRegistryPtr& registryArg,
- const AsteriskSCF::Core::Routing::V1::Event::RoutingEventsPtr& publisherArg,
+ const RoutingServiceEventPublisherPtr& publisherArg,
const boost::shared_ptr<AsteriskSCF::Threading::WorkQueue>& workQueueArg,
const RoutingReplicationContextPtr& replicationContextArg)
: adapter(adapterArg),
@@ -67,7 +68,7 @@ public:
const Ice::ObjectAdapterPtr adapter;
const EndpointRegistryPtr endpointRegistry;
- const AsteriskSCF::Core::Routing::V1::Event::RoutingEventsPtr eventPublisher;
+ const RoutingServiceEventPublisherPtr eventPublisher;
const boost::shared_ptr<AsteriskSCF::Threading::WorkQueue> workQueue;
const RoutingReplicationContextPtr replicationContext;
@@ -166,8 +167,7 @@ public:
mIceCurrent(current),
mFinished(false),
mOperationsManager(manager),
- mStateMachine(defaultState),
- mUnregisterListenerContext(AsteriskSCF::Operations::createContext(operationContext))
+ mStateMachine(defaultState)
{
}
@@ -377,11 +377,6 @@ public:
return mStartSessionContexts;
}
- AsteriskSCF::System::V1::OperationContextPtr getUnregisterListenerContext()
- {
- return mUnregisterListenerContext;
- }
-
protected:
typename SessionRouterOperationCookie<T>::Ptr mCookie;
AsteriskSCF::System::V1::OperationContextPtr mOperationContext;
@@ -394,11 +389,8 @@ protected:
AsteriskSCF::StateMachine::SimpleStateMachine<S> mStateMachine;
AsteriskSCF::Core::Endpoint::V1::EndpointSeq mLookupResult;
- AsteriskSCF::System::V1::OperationContextSeq mAddSessionListenerContexts;
- AsteriskSCF::System::V1::OperationContextSeq mRemoveSessionListenerContexts;
AsteriskSCF::System::V1::OperationContextSeq mCreateSessionContexts;
AsteriskSCF::System::V1::OperationContextSeq mStartSessionContexts;
- AsteriskSCF::System::V1::OperationContextPtr mUnregisterListenerContext;
}; // class SessionRouterOperation
-----------------------------------------------------------------------
--
asterisk-scf/integration/routing.git
More information about the asterisk-scf-commits
mailing list