[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "sessionparty" created.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Aug 23 18:50:04 CDT 2011
branch "sessionparty" has been created
at 60837c2a1ce92144511988ef9c0ac8ae9c721aac (commit)
- Log -----------------------------------------------------------------
commit 60837c2a1ce92144511988ef9c0ac8ae9c721aac
Author: Ken Hunt <ken.hunt at digium.com>
Date: Tue Aug 23 18:48:26 2011 -0500
Cleanup of replication context initialization. Starts up cleaner in Standalone mode.
diff --git a/config/bridging.conf b/config/bridging.conf
index 95e9796..dfc42d5 100644
--- a/config/bridging.conf
+++ b/config/bridging.conf
@@ -1,4 +1,5 @@
-# This is a configuration file used in conjunction with the ulaw media format test driver
+# This is a configuration file used in conjunction with the bridge service.
+Ice.Warn.UnknownProperties=0
# Adapter parameters for this component
BridgeManager.BridgeService.Endpoints=default
@@ -12,3 +13,7 @@ LocatorService.Proxy=LocatorService:tcp -p 4411
TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:default -p 10000
IceBox.InheritProperties=1
IceBox.Service.BridgeManager=bridgeservice:create
+
+# For testing without replication...
+BridgeManager.Standalone=true
+
diff --git a/src/BridgeReplicationContext.h b/src/BridgeReplicationContext.h
index 8959336..5a375de 100644
--- a/src/BridgeReplicationContext.h
+++ b/src/BridgeReplicationContext.h
@@ -33,30 +33,33 @@ namespace BridgeService
class BridgeReplicationContext : public AsteriskSCF::Replication::ReplicationContext
{
public:
- BridgeReplicationContext(AsteriskSCF::Replication::ReplicationStateType state,
- const ReplicatorSmartPrx& bridgeReplicator) :
- ReplicationContext(state),
- mBridgeReplicator(bridgeReplicator)
+ BridgeReplicationContext(AsteriskSCF::Replication::ReplicationStateType state) :
+ ReplicationContext(state)
{
}
// Override
- virtual bool isReplicating()
- {
- // If the base context says we aren't replicating, we aren't.
- if (!ReplicationContext::isReplicating())
- {
- return false;
- }
+ virtual bool isReplicating()
+ {
+ // If the base context says we aren't replicating, we aren't.
+ if (!ReplicationContext::isReplicating())
+ {
+ return false;
+ }
+
+ // Do we have a replicator proxy?
+ if (mBridgeReplicator.isInitialized())
+ {
+ return true;
+ }
- // Do we have a replicator proxy?
- if (mBridgeReplicator.isInitialized())
- {
- return true;
- }
+ return false;
+ }
- return false;
- }
+ void setReplicator(const ReplicatorSmartPrx& bridgeReplicator)
+ {
+ mBridgeReplicator = bridgeReplicator;
+ }
ReplicatorSmartPrx getReplicator() {return mBridgeReplicator;}
diff --git a/src/Component.cpp b/src/Component.cpp
index dbe7194..e9a4a3e 100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@ -70,7 +70,7 @@ private:
virtual void createReplicationStateListeners();
virtual void stopListeningToStateReplicators();
virtual void listenToStateReplicators();
- virtual void findRemoteServices() {}; // N/A
+ virtual void findRemoteServices();
// Other base Component overrides
virtual ReplicationContextPtr createReplicationContext(ReplicationStateType state);
@@ -91,24 +91,7 @@ private:
*/
ReplicationContextPtr Component::createReplicationContext(ReplicationStateType state)
{
- // Find our state replicator.
- ServiceLocatorParamsPtr searchParams = new ServiceLocatorParams;
- searchParams->category = StateReplicatorDiscoveryCategory;
- searchParams->service = getCommunicator()->getProperties()->getPropertyWithDefault(
- "Bridge.StateReplicatorService", "default");
- searchParams->id = getCommunicator()->getProperties()->getProperty("Bridge.StateReplicatorId");
-
- ReplicatorSmartPrx replicator;
- try
- {
- replicator = ReplicatorSmartPrx(getServiceLocator(), searchParams, lg);
- }
- catch (const std::exception& ex)
- {
- lg(Error) << "Bridge state replicator lookup failed. Continuing without replication. " << ex.what();
- }
-
- BridgeReplicationContextPtr context(new BridgeReplicationContext(state, replicator));
+ BridgeReplicationContextPtr context(new BridgeReplicationContext(state));
return context;
}
@@ -210,6 +193,37 @@ void Component::listenToStateReplicators()
}
}
+/**
+ * Locate services we depend on.
+ */
+void Component::findRemoteServices()
+{
+ if (getReplicationContext()->getState() == ACTIVE_STANDALONE)
+ {
+ return;
+ }
+
+ // Find our state replicator.
+ ServiceLocatorParamsPtr searchParams = new ServiceLocatorParams;
+ searchParams->category = StateReplicatorDiscoveryCategory;
+ searchParams->service = getCommunicator()->getProperties()->getPropertyWithDefault(
+ "Bridge.StateReplicatorService", "default");
+ searchParams->id = getCommunicator()->getProperties()->getProperty("Bridge.StateReplicatorId");
+
+ try
+ {
+ BridgeReplicationContextPtr bridgingReplicationContext =
+ boost::static_pointer_cast<BridgeReplicationContext>(getReplicationContext());
+
+ ReplicatorSmartPrx replicator = ReplicatorSmartPrx(getServiceLocator(), searchParams, lg);
+ bridgingReplicationContext->setReplicator(replicator);
+ }
+ catch (const std::exception& ex)
+ {
+ lg(Error) << getName() << ": StateReplicator not found. Check configuration. Continuing without replication.";
+ }
+}
+
void Component::stopListeningToStateReplicators()
{
boost::unique_lock<boost::shared_mutex> lock(mReplicatorLock);
-----------------------------------------------------------------------
--
asterisk-scf/integration/bridging.git
More information about the asterisk-scf-commits
mailing list