[hydra-commits] hydra/bridging.git branch "master" updated.

Commits to the Hydra project code repositories hydra-commits at lists.digium.com
Tue Aug 10 12:52:00 CDT 2010


branch "master" has been updated
       via  87557838c93f3790702ff79bdbf2e2a43a7ea6e3 (commit)
       via  15c525b571a0a2f2a0194a5cc1ea86436acc5ec4 (commit)
      from  1e9815d515ade27c93532a6f997208fe83bf252e (commit)

Summary of changes:
 src/BridgeImpl.cpp    |   39 ++++++++++++++++++------
 src/BridgeImpl.h      |    3 +-
 test/TestBridging.cpp |   78 ++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 107 insertions(+), 13 deletions(-)


- Log -----------------------------------------------------------------
commit 87557838c93f3790702ff79bdbf2e2a43a7ea6e3
Author: Brent Eagles <beagles at digium.com>
Date:   Tue Aug 10 15:19:53 2010 -0230

    Add a test for monitor code calls.

diff --git a/test/TestBridging.cpp b/test/TestBridging.cpp
index dd61012..251f812 100644
--- a/test/TestBridging.cpp
+++ b/test/TestBridging.cpp
@@ -81,6 +81,45 @@ private:
 
 typedef IceUtil::Handle<BridgeEventSubscriberI> BridgeEventSubscriberIPtr;
 
