[asterisk-scf-commits] asterisk-scf/release/test_channel.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Apr 19 10:56:17 CDT 2011


branch "master" has been updated
       via  fc859d79f234dfe789e669efd771e615eb52ddcc (commit)
      from  fffdcb241ce942415bb8fe17a9f266d0e7a1ecdf (commit)

Summary of changes:
 src/Service.cpp      |   48 +++++++++++++++++++++++++++++++++++++++++++-----
 src/TestEndpoint.cpp |    8 ++++----
 src/TestEndpoint.h   |    2 +-
 3 files changed, 48 insertions(+), 10 deletions(-)


- Log -----------------------------------------------------------------
commit fc859d79f234dfe789e669efd771e615eb52ddcc
Author: Brent Eagles <beagles at digium.com>
Date:   Tue Apr 19 13:25:50 2011 -0230

    Modifying the test channel to be more usable through service discovery by:
    - configured a default for the adapter configuration, both in endpoints
      and thread pool configuration
    - made the test command proxy a facet of the endpoint

diff --git a/src/Service.cpp b/src/Service.cpp
index af0e1ed..36bf53b 100644
--- a/src/Service.cpp
+++ b/src/Service.cpp
@@ -46,14 +46,52 @@ TestChannelDriver::TestChannelDriver()
 void TestChannelDriver::start(const std::string&, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq&)
 {
     mLogger.getTraceStream() << "Launching AsteriskSCF Session-Oriented Test Channel Service." << std::endl;
-    mAdapter = communicator->createObjectAdapter("AsteriskSCF.TestChannelService");
+
+    //
+    // It is standard practice to base the adapter name on the configured
+    // service instance name.
+    //
+    std::string adapterName;
+    if(name.size() == 0)
+    {
+        adapterName = "TestChannel";
+    }
+    else
+    {
+        adapterName = name + ".TestChannel";
+    }
+
+    //
+    // Check on the threadpool properties, make sure that they are compatible with the requirements of this 
+    // service. This could be moved into a helper method, but it is somehow more clear for seeing what
+    // is going on during initialization to leave it here.
+    //
+    // TODO: Are there any other properties that need to be double-checked before proceeding?
+    //
+    Ice::Int defaultPoolSize = communicator->getProperties()->getPropertyAsIntWithDefault("Ice.ThreadPool.Server.Size", 0);
+    if (communicator->getProperties()->getPropertyAsIntWithDefault(adapterName + ".ThreadPool.Size", 0) < 4)
+    {
+        if (defaultPoolSize < 4)
+        {
+            communicator->getProperties()->setProperty(adapterName + ".ThreadPool.Size", "4");
+        }
+    }
+
+    //
+    // TODO: All adapter ids should be globally unique. This would allow replicas to be identified.
+    // How this might be useful is that it might be used as a replicated state item to identify
+    // which adapter is currently the primary in a group of replicas.
+    //
+    mAdapter = communicator->createObjectAdapterWithEndpoints(adapterName,
+        communicator->getProperties()->getPropertyWithDefault(adapterName + ".Endpoints", "default"));
+
     mAdapter->activate();
 
-    AsteriskSCF::Core::Routing::V1::EndpointLocatorPtr servant = AsteriskSCF::TestUtil::TestEndpoint::create(mAdapter, "TestChannel.Locator");
-    AsteriskSCF::Core::Routing::V1::EndpointLocatorPrx endpointLocatorPrx =
-        AsteriskSCF::Core::Routing::V1::EndpointLocatorPrx::checkedCast(mAdapter->add(servant, communicator->stringToIdentity("TestChannel")));
+    AsteriskSCF::Core::Routing::V1::EndpointLocatorPrx endpointLocatorPrx = 
+        AsteriskSCF::TestUtil::TestEndpoint::create(mAdapter, "TestChannel.Locator");
 
-    AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx management = AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx::checkedCast(communicator->propertyToProxy("ServiceLocatorManagementProxy"));
+    AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx management = 
+        AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx::checkedCast(communicator->propertyToProxy("ServiceLocatorManagementProxy"));
     mServiceManagement = AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx::uncheckedCast(management->addService(endpointLocatorPrx, "TestChannel"));
     AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr params = new AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams();
     params->category = "TestChannel";
diff --git a/src/TestEndpoint.cpp b/src/TestEndpoint.cpp
index b6717f1..fc1191d 100644
--- a/src/TestEndpoint.cpp
+++ b/src/TestEndpoint.cpp
@@ -527,7 +527,7 @@ public:
         mEndpointProxy =
             AsteriskSCF::Core::Endpoint::V1::BaseEndpointPrx::checkedCast(adapter->add(mManager, adapter->getCommunicator()->stringToIdentity(mManagerId + ".Endpoint")));
         mCommands = new CommandImpl(mManager);
-        adapter->add(mCommands, adapter->getCommunicator()->stringToIdentity(mManagerId + ".Commands"));
+        adapter->addFacet(mCommands, adapter->getCommunicator()->stringToIdentity(id), "Commands");
     }
 
     AsteriskSCF::Core::Endpoint::V1::EndpointSeq lookup(const std::string&, const Ice::Current&)
@@ -555,11 +555,11 @@ namespace AsteriskSCF
 namespace TestUtil
 {
 
-AsteriskSCF::Core::Routing::V1::EndpointLocatorPtr TestEndpoint::create(const Ice::ObjectAdapterPtr& adapter, const std::string& id)
+AsteriskSCF::Core::Routing::V1::EndpointLocatorPrx TestEndpoint::create(const Ice::ObjectAdapterPtr& adapter, const std::string& id)
 {
-
     EndpointLocatorIPtr impl(new EndpointLocatorI(adapter, id));
-    return  AsteriskSCF::Core::Routing::V1::EndpointLocatorPtr::dynamicCast(impl);
+    return AsteriskSCF::Core::Routing::V1::EndpointLocatorPrx::uncheckedCast(adapter->add(impl, 
+        adapter->getCommunicator()->stringToIdentity(id)));
 }
 
 }
diff --git a/src/TestEndpoint.h b/src/TestEndpoint.h
index 827efa8..3bed6fc 100644
--- a/src/TestEndpoint.h
+++ b/src/TestEndpoint.h
@@ -34,7 +34,7 @@ class TestEndpoint
     //
     TestEndpoint() {}
 public:
-    static AsteriskSCF::Core::Routing::V1::EndpointLocatorPtr create(const Ice::ObjectAdapterPtr& adapter, const std::string& id);
+    static AsteriskSCF::Core::Routing::V1::EndpointLocatorPrx create(const Ice::ObjectAdapterPtr& adapter, const std::string& id);
 };
 }
 } // End of namespace AsteriskSCF

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


-- 
asterisk-scf/release/test_channel.git



More information about the asterisk-scf-commits mailing list