[asterisk-scf-commits] asterisk-scf/integration/test_channel.git branch "async-bridging" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Apr 7 07:32:54 CDT 2011


branch "async-bridging" has been created
        at  979ae71d2d0d5e511801a3af0c345ae0156b03d2 (commit)

- Log -----------------------------------------------------------------
commit 979ae71d2d0d5e511801a3af0c345ae0156b03d2
Author: Brent Eagles <beagles at digium.com>
Date:   Thu Apr 7 10:00:21 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 9ec19e5..758e87c 100644
--- a/src/Service.cpp
+++ b/src/Service.cpp
@@ -46,14 +46,52 @@ TestChannelDriver::TestChannelDriver()
 void TestChannelDriver::start(const std::string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args)
 {
     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 830bdbf..470659b 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& destination, 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/integration/test_channel.git



More information about the asterisk-scf-commits mailing list