+class BridgeMonitorI : public Hydra::Core::Bridging::V1::BridgeMonitor
+{
+public:
+    bool onAddEndpoint(const Hydra::Core::Endpoint::V1::BaseEndpointPtr& e, const Ice::Current&)
+    {
+        return true;
+    }
+
+    bool onRemoveEndpoint(const Hydra::Core::Endpoint::V1::BaseEndpointPtr& e, const Ice::Current&)
+    {
+        return true;
+    }
+
+    bool onListEndpoints(const Hydra::Core::Endpoint::V1::EndpointSeq& eps, Hydra::Core::Endpoint::V1::EndpointSeq& result, const Ice::Current&)
+    {
+        result = eps;
+        result.erase(result.begin());
+        return true;
+    }
+
+    bool onShutdown(const Ice::Current&)
+    {
+        return true;
+    }
+
+    bool onShutdownComplete(const Ice::Current&)
+    {
+        return true;
+    }
+
+    bool onDestroy(const Ice::Current&)
+    {
+        return true;
+    }
+};
+
+typedef IceUtil::Handle<BridgeMonitorI> BridgeMonitorPtr;
+
+
 static ArgCacheType mCachedArgs;
 
 /**
@@ -1446,7 +1485,6 @@ BOOST_AUTO_TEST_CASE(BridgeEvents)
     Ice::InitializationData initData;
     initData.properties = Ice::createProperties(0);
     initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
-    initData.properties->setProperty("TestBridgeEvents.Endpoints", "default -p 33334 -t 1000");
     Ice::CommunicatorPtr comm = Ice::initialize(initData);
     Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
     BridgeEventSubscriberIPtr subServant(new BridgeEventSubscriberI);
@@ -1480,3 +1518,41 @@ BOOST_AUTO_TEST_CASE(BridgeEvents)
     }
     adapter->destroy();
 }
+
+BOOST_AUTO_TEST_CASE(BridgeMonitor)
+{
+    Ice::InitializationData initData;
+    initData.properties = Ice::createProperties(0);
+    initData.properties->setProperty("TestBridging.Endpoints", "default -p 33333 -t 1000");
+    Ice::CommunicatorPtr comm = Ice::initialize(initData);
+    Ice::ObjectAdapterPtr adapter = comm->createObjectAdapter("TestBridging");
+    BridgeMonitorPtr monitor(new BridgeMonitorI);
+    Ice::ObjectPrx obj = adapter->addWithUUID(monitor);
+    Hydra::Core::Bridging::V1::BridgeMonitorPrx monitorPrx = Hydra::Core::Bridging::V1::BridgeMonitorPrx::checkedCast(obj);
+   
+    Ice::Current dummy;
+    dummy.adapter = adapter;
+    dummy.id = comm->stringToIdentity("testobject");
+    try
+    {
+        Hydra::BridgeService::BridgeFactoryImplPtr factoryServant(new Hydra::BridgeService::BridgeFactoryImpl(adapter, 0));
+        obj = adapter->addWithUUID(factoryServant);
+        Hydra::Core::Bridging::V1::BridgeFactoryPrx factory(Hydra::Core::Bridging::V1::BridgeFactoryPrx::checkedCast(obj));
+        Hydra::Core::Bridging::V1::BridgePrx bridge = factory->createBridge(0, Hydra::Core::Endpoint::V1::EndpointSeq(), monitorPrx);
+        Hydra::Session::V1::SessionEndpointPtr p(new Hydra::Session::V1::SessionEndpoint);
+        p->id = new Hydra::Core::Endpoint::V1::EndpointId;
+        p->id->endpointManagerId = "foo";
+        p->id->deviceId = "bar";
+        bridge->addEndpoint(p);
+        bridge->removeEndpoint(p->id);
+        bridge->shutdown();
+        bridge = factory->createBridge(0, Hydra::Core::Endpoint::V1::EndpointSeq(), monitorPrx);
+        bridge->destroy();
+    }
+    catch(...)
+    {
+        adapter->destroy();
+        throw;
+    }
+    adapter->destroy();
+}

commit 15c525b571a0a2f2a0194a5cc1ea86436acc5ec4
Author: Brent Eagles <beagles at digium.com>
Date:   Tue Aug 10 14:53:04 2010 -0230

    Add monitor calls

diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index 0c30c0f..356e7c6 100644
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -126,7 +126,7 @@ Hydra::BridgeService::BridgeImpl::BridgeImpl(
     mState(Running),
     mAdminEndpoint(adminEp),
     mEndpoints(initialEndpoints),
-    mManager(manager),
+    mMonitor(manager),
     mEvents(new Hydra::BridgeService::EventTopicWrapper(ev)),
     mAdminEndpointInList(true)
 {
@@ -162,6 +162,11 @@ void Hydra::BridgeService::BridgeImpl::addEndpoint(const Hydra::Core::Endpoint::
         throw Hydra::Core::Bridging::V1::EndpointAlreadyRegistered(ep->id);
     }
 
+    if(mMonitor)
+    {
+        bool result = mMonitor->onAddEndpoint(ep);
+        mLogger.getDebugStream() << __FUNCTION__ << "onAddEndpoint() returned " << result << std::endl;
+    }
     //
     // It's hear that the media operations will be calculated and the media allocator accessed for building the media operations for
     // the bridge.
@@ -191,16 +196,10 @@ void Hydra::BridgeService::BridgeImpl::removeEndpoint(const Hydra::Core::Endpoin
         throw Hydra::Core::Bridging::V1::UnknownEndpoint(ep);
     }
 
-    if(mManager && !mManager->onRemoveEndpoint(*i))
+    if(mMonitor)
     {
-        mLogger.getDebugStream() << __FUNCTION__ << ": bridge monitor rejects removal of endpoint with id " << ep->endpointManagerId << ":" << ep->deviceId << "." << std::endl;
-        //
-        // TODO: This seems unlikely to be correct. Either some kind of
-        // exception needs to be thrown or this kind of thing should not be
-        // allowed.  Silently doing nothing is likely to cause all sorts of
-        // confusion.
-        //
-        return;
+        bool result =  mMonitor->onRemoveEndpoint(*i);
+        mLogger.getDebugStream() << __FUNCTION__ << "onRemoveEndpoint() returned " << result << std::endl;
     }
     mEvents->endpointRemoved(*i);
     mEndpoints.erase(i);
@@ -226,6 +225,11 @@ Hydra::Core::Endpoint::V1::EndpointSeq Hydra::BridgeService::BridgeImpl::listEnd
     {
         eps.push_back(*i);
     }
+    if(mMonitor)
+    {
+        bool result = mMonitor->onListEndpoints(eps, eps);
+        mLogger.getDebugStream() << __FUNCTION__ << "onListEndpoints() returned " << result << std::endl;
+    }
     mLogger.getDebugStream() << __FUNCTION__ << ": returning " << eps.size() << " endpoints." << std::endl;
     return eps;
 }
@@ -247,6 +251,11 @@ void Hydra::BridgeService::BridgeImpl::shutdown(const Ice::Current& current)
         }
         mState = ShuttingDown;
     }
+    if(mMonitor)
+    {
+        bool result = mMonitor->onShutdown();
+        mLogger.getDebugStream() << __FUNCTION__ << "onShuttingDown() returned " << result << std::endl;
+    }
     mEvents->shuttingDown();
 
     //
@@ -264,6 +273,11 @@ void Hydra::BridgeService::BridgeImpl::shutdown(const Ice::Current& current)
     std::for_each(mEndpoints.begin(), mEndpoints.end(), Hydra::BridgeService::BridgeShutdownFunctor(sourceId, response));
     mLogger.getInfoStream() << current.adapter->getCommunicator()->identityToString(current.id) << ": is shutdown." << std::endl;
     mEvents->stopped();
+    if(mMonitor)
+    {
+        bool result = mMonitor->onShutdownComplete();
+        mLogger.getDebugStream() << __FUNCTION__ << "onShutdownComplete() returned " << result << std::endl;
+    }
 }
 
 void Hydra::BridgeService::BridgeImpl::destroy(const Ice::Current& current)
@@ -280,6 +294,11 @@ void Hydra::BridgeService::BridgeImpl::destroy(const Ice::Current& current)
         mLogger.getDebugStream() << __FUNCTION__ << ": called when destroyed." << std::endl;
         throw Ice::ObjectNotExistException(__FILE__, __LINE__);
     }
+    if(mMonitor)
+    {
+        bool result = mMonitor->onDestroy();
+        mLogger.getDebugStream() << __FUNCTION__ << "onDestroy() returned " << result << std::endl;
+    }
     mState = Destroyed;
     mLogger.getInfoStream() << current.adapter->getCommunicator()->identityToString(current.id) << ": is now destroyed." << std::endl;
     mEvents->stopped();
diff --git a/src/BridgeImpl.h b/src/BridgeImpl.h
index 22ac5ba..1fcae60 100644
--- a/src/BridgeImpl.h
+++ b/src/BridgeImpl.h
@@ -51,7 +51,6 @@ namespace BridgeService
       boost::shared_mutex mLock;
       enum ServiceStates
       { 
-         Starting, 
          Running, 
          ShuttingDown, 
          Destroyed 
@@ -60,7 +59,7 @@ namespace BridgeService
 
       Core::Endpoint::V1::BaseEndpointPtr mAdminEndpoint;
       Session::V1::SessionEndpointSeq mEndpoints;
-      Core::Bridging::V1::BridgeMonitorPrx mManager;
+      Core::Bridging::V1::BridgeMonitorPrx mMonitor;
       std::auto_ptr<EventTopicWrapper> mEvents;
 
       //

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


-- 
hydra/bridging.git




More information about the asterisk-scf-commits mailing list