[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 27 19:05:28 CDT 2012
branch "retry_deux" has been updated
via cbd70a3609f162267313600dc9219f9cf66c8cf7 (commit)
via aff242d3b2ee8f6a175b2c9a1dd7d509b31a7052 (commit)
via 105cbeb20c63d5656b6cd2bb6867fa184acd8f0f (commit)
via 1944bc82a8b2682bfb048f3b5ddf495971062f42 (commit)
via 1d5be561dd2dd3a4fbfd671f797c31fc13731052 (commit)
via 2a15cbc1f5c79cc18711e3c1df5fef51371773c3 (commit)
via 9001b8584ae8028c6be5d0245f962370ce60776c (commit)
from 17394f7f48475944efc079a76f9a817a6ec6cacb (commit)
Summary of changes:
src/BasicRoutingStateReplicatorApp.cpp | 327 --------------------------------
src/CMakeLists.txt | 2 +-
src/ComponentStateReplicator.cpp | 125 ++++++++++++
src/SessionRouterOperation.h | 15 +-
test/MockSession.cpp | 18 +-
test/MockSessionEndpoint.cpp | 12 +-
test/TestRouting.cpp | 172 ++++++++----------
7 files changed, 229 insertions(+), 442 deletions(-)
delete mode 100755 src/BasicRoutingStateReplicatorApp.cpp
create mode 100644 src/ComponentStateReplicator.cpp
- Log -----------------------------------------------------------------
commit cbd70a3609f162267313600dc9219f9cf66c8cf7
Author: Ken Hunt <ken.hunt at digium.com>
Date: Tue Mar 27 19:03:48 2012 -0500
Hello, gcc!
diff --git a/src/SessionRouterOperation.h b/src/SessionRouterOperation.h
index 1c6cf2c..794d03e 100644
--- a/src/SessionRouterOperation.h
+++ b/src/SessionRouterOperation.h
@@ -28,6 +28,7 @@
#include <AsteriskSCF/Core/Routing/RoutingIf.h>
#include <AsteriskSCF/Logger.h>
#include <AsteriskSCF/System/OperationsIf.h>
+#include <AsteriskSCF/Operations/OperationContext.h>
#include <AsteriskSCF/Operations/OperationContextCache.h>
#include "RoutingReplicationContext.h"
@@ -123,7 +124,10 @@ public:
mCallbacks.push_back(callback);
}
- const std::vector<T>& getCallbacks()
+ /**
+ * Get a copy of the callback set.
+ */
+ std::vector<T> getCallbacks()
{
boost::unique_lock<boost::shared_mutex> lock(mLock);
return mCallbacks;
@@ -216,7 +220,8 @@ public:
// Forward to this operation's callers. (Support plural in case of retries).
std::vector<T> callbacks = mCookie->getCallbacks();
- for(std::vector<T>::iterator it = callbacks.begin(); it != callbacks.end(); ++it)
+ for(typename std::vector<T>::iterator it = callbacks.begin();
+ it != callbacks.end(); ++it)
{
(*it)->ice_exception(e);
}
@@ -231,7 +236,8 @@ public:
void finishWithException()
{
std::vector<T> callbacks = mCookie->getCallbacks();
- for(std::vector<T>::iterator it = callbacks.begin(); it != callbacks.end(); ++it)
+ for(typename std::vector<T>::iterator it = callbacks.begin();
+ it != callbacks.end(); ++it)
{
(*it)->ice_exception();
}
@@ -246,7 +252,8 @@ public:
void finishAndSendResult()
{
std::vector<T> callbacks = mCookie->getCallbacks();
- for(std::vector<T>::iterator it = callbacks.begin(); it != callbacks.end(); ++it)
+ for(typename std::vector<T>::iterator it = callbacks.begin();
+ it != callbacks.end(); ++it)
{
(*it)->ice_response();
}
diff --git a/test/MockSession.cpp b/test/MockSession.cpp
index 193501f..f461fa8 100644
--- a/test/MockSession.cpp
+++ b/test/MockSession.cpp
@@ -120,7 +120,7 @@ void MockSession::internalAddListener(const SessionListenerPrx& listener)
void MockSession::addListener_async(
const AsteriskSCF::SessionCommunications::V1::AMD_Session_addListenerPtr& cb,
- const OperationContextPtr& operationContext,
+ const OperationContextPtr&,
const SessionListenerPrx& listener,
const Ice::Current&)
{
@@ -130,7 +130,7 @@ void MockSession::addListener_async(
void MockSession::indicate_async(
const AsteriskSCF::SessionCommunications::V1::AMD_Session_indicatePtr& cb,
- const OperationContextPtr& operationContext,
+ const OperationContextPtr&,
const AsteriskSCF::SessionCommunications::V1::IndicationPtr& indication,
const Ice::Current&)
{
@@ -168,7 +168,7 @@ void MockSession::getMediaSession_async(
cb->ice_response(0);
}
-void MockSession::removeListener(const OperationContextPtr& operationContext, const SessionListenerPrx& listener, const Ice::Current&)
+void MockSession::removeListener(const OperationContextPtr&, const SessionListenerPrx& listener, const Ice::Current&)
{
for(vector<SessionListenerPrx>::iterator i = mListeners.begin(); i != mListeners.end(); ++i)
{
@@ -180,7 +180,7 @@ void MockSession::removeListener(const OperationContextPtr& operationContext, co
}
}
-void MockSession::start(const OperationContextPtr& operationContext, const Ice::Current&)
+void MockSession::start(const OperationContextPtr&, const Ice::Current&)
{
cout << "Session started." << endl;
@@ -191,7 +191,7 @@ void MockSession::start(const OperationContextPtr& operationContext, const Ice::
}
}
-void MockSession::stop(const OperationContextPtr& operationContext, const ResponseCodePtr& response, const Ice::Current&)
+void MockSession::stop(const OperationContextPtr&, const ResponseCodePtr& response, const Ice::Current&)
{
BOOST_TEST_MESSAGE("Session " + mLegId + " stopped.");
@@ -219,7 +219,7 @@ void MockSession::getStreams_async(
void MockSession::setAndGetSessionController_async(
const AsteriskSCF::SessionCommunications::V1::AMD_Session_setAndGetSessionControllerPtr& cb,
- const OperationContextPtr& operationContext,
+ const OperationContextPtr&,
const AsteriskSCF::SessionCommunications::V1::SessionControllerPrx&,
const Ice::Current&)
{
@@ -228,7 +228,7 @@ void MockSession::setAndGetSessionController_async(
void MockSession::removeSessionController_async(
const AsteriskSCF::SessionCommunications::V1::AMD_Session_removeSessionControllerPtr& cb,
- const OperationContextPtr& operationContext,
+ const OperationContextPtr&,
const AsteriskSCF::SessionCommunications::V1::SessionControllerPrx&,
const Ice::Current&)
{
@@ -266,7 +266,7 @@ void MockSession::getRedirections_async(const AMD_Session_getRedirectionsPtr& cb
*/
void MockSession::setBridge_async(
const AMD_Session_setBridgePtr& cb,
- const OperationContextPtr& operationContext,
+ const OperationContextPtr&,
const BridgePrx& bridge,
const SessionListenerPrx& listener,
const Ice::Current&)
@@ -281,7 +281,7 @@ void MockSession::setBridge_async(
void MockSession::removeBridge_async(
const AsteriskSCF::SessionCommunications::V1::AMD_Session_removeBridgePtr& cb,
- const OperationContextPtr& operationContext,
+ const OperationContextPtr&,
const SessionListenerPrx& listener,
const Ice::Current ¤t)
{
diff --git a/test/MockSessionEndpoint.cpp b/test/MockSessionEndpoint.cpp
index cf7a110..aba7a1c 100644
--- a/test/MockSessionEndpoint.cpp
+++ b/test/MockSessionEndpoint.cpp
@@ -40,7 +40,7 @@ MockSessionEndpoint::MockSessionEndpoint(const std::string& id) :
}
SessionPrx MockSessionEndpoint::createSession(
- const OperationContextPtr& operationContext,
+ const OperationContextPtr&,
const string& dest,
const SessionListenerPrx&,
const SessionCreationHookPrx&,
@@ -72,25 +72,27 @@ void MockSessionEndpoint::setProxy(const SessionEndpointPrx& proxy)
mProxy = proxy;
}
-void MockSessionEndpoint::addDefaultSessionListener(const OperationContextPtr& operationContext, const SessionListenerPrx& listener, const Ice::Current& )
+void MockSessionEndpoint::addDefaultSessionListener(const OperationContextPtr&,
+ const SessionListenerPrx& listener, const Ice::Current& )
{
mDefaultSessionListeners.add(listener);
}
-void MockSessionEndpoint::removeDefaultSessionListener(const OperationContextPtr& operationContext, const SessionListenerPrx& listener, const Ice::Current&)
+void MockSessionEndpoint::removeDefaultSessionListener(const OperationContextPtr&,
+ const SessionListenerPrx& listener, const Ice::Current&)
{
mDefaultSessionListeners.remove(listener);
}
void MockSessionEndpoint::addDefaultSessionCookies(
- const OperationContextPtr& operationContext,
+ const OperationContextPtr&,
const AsteriskSCF::SessionCommunications::V1::SessionCookies&,
const Ice::Current&)
{
}
void MockSessionEndpoint::removeDefaultSessionCookies(
- const OperationContextPtr& operationContext,
+ const OperationContextPtr&,
const AsteriskSCF::SessionCommunications::V1::SessionCookies&,
const Ice::Current&)
{
commit aff242d3b2ee8f6a175b2c9a1dd7d509b31a7052
Merge: 105cbeb 17394f7
Author: Ken Hunt <ken.hunt at digium.com>
Date: Mon Mar 26 16:09:55 2012 -0500
Merge branch 'retry_deux' of git.asterisk.org:asterisk-scf/integration/routing into retry_deux
diff --cc test/TestRouting.cpp
index 0f87888,12a8eb7..24e4855
--- a/test/TestRouting.cpp
+++ b/test/TestRouting.cpp
@@@ -65,105 -68,125 +68,105 @@@ struct GlobalIceFixtur
::boost::debug::detect_memory_leaks(false);
::boost::unit_test::unit_test_log.set_stream( std::cout );
- int status = 0;
- try
+ // Set up incoming adapter. This is where we'll publish our proxies.
+ SharedTestData::instance.communicatorIn = IceBoxTestEnv.communicator;
+
+ Ice::PropertiesPtr props = SharedTestData::instance.communicatorIn->getProperties();
+ SharedTestData::instance.adapterIn = SharedTestData::instance.communicatorIn->createObjectAdapterWithEndpoints("TestRoutingAdapterIn", "default -h 127.0.0.1 -p 10070");
+
+ // Serve up our own EndpointLocator, since we're emulating a channel.
+ MockEndpointLocator *locator = new MockEndpointLocator();
+ SharedTestData::instance.endpointLocator = locator;
+ SharedTestData::instance.adapterIn->add(SharedTestData::instance.endpointLocator, SharedTestData::instance.communicatorIn->stringToIdentity(LocatorObjectId));
+
+ SharedTestData::instance.adapterIn->activate();
+
+ // Now that the adapter has been activated, get a local proxy to our EndpointLocator.
+ Ice::ObjectPrx locatorObjectPrx = SharedTestData::instance.adapterIn->createDirectProxy(SharedTestData::instance.communicatorIn->stringToIdentity(LocatorObjectId));
+ SharedTestData::instance.endpointLocatorPrx = EndpointLocatorPrx::checkedCast(locatorObjectPrx);
+
+ // Now set up outgoing adapter. This will be used for proxies we want to call out to the
+ // the unit under test on.
+ Ice::InitializationData initData;
+ initData.properties = IceBoxTestEnv.communicator->getProperties();
+ SharedTestData::instance.communicatorOut = Ice::initialize(initData);
+ SharedTestData::instance.adapterOut = SharedTestData::instance.communicatorOut->createObjectAdapterWithEndpoints("TestRoutingAdapterOut", "default -h 127.0.0.1 -p 10071");
+
+ // Get ref to Routing Service's ComponentService interface.
+ Ice::ObjectPrx componentObj = SharedTestData::instance.communicatorOut->propertyToProxy("RoutingComponent.Proxy");
+ SharedTestData::instance.componentService = ComponentServicePrx::uncheckedCast(componentObj);
+
+ if (!SharedTestData::instance.componentService)
+ {
+ throw "Invalid ComponentService";
+ }
+
+ SharedTestData::instance.componentTest = ComponentTestPrx::checkedCast(SharedTestData::instance.componentService, AsteriskSCF::System::Component::V1::ComponentTestFacet);
+ if (SharedTestData::instance.componentTest == 0)
+ {
+ BOOST_TEST_MESSAGE("No Component Test facet available. Some tests may be skipped.");
+ }
+
+ // Get ref to Routing Service EndpointLocator so we can test it. Getting direct for now, but
+ // need to test acquiring reference via ServiceLocator as well.
+ Ice::ObjectPrx locatorObj = SharedTestData::instance.communicatorOut->propertyToProxy("LocatorRegistry.Proxy");
+ SharedTestData::instance.locatorRegistry = LocatorRegistryPrx::uncheckedCast(locatorObj);
+
+ if (!SharedTestData::instance.locatorRegistry)
+ {
+ throw "Invalid LocatorRegistry";
+ }
+
+ // Get ref to Backup Routing Services EndpointLocator we can test it.
+ Ice::ObjectPrx locatorObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupLocatorRegistry.Proxy");
+ SharedTestData::instance.backupLocatorRegistry = LocatorRegistryPrx::uncheckedCast(locatorObj2);
+
+ if (!SharedTestData::instance.backupLocatorRegistry)
{
- // Set up incoming adapter. This is where we'll publish our proxies.
- SharedTestData::instance.communicatorIn = IceBoxTestEnv.communicator;
-
- Ice::PropertiesPtr props = SharedTestData::instance.communicatorIn->getProperties();
- SharedTestData::instance.adapterIn = SharedTestData::instance.communicatorIn->createObjectAdapterWithEndpoints("TestRoutingAdapterIn", "default -h 127.0.0.1 -p 10070");
-
- // Serve up our own EndpointLocator, since we're emulating a channel.
- MockEndpointLocator *locator = new MockEndpointLocator();
- SharedTestData::instance.endpointLocator = locator;
- SharedTestData::instance.adapterIn->add(SharedTestData::instance.endpointLocator, SharedTestData::instance.communicatorIn->stringToIdentity(LocatorObjectId));
-
- SharedTestData::instance.adapterIn->activate();
-
- // Now that the adapter has been activated, get a local proxy to our EndpointLocator.
- Ice::ObjectPrx locatorObjectPrx = SharedTestData::instance.adapterIn->createDirectProxy(SharedTestData::instance.communicatorIn->stringToIdentity(LocatorObjectId));
- SharedTestData::instance.endpointLocatorPrx = EndpointLocatorPrx::checkedCast(locatorObjectPrx);
-
- // Now set up outgoing adapter. This will be used for proxies we want to call out to the
- // the unit under test on.
- Ice::InitializationData initData;
- initData.properties = IceBoxTestEnv.communicator->getProperties();
- SharedTestData::instance.communicatorOut = Ice::initialize(initData);
- SharedTestData::instance.adapterOut = SharedTestData::instance.communicatorOut->createObjectAdapterWithEndpoints("TestRoutingAdapterOut", "default -h 127.0.0.1 -p 10071");
-
- // Get ref to Routing Service's ComponentService interface.
- Ice::ObjectPrx componentObj = SharedTestData::instance.communicatorOut->propertyToProxy("RoutingComponent.Proxy");
- SharedTestData::instance.componentService = ComponentServicePrx::uncheckedCast(componentObj);
-
- if (!SharedTestData::instance.componentService)
- {
- throw "Invalid ComponentService";
- }
-
- SharedTestData::instance.componentTest = ComponentTestPrx::checkedCast(SharedTestData::instance.componentService, AsteriskSCF::System::Component::V1::ComponentTestFacet);
- if (SharedTestData::instance.componentTest == 0)
- {
- BOOST_TEST_MESSAGE("No Component Test facet available. Some tests may be skipped.");
- }
-
- // Get ref to Routing Service EndpointLocator so we can test it. Getting direct for now, but
- // need to test acquiring reference via ServiceLocator as well.
- Ice::ObjectPrx locatorObj = SharedTestData::instance.communicatorOut->propertyToProxy("LocatorRegistry.Proxy");
- SharedTestData::instance.locatorRegistry = LocatorRegistryPrx::uncheckedCast(locatorObj);
-
- if (!SharedTestData::instance.locatorRegistry)
- {
- throw "Invalid LocatorRegistry";
- }
-
- // Get ref to Backup Routing Services EndpointLocator we can test it.
- Ice::ObjectPrx locatorObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupLocatorRegistry.Proxy");
- SharedTestData::instance.backupLocatorRegistry = LocatorRegistryPrx::uncheckedCast(locatorObj2);
-
- if (!SharedTestData::instance.backupLocatorRegistry)
- {
- throw "Invalid Backup LocatorRegistry";
- }
-
- // Get a ref to the SessionRouter interface and cache it for testing.
- Ice::ObjectPrx routerObj = SharedTestData::instance.communicatorOut->propertyToProxy("SessionRouter.Proxy");
- SharedTestData::instance.sessionRouter = SessionRouterPrx::checkedCast(routerObj);
-
- if (!SharedTestData::instance.sessionRouter)
- {
- throw "Invalid SessionRouter";
- }
-
- // Get a ref to the Backup SessionRouter interface and cache it for testing.
- Ice::ObjectPrx routerObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupSessionRouter.Proxy");
- SharedTestData::instance.backupSessionRouter = SessionRouterPrx::checkedCast(routerObj2);
-
- if (!SharedTestData::instance.backupSessionRouter)
- {
- throw "Invalid Backup SessionRouter";
- }
-
- // Get a ref to the Replica interface and cache it for testing.
- Ice::ObjectPrx replicaObj = SharedTestData::instance.communicatorOut->propertyToProxy("Replica.Proxy");
- SharedTestData::instance.serviceReplicaMgmt = ReplicaPrx::checkedCast(replicaObj);
-
- if (!SharedTestData::instance.serviceReplicaMgmt)
- {
- throw "Invalid Replica";
- }
-
- // Note: This would be done by Pacemaker-initiated script in the real system. Something
- // external must activate one of the sevice instances.
- SharedTestData::instance.serviceReplicaMgmt->activate(createContext());
-
- // Get a ref to the Replica interface and cache it for testing.
- Ice::ObjectPrx replicaObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupReplica.Proxy");
- SharedTestData::instance.backupServiceReplicaMgmt = ReplicaPrx::checkedCast(replicaObj2);
-
- if (!SharedTestData::instance.backupServiceReplicaMgmt)
- {
- throw "Invalid Backup Replica";
- }
-
- RegisterWithServiceLocator();
+ throw "Invalid Backup LocatorRegistry";
}
- catch (const Ice::Exception& ex)
+
+ // Get a ref to the SessionRouter interface and cache it for testing.
+ Ice::ObjectPrx routerObj = SharedTestData::instance.communicatorOut->propertyToProxy("SessionRouter.Proxy");
+ SharedTestData::instance.sessionRouter = SessionRouterPrx::checkedCast(routerObj);
+
+ if (!SharedTestData::instance.sessionRouter)
{
- cerr << ex << endl;
- status = 1;
+ throw "Invalid SessionRouter";
}
- catch (const std::exception& ex)
+
+ // Get a ref to the Backup SessionRouter interface and cache it for testing.
+ Ice::ObjectPrx routerObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupSessionRouter.Proxy");
+ SharedTestData::instance.backupSessionRouter = SessionRouterPrx::checkedCast(routerObj2);
+
+ if (!SharedTestData::instance.backupSessionRouter)
{
- cerr << ex.what() << endl;
- status = 1;
+ throw "Invalid Backup SessionRouter";
}
- catch (const char* msg)
+
+ // Get a ref to the Replica interface and cache it for testing.
+ Ice::ObjectPrx replicaObj = SharedTestData::instance.communicatorOut->propertyToProxy("Replica.Proxy");
+ SharedTestData::instance.serviceReplicaMgmt = ReplicaPrx::checkedCast(replicaObj);
+
+ if (!SharedTestData::instance.serviceReplicaMgmt)
{
- cerr << msg << endl;
- status = 1;
+ throw "Invalid Replica";
}
- BOOST_CHECK_EQUAL(0, status);
+
+ // Note: This would be done by Pacemaker-initiated script in the real system. Something
- // external must activate one of the sevice instances.
- SharedTestData::instance.serviceReplicaMgmt->activate();
++ // external must activate one of the sevice instances.
++ SharedTestData::instance.serviceReplicaMgmt->activate(createContext());
+
+ // Get a ref to the Replica interface and cache it for testing.
+ Ice::ObjectPrx replicaObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupReplica.Proxy");
+ SharedTestData::instance.backupServiceReplicaMgmt = ReplicaPrx::checkedCast(replicaObj2);
+
+ if (!SharedTestData::instance.backupServiceReplicaMgmt)
+ {
+ throw "Invalid Backup Replica";
+ }
+
+ RegisterWithServiceLocator();
} // end Fixture() constructor
void RegisterWithServiceLocator()
commit 105cbeb20c63d5656b6cd2bb6867fa184acd8f0f
Author: Ken Hunt <ken.hunt at digium.com>
Date: Fri Feb 10 11:41:27 2012 -0600
Changes to base ComponentStateReplicator constructor args.
diff --git a/src/ComponentStateReplicator.cpp b/src/ComponentStateReplicator.cpp
index 1ba7dd6..742309e 100644
--- a/src/ComponentStateReplicator.cpp
+++ b/src/ComponentStateReplicator.cpp
@@ -60,7 +60,7 @@ public:
ComponentStateReplicator() :
AsteriskSCF::Component::ComponentStateReplicator(lg,
AsteriskSCF::Replication::BasicRoutingService::V1::StateReplicatorComponentCategory,
- false)
+ false, "")
{
}
commit 1944bc82a8b2682bfb048f3b5ddf495971062f42
Author: David M. Lee <dlee at digium.com>
Date: Thu Feb 9 10:28:36 2012 -0600
Pass exceptions on up to the test framework.
Fixes set-but-not-used errors.
diff --git a/test/TestRouting.cpp b/test/TestRouting.cpp
index 5ef24cf..0f87888 100644
--- a/test/TestRouting.cpp
+++ b/test/TestRouting.cpp
@@ -65,124 +65,105 @@ struct GlobalIceFixture
::boost::debug::detect_memory_leaks(false);
::boost::unit_test::unit_test_log.set_stream( std::cout );
- int status = 0;
- try
- {
- // Set up incoming adapter. This is where we'll publish our proxies.
- SharedTestData::instance.communicatorIn = IceBoxTestEnv.communicator;
-
- Ice::PropertiesPtr props = SharedTestData::instance.communicatorIn->getProperties();
- SharedTestData::instance.adapterIn = SharedTestData::instance.communicatorIn->createObjectAdapterWithEndpoints("TestRoutingAdapterIn", "default -h 127.0.0.1 -p 10070");
+ // Set up incoming adapter. This is where we'll publish our proxies.
+ SharedTestData::instance.communicatorIn = IceBoxTestEnv.communicator;
- // Serve up our own EndpointLocator, since we're emulating a channel.
- MockEndpointLocator *locator = new MockEndpointLocator();
- SharedTestData::instance.endpointLocator = locator;
- SharedTestData::instance.adapterIn->add(SharedTestData::instance.endpointLocator, SharedTestData::instance.communicatorIn->stringToIdentity(LocatorObjectId));
+ Ice::PropertiesPtr props = SharedTestData::instance.communicatorIn->getProperties();
+ SharedTestData::instance.adapterIn = SharedTestData::instance.communicatorIn->createObjectAdapterWithEndpoints("TestRoutingAdapterIn", "default -h 127.0.0.1 -p 10070");
- SharedTestData::instance.adapterIn->activate();
+ // Serve up our own EndpointLocator, since we're emulating a channel.
+ MockEndpointLocator *locator = new MockEndpointLocator();
+ SharedTestData::instance.endpointLocator = locator;
+ SharedTestData::instance.adapterIn->add(SharedTestData::instance.endpointLocator, SharedTestData::instance.communicatorIn->stringToIdentity(LocatorObjectId));
- // Now that the adapter has been activated, get a local proxy to our EndpointLocator.
- Ice::ObjectPrx locatorObjectPrx = SharedTestData::instance.adapterIn->createDirectProxy(SharedTestData::instance.communicatorIn->stringToIdentity(LocatorObjectId));
- SharedTestData::instance.endpointLocatorPrx = EndpointLocatorPrx::checkedCast(locatorObjectPrx);
+ SharedTestData::instance.adapterIn->activate();
- // Now set up outgoing adapter. This will be used for proxies we want to call out to the
- // the unit under test on.
- Ice::InitializationData initData;
- initData.properties = IceBoxTestEnv.communicator->getProperties();
- SharedTestData::instance.communicatorOut = Ice::initialize(initData);
- SharedTestData::instance.adapterOut = SharedTestData::instance.communicatorOut->createObjectAdapterWithEndpoints("TestRoutingAdapterOut", "default -h 127.0.0.1 -p 10071");
+ // Now that the adapter has been activated, get a local proxy to our EndpointLocator.
+ Ice::ObjectPrx locatorObjectPrx = SharedTestData::instance.adapterIn->createDirectProxy(SharedTestData::instance.communicatorIn->stringToIdentity(LocatorObjectId));
+ SharedTestData::instance.endpointLocatorPrx = EndpointLocatorPrx::checkedCast(locatorObjectPrx);
- // Get ref to Routing Service's ComponentService interface.
- Ice::ObjectPrx componentObj = SharedTestData::instance.communicatorOut->propertyToProxy("RoutingComponent.Proxy");
- SharedTestData::instance.componentService = ComponentServicePrx::uncheckedCast(componentObj);
+ // Now set up outgoing adapter. This will be used for proxies we want to call out to the
+ // the unit under test on.
+ Ice::InitializationData initData;
+ initData.properties = IceBoxTestEnv.communicator->getProperties();
+ SharedTestData::instance.communicatorOut = Ice::initialize(initData);
+ SharedTestData::instance.adapterOut = SharedTestData::instance.communicatorOut->createObjectAdapterWithEndpoints("TestRoutingAdapterOut", "default -h 127.0.0.1 -p 10071");
- if (!SharedTestData::instance.componentService)
- {
- throw "Invalid ComponentService";
- }
+ // Get ref to Routing Service's ComponentService interface.
+ Ice::ObjectPrx componentObj = SharedTestData::instance.communicatorOut->propertyToProxy("RoutingComponent.Proxy");
+ SharedTestData::instance.componentService = ComponentServicePrx::uncheckedCast(componentObj);
- SharedTestData::instance.componentTest = ComponentTestPrx::checkedCast(SharedTestData::instance.componentService, AsteriskSCF::System::Component::V1::ComponentTestFacet);
- if (SharedTestData::instance.componentTest == 0)
- {
- BOOST_TEST_MESSAGE("No Component Test facet available. Some tests may be skipped.");
- }
+ if (!SharedTestData::instance.componentService)
+ {
+ throw "Invalid ComponentService";
+ }
- // Get ref to Routing Service EndpointLocator so we can test it. Getting direct for now, but
- // need to test acquiring reference via ServiceLocator as well.
- Ice::ObjectPrx locatorObj = SharedTestData::instance.communicatorOut->propertyToProxy("LocatorRegistry.Proxy");
- SharedTestData::instance.locatorRegistry = LocatorRegistryPrx::uncheckedCast(locatorObj);
+ SharedTestData::instance.componentTest = ComponentTestPrx::checkedCast(SharedTestData::instance.componentService, AsteriskSCF::System::Component::V1::ComponentTestFacet);
+ if (SharedTestData::instance.componentTest == 0)
+ {
+ BOOST_TEST_MESSAGE("No Component Test facet available. Some tests may be skipped.");
+ }
- if (!SharedTestData::instance.locatorRegistry)
- {
- throw "Invalid LocatorRegistry";
- }
+ // Get ref to Routing Service EndpointLocator so we can test it. Getting direct for now, but
+ // need to test acquiring reference via ServiceLocator as well.
+ Ice::ObjectPrx locatorObj = SharedTestData::instance.communicatorOut->propertyToProxy("LocatorRegistry.Proxy");
+ SharedTestData::instance.locatorRegistry = LocatorRegistryPrx::uncheckedCast(locatorObj);
- // Get ref to Backup Routing Services EndpointLocator we can test it.
- Ice::ObjectPrx locatorObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupLocatorRegistry.Proxy");
- SharedTestData::instance.backupLocatorRegistry = LocatorRegistryPrx::uncheckedCast(locatorObj2);
+ if (!SharedTestData::instance.locatorRegistry)
+ {
+ throw "Invalid LocatorRegistry";
+ }
- if (!SharedTestData::instance.backupLocatorRegistry)
- {
- throw "Invalid Backup LocatorRegistry";
- }
+ // Get ref to Backup Routing Services EndpointLocator we can test it.
+ Ice::ObjectPrx locatorObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupLocatorRegistry.Proxy");
+ SharedTestData::instance.backupLocatorRegistry = LocatorRegistryPrx::uncheckedCast(locatorObj2);
- // Get a ref to the SessionRouter interface and cache it for testing.
- Ice::ObjectPrx routerObj = SharedTestData::instance.communicatorOut->propertyToProxy("SessionRouter.Proxy");
- SharedTestData::instance.sessionRouter = SessionRouterPrx::checkedCast(routerObj);
+ if (!SharedTestData::instance.backupLocatorRegistry)
+ {
+ throw "Invalid Backup LocatorRegistry";
+ }
- if (!SharedTestData::instance.sessionRouter)
- {
- throw "Invalid SessionRouter";
- }
+ // Get a ref to the SessionRouter interface and cache it for testing.
+ Ice::ObjectPrx routerObj = SharedTestData::instance.communicatorOut->propertyToProxy("SessionRouter.Proxy");
+ SharedTestData::instance.sessionRouter = SessionRouterPrx::checkedCast(routerObj);
- // Get a ref to the Backup SessionRouter interface and cache it for testing.
- Ice::ObjectPrx routerObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupSessionRouter.Proxy");
- SharedTestData::instance.backupSessionRouter = SessionRouterPrx::checkedCast(routerObj2);
+ if (!SharedTestData::instance.sessionRouter)
+ {
+ throw "Invalid SessionRouter";
+ }
- if (!SharedTestData::instance.backupSessionRouter)
- {
- throw "Invalid Backup SessionRouter";
- }
+ // Get a ref to the Backup SessionRouter interface and cache it for testing.
+ Ice::ObjectPrx routerObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupSessionRouter.Proxy");
+ SharedTestData::instance.backupSessionRouter = SessionRouterPrx::checkedCast(routerObj2);
- // Get a ref to the Replica interface and cache it for testing.
- Ice::ObjectPrx replicaObj = SharedTestData::instance.communicatorOut->propertyToProxy("Replica.Proxy");
- SharedTestData::instance.serviceReplicaMgmt = ReplicaPrx::checkedCast(replicaObj);
+ if (!SharedTestData::instance.backupSessionRouter)
+ {
+ throw "Invalid Backup SessionRouter";
+ }
- if (!SharedTestData::instance.serviceReplicaMgmt)
- {
- throw "Invalid Replica";
- }
+ // Get a ref to the Replica interface and cache it for testing.
+ Ice::ObjectPrx replicaObj = SharedTestData::instance.communicatorOut->propertyToProxy("Replica.Proxy");
+ SharedTestData::instance.serviceReplicaMgmt = ReplicaPrx::checkedCast(replicaObj);
- // Note: This would be done by Pacemaker-initiated script in the real system. Something
- // external must activate one of the sevice instances.
- SharedTestData::instance.serviceReplicaMgmt->activate();
+ if (!SharedTestData::instance.serviceReplicaMgmt)
+ {
+ throw "Invalid Replica";
+ }
- // Get a ref to the Replica interface and cache it for testing.
- Ice::ObjectPrx replicaObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupReplica.Proxy");
- SharedTestData::instance.backupServiceReplicaMgmt = ReplicaPrx::checkedCast(replicaObj2);
+ // Note: This would be done by Pacemaker-initiated script in the real system. Something
+ // external must activate one of the sevice instances.
+ SharedTestData::instance.serviceReplicaMgmt->activate();
- if (!SharedTestData::instance.backupServiceReplicaMgmt)
- {
- throw "Invalid Backup Replica";
- }
+ // Get a ref to the Replica interface and cache it for testing.
+ Ice::ObjectPrx replicaObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupReplica.Proxy");
+ SharedTestData::instance.backupServiceReplicaMgmt = ReplicaPrx::checkedCast(replicaObj2);
- RegisterWithServiceLocator();
- }
- catch (const Ice::Exception& ex)
+ if (!SharedTestData::instance.backupServiceReplicaMgmt)
{
- cerr << ex << endl;
- status = 1;
- }
- catch (const std::exception& ex)
- {
- cerr << ex.what() << endl;
- status = 1;
- }
- catch (const char* msg)
- {
- cerr << msg << endl;
- status = 1;
+ throw "Invalid Backup Replica";
}
+
+ RegisterWithServiceLocator();
} // end Fixture() constructor
void RegisterWithServiceLocator()
commit 1d5be561dd2dd3a4fbfd671f797c31fc13731052
Author: Ken Hunt <ken.hunt at digium.com>
Date: Mon Feb 6 18:52:16 2012 -0600
Fix for the unit test.
diff --git a/test/TestRouting.cpp b/test/TestRouting.cpp
index a9f4a0f..5ef24cf 100644
--- a/test/TestRouting.cpp
+++ b/test/TestRouting.cpp
@@ -183,7 +183,6 @@ struct GlobalIceFixture
cerr << msg << endl;
status = 1;
}
- BOOST_CHECK_EQUAL(0, status);
} // end Fixture() constructor
void RegisterWithServiceLocator()
commit 2a15cbc1f5c79cc18711e3c1df5fef51371773c3
Author: Ken Hunt <ken.hunt at digium.com>
Date: Mon Feb 6 11:40:13 2012 -0600
Correction for file name case change.
diff --git a/src/ComponentStateReplicator.cpp b/src/ComponentStateReplicator.cpp
index e96d90e..1ba7dd6 100644
--- a/src/ComponentStateReplicator.cpp
+++ b/src/ComponentStateReplicator.cpp
@@ -20,7 +20,7 @@
#include <IceBox/IceBox.h>
#include <AsteriskSCF/Component/ComponentStateReplicator.h>
-#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Logger.h>
#include <AsteriskSCF/Replication/StateReplicator.h>
#include "BasicRoutingStateReplicationIf.h"
commit 9001b8584ae8028c6be5d0245f962370ce60776c
Author: Ken Hunt <ken.hunt at digium.com>
Date: Fri Feb 3 18:24:18 2012 -0600
Using base class ComponentStateReplicator for the replicator service.
diff --git a/src/BasicRoutingStateReplicatorApp.cpp b/src/BasicRoutingStateReplicatorApp.cpp
deleted file mode 100644
index 0e385dd..0000000
--- a/src/BasicRoutingStateReplicatorApp.cpp
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * Asterisk SCF -- An open-source communications framework.
- *
- * Copyright (C) 2010, Digium, Inc.
- *
- * See http://www.asterisk.org for more information about
- * the Asterisk SCF project. Please do not directly contact
- * any of the maintainers of this project for assistance;
- * the project provides a web site, mailing lists and IRC
- * channels for your use.
- *
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE.txt file
- * at the top of the source tree.
- */
-
-#include <Ice/Ice.h>
-#include <IceUtil/UUID.h>
-#include <IceStorm/IceStorm.h>
-#include <IceBox/IceBox.h>
-
-#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
-#include <AsteriskSCF/System/Component/ComponentServiceIf.h>
-#include <AsteriskSCF/Logger.h>
-#include <AsteriskSCF/Logger/IceLogger.h>
-#include <AsteriskSCF/Replication/StateReplicator.h>
-#include "BasicRoutingStateReplicationIf.h"
-
-using namespace std;
-using namespace AsteriskSCF::Core;
-using namespace AsteriskSCF::Core::Discovery::V1;
-using namespace AsteriskSCF::System::Component::V1;
-using namespace AsteriskSCF::System::Logging;
-using namespace AsteriskSCF::Replication::BasicRoutingService::V1;
-using namespace AsteriskSCF::Core::Routing::V1;
-
-namespace
-{
-Logger lg = getLoggerFactory().getLogger("AsteriskSCF.BasicRoutingServiceStateReplicator");
-}
-
-namespace AsteriskSCF
-{
-namespace BasicRoutingService
-{
-
-typedef AsteriskSCF::Replication::StateReplicator< RoutingStateReplicator,
- RoutingStateItemPtr,
- std::string,
- RoutingStateReplicatorListenerPrx> RoutingStateReplicatorI;
-typedef IceUtil::Handle<RoutingStateReplicatorI> RoutingStateReplicatorIPtr;
-
-};
-};
-
-using namespace AsteriskSCF::BasicRoutingService;
-
-/**
- * This class implements a very simplistic replication capability using the StateReplicator template.
- */
-class BasicRoutingStateReplicatorService : public IceBox::Service
-{
-public:
- BasicRoutingStateReplicatorService() : mRunning(false), mInitialized(false) {};
- ~BasicRoutingStateReplicatorService() {};
-
- void suspend();
- void resume();
-
- ////// Overrides of IceBox::Service methods.
- virtual void start(const string &name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq& args);
- virtual void stop();
-
-private:
- void suspendService(bool shuttingDown);
- void initialize(const std::string& appName);
- void registerWithServiceLocator();
- void deregisterFromServiceLocator(bool includeComponentService);
- std::string mAppName;
-
- bool mRunning;
- bool mInitialized;
- ::Ice::ObjectAdapterPtr mServiceAdapter;
- ::Ice::CommunicatorPtr mCommunicator;
- ServiceLocatorManagementPrx mServiceLocatorManagement;
- Discovery::V1::ServiceManagementPrx mComponentServiceManagement;
- Discovery::V1::ServiceManagementPrx mStateReplicationManagement;
- ConfiguredIceLoggerPtr mIceLogger;
- RoutingStateReplicatorIPtr mStateReplicator;
-
- ComponentServicePrx mComponentServicePrx;
- RoutingStateReplicatorPrx mStateReplicatorPrx;
-};
-typedef ::IceUtil::Handle<BasicRoutingStateReplicatorService> BasicRoutingStateReplicatorServicePtr;
-
-static const string ComponentServiceId("BasicRoutingStateReplicatorComponent");
-static const string ServiceDiscoveryId("BasicRoutingStateReplicatorService");
-
-/**
- * This class provides implementation for the ComponentService interface, which
- * every Asterisk SCF component is expected to publish.
- */
-class ComponentServiceImpl : public ComponentService
-{
-public:
- ComponentServiceImpl(BasicRoutingStateReplicatorService* service) : mService(service) {}
-
-public: // Overrides of the ComponentService interface.
- virtual void suspend(const ::Ice::Current&)
- {
- mService->suspend();
- }
-
- virtual void resume(const ::Ice::Current&)
- {
- mService->resume();
- }
-
- virtual void shutdown(const ::Ice::Current&)
- {
- mService->stop();
- }
-
-private:
- BasicRoutingStateReplicatorServicePtr mService;
-};
-
-/**
- * Helper function to add some parameters to one of our registered interfaces in the ServiceLocator, so that
- * other components can look up our interfaces.
- */
-void setCategory(const Discovery::V1::ServiceManagementPrx& serviceManagement,
- const string& category,
- const string& service,
- const string& id="")
-{
- // Add category as a parameter to enable other components look this component up.
- ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams;
- genericparams->category = category;
- genericparams->service = service;
- genericparams->id = id;
- serviceManagement->addLocatorParams(genericparams, "");
-}
-
-/**
- * Register this component's primary public interfaces with the Service Locator.
- * This enables other Asterisk SCF components to locate our interfaces.
- */
-void BasicRoutingStateReplicatorService::registerWithServiceLocator()
-{
- try
- {
- string serviceName = mCommunicator->getProperties()->getPropertyWithDefault(
- mAppName + ".ServiceName", "default");
-
- // Add our ComponentService interface and add it to the Service Locator.
- // Note that this interface has its own adapter.
- string componentServiceGuid(StateReplicatorComponentCategory);
- mComponentServiceManagement = mServiceLocatorManagement->addService(mComponentServicePrx, componentServiceGuid);
- setCategory(mComponentServiceManagement, StateReplicatorComponentCategory, serviceName);
-
- // Add our Replicator interface and add it to the Service Locator.
- mStateReplicationManagement = mServiceLocatorManagement->addService(mStateReplicatorPrx, StateReplicatorDiscoveryCategory);
-
- string replicatorName = mAppName;
- setCategory(mStateReplicationManagement, StateReplicatorDiscoveryCategory, serviceName, replicatorName);
- }
- catch(...)
- {
- lg(Error) << "Exception in " << mAppName << BOOST_CURRENT_FUNCTION;
- throw;
- }
-}
-
-/**
- * Deregister this component's primary public interfaces from the Service Locator.
- * This is done at shutdown, and whenever we want to keep other services from locating
- * our interfaces.
- *
- * @param includeBackplane If true, deregisters our backplane interfaces
- * in addition to all our other interfaces, making this component unreachable from the
- * rest of Asterisk SCF. Should only be done during shutdown.
- */
-void BasicRoutingStateReplicatorService::deregisterFromServiceLocator(bool includeBackplane)
-{
- try
- {
- mStateReplicationManagement->unregister();
-
- if (includeBackplane)
- {
- mComponentServiceManagement->unregister();
- }
- }
- catch(...)
- {
- lg(Error) << "Exception in " << mAppName << BOOST_CURRENT_FUNCTION;
- }
-}
-
-void BasicRoutingStateReplicatorService::initialize(const std::string& appName)
-{
- mAppName = appName;
-
- // This is the primary adapter for this component.
- mServiceAdapter = mCommunicator->createObjectAdapter(mAppName + ".Adapter");
-
- // setup logging client
- mIceLogger = createIceLogger(mServiceAdapter);
- getLoggerFactory().setLogOutput(mIceLogger->getLogger());
-
- // Create and publish our ComponentService interface.
- mComponentServicePrx = ComponentServicePrx::uncheckedCast(
- mServiceAdapter->add(new ComponentServiceImpl(this), mCommunicator->stringToIdentity(ComponentServiceId)));
-
- // Create our instance of the StateReplicator template.
- mStateReplicator = new RoutingStateReplicatorI();
- mStateReplicatorPrx = RoutingStateReplicatorPrx::uncheckedCast(
- mServiceAdapter->add(mStateReplicator, mCommunicator->stringToIdentity(ServiceDiscoveryId)));
-
- // Activate our adapters.
- mServiceAdapter->activate();
-
- // Get a proxy to the management interface for the Service Locator, so we can add
- // ourselves into the system discovery mechanisms.
- mServiceLocatorManagement = ServiceLocatorManagementPrx::checkedCast(mCommunicator->propertyToProxy("LocatorServiceManagement.Proxy"));
-
- if (mServiceLocatorManagement == 0)
- {
- lg(Error) << "Unable to obtain proxy to ServiceLocatorManagement interface. Check config file. " << BOOST_CURRENT_FUNCTION;
- }
-
- mInitialized = true;
-}
-
-void BasicRoutingStateReplicatorService::start(const string &name, const Ice::CommunicatorPtr& ic, const Ice::StringSeq& )
-{
- mCommunicator = ic;
-
- if (!mInitialized)
- {
- initialize(name);
- }
- else
- {
- mServiceAdapter->activate();
- }
-
- // Plug into the Asterisk SCF discovery system so that the interfaces we provide
- // can be located.
- registerWithServiceLocator();
-
- mRunning = true;
-}
-
-void BasicRoutingStateReplicatorService::resume()
-{
- if (!mRunning)
- {
- mServiceAdapter->add(mStateReplicator, mCommunicator->stringToIdentity(ServiceDiscoveryId));
-
- // Plug back into the Asterisk SCF discovery system so that the interfaces we provide
- // can be located.
- registerWithServiceLocator();
-
- // Reactivate the primary adapter.
- mServiceAdapter->activate();
- }
-
- mRunning = true;
-}
-
-/**
- * Utility function to suspend the service for a suspend() or stop().
- */
-void BasicRoutingStateReplicatorService::suspendService(bool shuttingDown)
-{
- if (mRunning)
- {
- // Deregister our servants.
- deregisterFromServiceLocator(shuttingDown);
-
- // Deactive the primary adapter.
- // The adapter that services the ComponentService stays active.
- mServiceAdapter->deactivate();
- }
-
- mRunning = false;
-}
-
-/**
- * Handle a notice from the ComponentService.
- */
-void BasicRoutingStateReplicatorService::suspend()
-{
- lg(Info) << "Suspending...";
-
- suspendService(false);
-
- lg(Info) << "Suspended.";
-}
-
-/**
- * Implementation of the required IceBox::Service stop method.
- */
-void BasicRoutingStateReplicatorService::stop()
-{
- lg(Info) << "Stopping...";
-
- suspendService(true);
-
- // Just in case we were in suspend() mode when told to stop.
- mComponentServiceManagement->unregister();
-
-
- lg(Info) << "Stopped.";
-}
-
-extern "C"
-{
-ASTSCF_DLL_EXPORT IceBox::Service* create(Ice::CommunicatorPtr )
-{
- return new BasicRoutingStateReplicatorService;
-}
-}
-
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 64fbf5f..750fbb0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -45,10 +45,10 @@ endif()
astscf_component_install(BasicRoutingService)
astscf_component_init(BasicRoutingStateReplicator)
-astscf_component_add_files(BasicRoutingStateReplicator BasicRoutingStateReplicatorApp.cpp)
+astscf_component_add_files(BasicRoutingStateReplicator ComponentStateReplicator.cpp)
astscf_component_add_slices(BasicRoutingStateReplicator PROJECT AsteriskSCF/Replication/BasicRoutingService/BasicRoutingStateReplicationIf.ice)
astscf_component_add_ice_libraries(BasicRoutingStateReplicator IceStorm)
astscf_component_add_slice_collection_libraries(BasicRoutingStateReplicator ASTSCF)
astscf_component_build_icebox(BasicRoutingStateReplicator)
-target_link_libraries(BasicRoutingStateReplicator LoggingClient)
+target_link_libraries(BasicRoutingStateReplicator LoggingClient ASTSCFIceUtilCpp)
astscf_component_install(BasicRoutingStateReplicator)
diff --git a/src/ComponentStateReplicator.cpp b/src/ComponentStateReplicator.cpp
new file mode 100644
index 0000000..e96d90e
--- /dev/null
+++ b/src/ComponentStateReplicator.cpp
@@ -0,0 +1,125 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#include <Ice/Ice.h>
+#include <IceUtil/UUID.h>
+#include <IceStorm/IceStorm.h>
+#include <IceBox/IceBox.h>
+
+#include <AsteriskSCF/Component/ComponentStateReplicator.h>
+#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Replication/StateReplicator.h>
+#include "BasicRoutingStateReplicationIf.h"
+
+using namespace std;
+using namespace AsteriskSCF::Core;
+using namespace AsteriskSCF::Core::Discovery::V1;
+using namespace AsteriskSCF::System::Component::V1;
+using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::Replication::BasicRoutingService::V1;
+using namespace AsteriskSCF::Discovery;
+
+namespace
+{
+Logger lg = getLoggerFactory().getLogger("AsteriskSCF.BasicRoutingServiceStateReplicator");
+}
+
+namespace AsteriskSCF
+{
+namespace BasicRoutingService
+{
+
+typedef AsteriskSCF::Replication::StateReplicator< RoutingStateReplicator,
+ RoutingStateItemPtr,
+ std::string,
+ RoutingStateReplicatorListenerPrx> RoutingStateReplicatorI;
+typedef IceUtil::Handle<RoutingStateReplicatorI> RoutingStateReplicatorIPtr;
+
+};
+};
+
+/**
+ * This class implements a very simplistic replication capability using the StateReplicator template.
+ */
+class ComponentStateReplicator : public AsteriskSCF::Component::ComponentStateReplicator
+{
+public:
+ ComponentStateReplicator() :
+ AsteriskSCF::Component::ComponentStateReplicator(lg,
+ AsteriskSCF::Replication::BasicRoutingService::V1::StateReplicatorComponentCategory,
+ false)
+ {
+ }
+
+ ~ComponentStateReplicator() {};
+
+ ///////////////////////////////////////////////////
+ // Required overrides
+
+ void createPrimaryServices();
+ void preparePrimaryServicesForDiscovery();
+
+private:
+ AsteriskSCF::BasicRoutingService::RoutingStateReplicatorIPtr mStateReplicator;
+ RoutingStateReplicatorPrx mStateReplicatorPrx;
+ LocatorRegistrationWrapperPtr mStateReplicatorRegistration;
+};
+
+static const string ServiceDiscoveryId("BasicRoutingStateReplicatorService");
+
+/**
+ * Register this component's primary public interfaces with the Service Locator.
+ * This enables other Asterisk SCF components to locate our interfaces.
+ */
+void ComponentStateReplicator::preparePrimaryServicesForDiscovery()
+{
+ try
+ {
+ // Wrap our replicator interface for the Service Locator.
+ mStateReplicatorRegistration = wrapServiceForRegistration(mStateReplicatorPrx,
+ StateReplicatorDiscoveryCategory);
+ managePrimaryService(mStateReplicatorRegistration);
+ }
+ catch(const std::exception& e)
+ {
+ lg(Error) << "Unable to publish component interfaces in " << getName() << BOOST_CURRENT_FUNCTION <<
+ ". Exception: " << e.what();
+ throw; // rethrow
+ }
+}
+
+void ComponentStateReplicator::createPrimaryServices()
+{
+ // Create our instance of the StateReplicator template.
+ mStateReplicator = new AsteriskSCF::BasicRoutingService::RoutingStateReplicatorI;
+ mStateReplicatorPrx = RoutingStateReplicatorPrx::uncheckedCast(
+ getServiceAdapter()->add(mStateReplicator, getCommunicator()->stringToIdentity(ServiceDiscoveryId)));
+
+ assert(mStateReplicatorPrx != 0);
+ if(mStateReplicatorPrx == 0)
+ {
+ throw IceBox::FailureException(__FILE__, __LINE__, "Unable to instantiate routing replicator object");
+ }
+}
+
+extern "C"
+{
+ASTSCF_DLL_EXPORT IceBox::Service* create(Ice::CommunicatorPtr )
+{
+ return new ComponentStateReplicator;
+}
+}
+
-----------------------------------------------------------------------
--
asterisk-scf/integration/routing.git
More information about the asterisk-scf-commits
mailing list