[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "bridge-replication" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Apr 5 09:26:40 CDT 2011


branch "bridge-replication" has been updated
       via  504ababbd67d5a477d145b5f363654ca10b086a1 (commit)
      from  007048196f9c9f1f19f35126961804a9928e4312 (commit)

Summary of changes:
 config/test_bridging.conf.in |  141 +++++++++++++++++++++++++++++++++++++----
 src/BridgeImpl.cpp           |   11 +---
 src/BridgeImpl.h             |    2 +-
 src/BridgeManagerImpl.cpp    |    9 ---
 src/CMakeLists.txt           |    2 +
 src/Service.cpp              |   21 ++++---
 src/ServiceUtil.h            |   39 +++++++++---
 7 files changed, 175 insertions(+), 50 deletions(-)


- Log -----------------------------------------------------------------
commit 504ababbd67d5a477d145b5f363654ca10b086a1
Author: Brent Eagles <beagles at digium.com>
Date:   Tue Apr 5 11:56:25 2011 -0230

    Respond to review feedback

diff --git a/config/test_bridging.conf.in b/config/test_bridging.conf.in
index 461f245..47fd93f 100644
--- a/config/test_bridging.conf.in
+++ b/config/test_bridging.conf.in
@@ -1,28 +1,115 @@
+################################################################################
+# Configuration file for use with the bridging component's test driver.
+#
+#
+# General configuration
+#
+# We turn off all collocation optimization by default to avoid issues with any services
+# that might have trouble due to AMI/AMD usage.
+#
+Ice.Default.CollocationOptimized=0
+
+#
+# We use a single file for configuration.
+#
+IceBox.InheritProperties=1
+
+################################################################################
+# The following configuration is required for the the Service Locator component
+# because it loads a collocated instance of IceStorm.
+#
+#
+# We register services with names to help identify them within an IceBox instance.
+# It also helps with identifying properties in a configuration file as each
+# property that is specific to this service will be prefixed with
+# AsteriskSCFIceStorm.
+#
 AsteriskSCFIceStorm.InstanceName=AsteriskSCFIceStorm
-AsteriskSCFIceStorm.TopicManager.Endpoints=default -p 55555
+
+
+#
+# Configure the IceStorm TopicManager's object adapter.
+#
+AsteriskSCFIceStorm.TopicManager.Endpoints=default -p 10000
 AsteriskSCFIceStorm.TopicManager.ThreadPool.Size=4
-AsteriskSCFIceStorm.Publish.Endpoints=default -p 55556
+
+#
+# Configure the IceStorm publisher object adapter.
+#
+AsteriskSCFIceStorm.Publish.Endpoints=tcp -p 10001:udp -p 10001
 AsteriskSCFIceStorm.Publish.ThreadPool.Size=4
+
+#
+# This IceStorm instance will not need to persist subscriber/publisher
+# information across process lifetimes.
+# 
 AsteriskSCFIceStorm.Transient=1
-TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:default -p 55555
 
+#
+# Control TopicManager tracing.
+#
+# 0 = no tracing
+# 1 = trace topic creation, subscription, unsubscription
+# 2 = like 1, but with more detailed subscription information
+# 
+AsteriskSCFIceStorm.Trace.TopicManager=0
+
+#
+# Flush interval in case any any subscribers have subscribed
+# using a batched oneway proxy. (Default is currently 1000ms)
+#
+AsteriskSCFIceStorm.Flush.Timeout=2000
+
+#
+# Finally the proxy that can be used to access this IceStorm instance.
+#
+TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:default -p 10000
+
+#
+# Logger service configuration. Proxies to the logger service
+# are obtained through the service locator so specifying a port
+# number is not required.
+#
 LoggerAdapter.Endpoints=default
 AsteriskSCF.LoggingService.Endpoints=default
 AsteriskSCF.LoggingService.ThreadPool.Size=4
 AsteriskSCF.LoggingClient.Endpoints=default
 AsteriskSCF.LoggingClient.ThreadPool.Size=4
+
+#
+# The bridging service uses the test channel`s Endpoint
+# to create test sessions and register them with the bridge.
+# NOTE: this will be changed to be accessible through
+# service discovery in a later branch.
+#
 AsteriskSCF.TestChannelService.Endpoints=default -p 55560
 AsteriskSCF.TestChannelService.ThreadPool.Size=4
+TestChannel.Proxy=TestChannel:default -p 55560
 
-
-ServiceLocatorManagementAdapter.Endpoints=tcp -p 55557
-ServiceLocatorManagementAdapter.ThreadPool.Size=4
-ServiceLocatorAdapter.Endpoints=tcp -p 55558
+#
+# Service Locator configuration. Usually the service locator
+# and it`s collocated IceStorm instance are the only services
+# that need to have their ports specified. The service locator
+# instantiates two adapters:
+# * The ServiceLocatorAdapter which hosts the servants that implement
+#   the lookup queries for clients wishing to obtain proxies to services.
+# * The ServiceLocatorManagerAdapter which hosts the servants for the
+#   objects that implement the registration management for services
+#
+ServiceLocatorAdapter.Endpoints=tcp -p 4411
 ServiceLocatorAdapter.ThreadPool.Size=4
-LocatorService.Proxy=LocatorService:default -p 55558
-ServiceLocatorManagementProxy=LocatorServiceManagement:tcp -p 55557
+ServiceLocatorManagementAdapter.Endpoints=tcp -p 4422
+ServiceLocatorManagementAdapter.ThreadPool.Size=4
 
-IceBox.InheritProperties=1
+#
+# The proxies that clients use to access the Service Locator facilities.
+#
+LocatorService.Proxy=LocatorService:default -p 4411
+ServiceLocatorManagementProxy=LocatorServiceManagement:tcp -p 4422
+
+#
+# The IceBox entries for loading the services.
+#
 IceBox.Service.Logger=${logger_bindir}/server/src at logging-service:createLoggingService
 IceBox.Service.Replicator=../src at BridgeReplicator:create
 IceBox.Service.TestBridge=../src at bridgeservice:create
@@ -30,7 +117,13 @@ IceBox.Service.TestBridge2=../src/@bridgeservice:create
 IceBox.Service.TestServiceLocator=${service_locator_bindir}/src at service_locator:create
 IceBox.Service.TestChannel=${test_channel_bindir}/src at test_channel:create
 IceBox.Service.TestDriver=../test at bridge_component_test:create
- 
+
+#
+# Configuration for the test bridge instances. There are are two: one master
+# (TestBridge) and one standby (TestBridge2).
+# NOTE: These will be changed to be accessible through
+# service discovery in a later branch.
+#
 TestBridge.InstanceName=TestBridge
 TestBridge.BridgeService.Endpoints=default -p 55561
 TestBridge.BridgeService.ThreadPool.Size=4
@@ -46,18 +139,38 @@ TestBridge2.BridgeServiceInternal.Endpoints=default -p 65462
 TestBridge2.BridgeServiceInternal.ThreadPool.Size=4
 TestBridge2.StateReplicatorListener=yes
 
+#
+# Configuration for the bridge state replicator.
+# NOTE: This will be changed to only use service discovery in the a later
+# branch (i.e. it will not be necessary to configure the object adapter
+# or specify the proxy in the future)
+# 
 Replicator.InstanceName=Replicator
 Replicator.BridgeReplicator.Endpoints=default -p 63242
-Replciator.Proxy=BridgeReplicator:default -p 63242
+Replicator.Proxy=BridgeReplicator:default -p 63242
 Replicator.BridgeReplicator.ThreadPool.Size=4
 
-TestChannel.Proxy=TestChannel:default -p 55560
-TestUtilAdapter.Endpoints=default -p 55562
+#
+# Configure the test's internal object adapter.
+# NOTE: This will not be required in the future.
+#
+TestUtilAdapter.Endpoints=default
 TestUtilAdapter.ThreadPool.Size=4
 Commands.Proxy=TestChannel.Locator.Commands:default -p 55560
 
+#
+# Some IceBox configuration.
+#
+#
+# Multiple services are loaded in the single IceBox instance. It is necessary to have
+# them start in a specific order so dependencies are available when they are needed.
+#
 IceBox.LoadOrder=TestServiceLocator Logger Replicator TestBridge TestBridge2 TestChannel TestDriver
 
+#
+# Configuring a manager endpoint for the IceBox service allows services to be managed and
+# monitored.
+#
 IceBox.ServiceManager.Endpoints=default -p 56000
 IceBox.ServiceManager.ThreadPool.Size=4
 IceBoxMgr.Proxy=IceBox/ServiceManager:default -p 56000
diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index 4dd7969..acc4410 100644
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -1,7 +1,7 @@
 /*
  * Asterisk SCF -- An open-source communications framework.
  *
- * Copyright (C) 2010, Digium, Inc.
+ * Copyright (C) 2010-2011, Digium, Inc.
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk SCF project. Please do not directly contact
@@ -186,11 +186,6 @@ static void checkSessions(const SessionSeq& sessions)
     }
 }
 
-//
-// Compiled in constants.
-//
-static const string TopicPrefix("AsteriskSCF.Bridge.");
-
 } // End of anonymous namespace
 
 BridgeImpl::BridgeImpl(const string& name, const Ice::ObjectAdapterPtr& adapter, 
@@ -288,7 +283,7 @@ void BridgeImpl::addSessions(const SessionSeq& sessions, const Ice::Current& cur
                 }
             }
         }
-        catch (const Ice::Exception& ex)
+        catch (const Ice::Exception&)
         {
         }
     }
@@ -583,7 +578,7 @@ void BridgeImpl::replaceSession(const SessionPrx& oldSession, const SessionSeq&
 bool BridgeImpl::destroyed()
 {
     boost::shared_lock<boost::shared_mutex> lock(mLock);
-    mLogger(Debug) << FUNLOG << ": " << (mState == Destroyed ? "yes, I am destroyed." : "no, I am not destroyed") ;
+    mLogger(Debug) << FUNLOG << ": " << (mState->runningState == Destroyed ? "yes, I am destroyed." : "no, I am not destroyed") ;
     return mState->runningState == Destroyed;
 }
 
diff --git a/src/BridgeImpl.h b/src/BridgeImpl.h
index a87acd6..811a8ce 100644
--- a/src/BridgeImpl.h
+++ b/src/BridgeImpl.h
@@ -1,7 +1,7 @@
 /*
  * Asterisk SCF -- An open-source communications framework.
  *
- * Copyright (C) 2010, Digium, Inc.
+ * Copyright (C) 2010-2011, Digium, Inc.
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk SCF project. Please do not directly contact
diff --git a/src/BridgeManagerImpl.cpp b/src/BridgeManagerImpl.cpp
index a78c3d9..2e8bcd9 100644
--- a/src/BridgeManagerImpl.cpp
+++ b/src/BridgeManagerImpl.cpp
@@ -37,15 +37,6 @@ using namespace AsteriskSCF::BridgeService;
 using namespace AsteriskSCF::Bridge::V1;
 using namespace std;
 
-//
-// Compiled in constants.
-//
-// Note: It's not clear that being able to configure the prefix is all that
-// important.  No doubt somebody will want to do it, but the idea is that it
-// makes it easy to identify what an IceStorm topic is for.
-//
-static const string TopicPrefix("AsteriskSCF.BridgeManager.");
-
 namespace 
 {
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f9b39d1..1da4fa2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -19,6 +19,8 @@ asterisk_scf_component_add_file(bridgeservice SessionCollection.cpp)
 asterisk_scf_component_add_file(bridgeservice SessionCollection.h)
 asterisk_scf_component_add_file(bridgeservice SessionOperations.cpp)
 asterisk_scf_component_add_file(bridgeservice SessionOperations.h)
+asterisk_scf_component_add_file(bridgeservice ServiceUtil.h)
+asterisk_scf_component_add_file(bridgeservice DebugUtil.h)
 asterisk_scf_component_add_file(bridgeservice MediaSplicer.h)
 asterisk_scf_component_add_file(bridgeservice MediaSplicer.cpp)
 asterisk_scf_component_add_slice(bridgeservice ./BridgeReplicatorIf.ice)
diff --git a/src/Service.cpp b/src/Service.cpp
index 660f18b..42fd326 100644
--- a/src/Service.cpp
+++ b/src/Service.cpp
@@ -1,7 +1,7 @@
 /*
  * Asterisk SCF -- An open-source communications framework.
  *
- * Copyright (C) 2010, Digium, Inc.
+ * Copyright (C) 2010-2011, Digium, Inc.
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk SCF project. Please do not directly contact
@@ -39,15 +39,14 @@ using namespace std;
 namespace
 {
 
-static const string BridgeReplicaId("BridgeChannelReplica");
-
 class ReplicaControl : virtual public Replica
 {
 public:
-    ReplicaControl(const Ice::ObjectAdapterPtr& adapter, const BridgeManagerServantPtr& manager) :
+    ReplicaControl(const Ice::ObjectAdapterPtr& adapter, const BridgeManagerServantPtr& manager, const string& id) :
         mActive(true),
         mAdapter(adapter),
-        mManager(manager)
+        mManager(manager),
+        mReplicaId(id)
     {
     }
 
@@ -62,7 +61,7 @@ public:
         mManager->activate();
         for (vector<ReplicaListenerPrx>::const_iterator i = mListeners.begin(); i != mListeners.end(); ++i)
         {
-            (*i)->activated(ReplicaPrx::uncheckedCast(mAdapter->createDirectProxy(mAdapter->getCommunicator()->stringToIdentity(BridgeReplicaId))));
+            (*i)->activated(ReplicaPrx::uncheckedCast(mAdapter->createDirectProxy(mAdapter->getCommunicator()->stringToIdentity(mReplicaId))));
         }
         return true;
     }
@@ -72,7 +71,7 @@ public:
         mActive = false;
         for (vector<ReplicaListenerPrx>::const_iterator i = mListeners.begin(); i != mListeners.end(); ++i)
         {
-            (*i)->onStandby(ReplicaPrx::uncheckedCast(mAdapter->createDirectProxy(mAdapter->getCommunicator()->stringToIdentity(BridgeReplicaId))));
+            (*i)->onStandby(ReplicaPrx::uncheckedCast(mAdapter->createDirectProxy(mAdapter->getCommunicator()->stringToIdentity(mReplicaId))));
         }
     }
 
@@ -91,6 +90,7 @@ private:
     Ice::ObjectAdapterPtr mAdapter;
     vector<ReplicaListenerPrx> mListeners;
     BridgeManagerServantPtr mManager;
+    string mReplicaId;
 };
 typedef IceUtil::Handle<ReplicaControl> ReplicaControlPtr;
 
@@ -206,9 +206,12 @@ void BridgingApp::start(const std::string& name, const Ice::CommunicatorPtr& com
     ReplicatorListenerPtr replicaListener = createStateListener(logger, manager);
     ReplicatorListenerPrx listenerPrx = ReplicatorListenerPrx::uncheckedCast(mInfrastructureAdapter->addWithUUID(replicaListener));
 
-    mReplicaControl = new ReplicaControl(mInfrastructureAdapter, manager);
+    string replicaId = 
+        mAdapter->getCommunicator()->getProperties()->getPropertyWithDefault(
+            adapterName + ".ReplicaId", "BridgeReplica");
+    mReplicaControl = new ReplicaControl(mInfrastructureAdapter, manager, replicaId);
     ReplicaPrx replicaControlPrx =
-        ReplicaPrx::uncheckedCast(mInfrastructureAdapter->add(mReplicaControl, communicator->stringToIdentity(BridgeReplicaId)));
+        ReplicaPrx::uncheckedCast(mInfrastructureAdapter->add(mReplicaControl, communicator->stringToIdentity(replicaId)));
 
     bool onStandby = false;
     if (replicator)
diff --git a/src/ServiceUtil.h b/src/ServiceUtil.h
index 36610b9..d59ae11 100644
--- a/src/ServiceUtil.h
+++ b/src/ServiceUtil.h
@@ -78,7 +78,8 @@ public:
 private:
 
     //
-    // TODO: boost?
+    // This template doesn't use boost locking simply because it already has a physical dependency
+    // to Ice runtime, so avoiding adding a second seemed reasonable.
     //
     IceUtil::Mutex mLock;
     Ice::CommunicatorPtr mCommunicator;
@@ -95,9 +96,17 @@ template <class T>
 class RegisterThread : public IceUtil::Thread
 {
 public:
+    RegisterThread(const IceUtil::Handle<LocatorRegistrationWrapper<T> >& registration, const IceUtil::Time& retryInterval) :
+        mRegistration(registration),
+        mStopped(false),
+        mRetryInterval(retryInterval)
+    {
+    }
+
     RegisterThread(const IceUtil::Handle<LocatorRegistrationWrapper<T> >& registration) :
         mRegistration(registration),
-        mStopped(false)
+        mStopped(false),
+        mRetryInterval(IceUtil::Time::seconds(15))
     {
     }
 
@@ -107,10 +116,7 @@ public:
         IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mMonitor);
         do
         {
-            //
-            // TODO: Make configurable.
-            //
-            mMonitor.timedWait(IceUtil::Time::seconds(15));
+            mMonitor.timedWait(mRetryInterval);
             if(mStopped)
             {
                 break;
@@ -136,6 +142,7 @@ public:
 private:
     IceUtil::Monitor<IceUtil::Mutex> mMonitor;
     IceUtil::Handle<LocatorRegistrationWrapper<T> > mRegistration;
+    IceUtil::Time mRetryInterval;
     bool mStopped;
 };
 
@@ -145,9 +152,23 @@ private:
 class RetryPolicy
 {
 public:
+    //
+    // The constructor for those that want to specify intervals in milliseconds.
+    //
     RetryPolicy(size_t maxRetries, size_t intervalInMilliseconds) :
         mMaxRetries(maxRetries),
-        mRetryInterval(intervalInMilliseconds),
+        mRetryInterval(IceUtil::Time::milliSeconds(intervalInMilliseconds)),
+        mCounter(0)
+    {
+    }
+
+    //
+    // The constructor for those that want to specify intervals in whatever
+    // unit they like so long as it is converted to IceUtil::Time.
+    //
+    RetryPolicy(size_t maxRetries, const IceUtil::Time& interval) :
+        mMaxRetries(maxRetries),
+        mRetryInterval(interval),
         mCounter(0)
     {
     }
@@ -159,14 +180,14 @@ public:
 
     bool retry()
     {
-        IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(mRetryInterval));
+        IceUtil::ThreadControl::sleep(mRetryInterval);
         ++mCounter;
         return canRetry();
     }
 
 private:
     size_t mMaxRetries;
-    size_t mRetryInterval;
+    IceUtil::Time mRetryInterval;
     size_t mCounter;
 };
 

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


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list