[asterisk-scf-commits] asterisk-scf/integration/routing.git branch "refactor_startup" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed May 18 19:23:25 CDT 2011


branch "refactor_startup" has been updated
       via  b2ea2b4cbed1a1a4f86d59aadf1dddd7ef269bf8 (commit)
      from  6c2629eca0196ffd38384f6bd3b165d20330a495 (commit)

Summary of changes:
 config/routingtest-integ.config                    |   57 ++++++++++----------
 local-slice/BasicRoutingStateReplicationIf.ice     |    2 +-
 src/BasicRoutingServiceApp.cpp                     |    6 ++-
 ...nectBridgedSessionsWithDestinationOperation.cpp |   52 ++++++++++++------
 test/TestRouting.cpp                               |    8 +++
 5 files changed, 76 insertions(+), 49 deletions(-)


- Log -----------------------------------------------------------------
commit b2ea2b4cbed1a1a4f86d59aadf1dddd7ef269bf8
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Wed May 18 19:21:16 2011 -0500

    Cleanup for startup changes.
      - Removed the reference to a .Standby property and use the .Standalone property.
      - Updated config file.
      - Fixed a time-sensitive test case.

diff --git a/config/routingtest-integ.config b/config/routingtest-integ.config
index 36f3d03..0ca6d18 100644
--- a/config/routingtest-integ.config
+++ b/config/routingtest-integ.config
@@ -3,10 +3,10 @@
 Ice.Warn.UnknownProperties=0
 Ice.ThreadPool.Client.Size=4
 
-#Ice.Admin.Endpoints=tcp -p 10006
+#Ice.Admin.Endpoints=tcp -h 127.0.0.1 -p 10006
 #Ice.Admin.InstanceName=IceBox
 IceBox.InstanceName=IceBox
-IceBox.ServiceManager.Endpoints=tcp -p 10007
+IceBox.ServiceManager.Endpoints=tcp -h 127.0.0.1 -p 10007
 
 IceBox.InheritProperties=1
 
@@ -24,13 +24,13 @@ IceBox.Service.Replicator=BasicRoutingStateReplicator:create
 IceBox.LoadOrder=ServiceDiscovery,Replicator,RoutingService,RoutingService2,RoutingTest
 
 # Where to find the Service Locator manager. We need the Service Locator in order to be able to plug in to the Asterisk SCF system Discovery mechanisms.
-LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4422
+LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -h 127.0.0.1 -p 4422
 
 # Where to find the Service Locator.
-LocatorService.Proxy=LocatorService:tcp -p 4411
+LocatorService.Proxy=LocatorService:tcp -h 127.0.0.1 -p 4411
 
 # Test endpoints for IceStorm
-TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:default -p 10000
+TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:tcp -h 127.0.0.1 -p 10000
 
 # Category for the bridge service
 BridgeManager.ServiceLocatorId=BridgeService
@@ -38,26 +38,27 @@ BridgeManager.ServiceLocatorId=BridgeService
 ###########################################
 # Routing Service properties
 
-RoutingService.Endpoints=tcp -p 10050
-RoutingService.ComponentService.Endpoints=tcp -p 10051
+RoutingService.Endpoints=tcp -h 127.0.0.1 -p 10050
+RoutingService.Management.Endpoints=tcp -h 127.0.0.1 -p 10051
 RoutingService.ThreadPool.Size=8
 RoutingService.ThreadPool.SizeMax=14
 RoutingService.ThreadPool.SizeWarn=9
-RoutingService.Standby=no
+# Note: Default for Standalone is no, so this could be omitted.
+RoutingService.Standalone=no
 RoutingService.StateReplicatorName=Replicator
 RoutingService.ComponentTest=yes
 
-RoutingService2.Endpoints=tcp -p 10052
-RoutingService2.ComponentService.Endpoints=tcp -p 10053
+RoutingService2.Endpoints=tcp -h 127.0.0.1 -p 10052
+RoutingService2.Management.Endpoints=tcp -h 127.0.0.1 -p 10053
 RoutingService2.ThreadPool.Size=8
 RoutingService2.ThreadPool.SizeMax=14
 RoutingService2.ThreadPool.SizeWarn=9
-RoutingService2.Standby=yes
+RoutingService2.Standalone=no
 RoutingService2.StateReplicatorName=Replicator
 
 Replicator.InstanceName=Replicator
-Replicator.Endpoints=default -p 10054
-Replicator.ComponentService.Endpoints=default -p 10055
+Replicator.Endpoints=tcp -h 127.0.0.1 -p 10054
+Replicator.Management.Endpoints=tcp -h 127.0.0.1 -p 10055
 Replicator.ThreadPool.Size=8
 Replicator.ThreadPool.SizeMax=14
 Replicator.ThreadPool.SizeWarn=9
@@ -68,23 +69,23 @@ Replicator.ThreadPool.SizeWarn=9
 # Test properties
 
 # Test adapter
-TestRoutingAdapterOut.Endpoints=tcp -p 10070
-TestRoutingAdapterIn.Endpoints=tcp -p 10071
+TestRoutingAdapterOut.Endpoints=tcp -h 127.0.0.1 -p 10070
+TestRoutingAdapterIn.Endpoints=tcp -h 127.0.0.1 -p 10071
 
 # NOTE: For testing, we grab direct proxy to the same servant on 
 # backup service.
 
 # Where to look for the Routing Service LocatorRegistry interface
-LocatorRegistry.Proxy=RoutingServiceLocatorRegistry:tcp -p 10050
-BackupLocatorRegistry.Proxy=RoutingServiceLocatorRegistry:tcp -p 10052
+LocatorRegistry.Proxy=RoutingServiceLocatorRegistry:tcp -h 127.0.0.1 -p 10050
+BackupLocatorRegistry.Proxy=RoutingServiceLocatorRegistry:tcp -h 127.0.0.1 -p 10052
 
-SessionRouter.Proxy=SessionRouter:tcp -p 10050
-BackupSessionRouter.Proxy=SessionRouter:tcp -p 10052
+SessionRouter.Proxy=SessionRouter:tcp -h 127.0.0.1 -p 10050
+BackupSessionRouter.Proxy=SessionRouter:tcp -h 127.0.0.1 -p 10052
 
-Replica.Proxy=BasicRoutingServiceReplica:tcp -p 10050
-BackupReplica.Proxy=BasicRoutingServiceReplica:tcp -p 10052
+Replica.Proxy=BasicRoutingServiceReplica:tcp -h 127.0.0.1 -p 10051
+BackupReplica.Proxy=BasicRoutingServiceReplica:tcp -h 127.0.0.1 -p 10053
 
-RoutingComponent.Proxy=BasicRoutingComponent:tcp -p 10051
+RoutingComponent.Proxy=BasicRoutingComponent:tcp -h 127.0.0.1 -p 10051
 
 TestRoutingAdapterIn.ThreadPool.Size=8
 TestRoutingAdapterIn.ThreadPool.SizeMax=14
@@ -102,7 +103,7 @@ AsteriskSCFIceStorm.InstanceName=AsteriskSCFIceStorm
 # This property defines the endpoints on which the IceStorm
 # TopicManager listens.
 #
-AsteriskSCFIceStorm.TopicManager.Endpoints=default -p 10000
+AsteriskSCFIceStorm.TopicManager.Endpoints=tcp -h 127.0.0.1 -p 10000
 
 #
 # This property defines the endpoints on which the topic
@@ -110,7 +111,7 @@ AsteriskSCFIceStorm.TopicManager.Endpoints=default -p 10000
 # IceStorm instances this must run on a fixed port (or use
 # IceGrid).
 #
-AsteriskSCFIceStorm.Publish.Endpoints=tcp -p 10001:udp -p 10001
+AsteriskSCFIceStorm.Publish.Endpoints=tcp -h 127.0.0.1 -p 10001:udp -h 127.0.0.1 -p 10001
 
 #
 # TopicManager Tracing
@@ -127,12 +128,12 @@ AsteriskSCFIceStorm.Flush.Timeout=2000
 # This is a configuration file used in conjunction with the service locator test driver
 
 # Test endpoints for the service locator management adapter
-ServiceLocatorManagementAdapter.Endpoints=tcp -p 4422
+ServiceLocatorManagementAdapter.Endpoints=tcp -h 127.0.0.1 -p 4422
 
 # Test endpoints for the service locator adapter
-ServiceLocatorAdapter.Endpoints=tcp -p 4411
-ServiceLocatorLocalAdapter.Endpoints=tcp -p 4412
+ServiceLocatorAdapter.Endpoints=tcp -h 127.0.0.1 -p 4411
+ServiceLocatorLocalAdapter.Endpoints=tcp -h 127.0.0.1 -p 4412
 
 # Logger configuration
-LoggerAdapter.Endpoints=default
+LoggerAdapter.Endpoints=tcp -h 127.0.0.1
 AsteriskSCF.Logging.logger.AsteriskSCF=Error
diff --git a/local-slice/BasicRoutingStateReplicationIf.ice b/local-slice/BasicRoutingStateReplicationIf.ice
index 4ea55c1..3e31d77 100644
--- a/local-slice/BasicRoutingStateReplicationIf.ice
+++ b/local-slice/BasicRoutingStateReplicationIf.ice
@@ -139,6 +139,7 @@ module V1
     {
         AsteriskSCF::SessionCommunications::V1::Session *sessionToReplace;
         string destination;
+        AsteriskSCF::SessionCommunications::V1::Bridge* bridge;
     };
     const string ConnectBridgedSessionsWithDestStartKeyMod = ".START";
 
@@ -162,7 +163,6 @@ module V1
      */
     class ConnectBridgedSessionsWithDestinationOpBridgingState extends OperationStateItem
     {
-        AsteriskSCF::SessionCommunications::V1::Bridge* bridge;
     };
     const string ConnectBridgedSessionsWithDestBridgingKeyMod = ".BRIDGING";
 
diff --git a/src/BasicRoutingServiceApp.cpp b/src/BasicRoutingServiceApp.cpp
index 46dd274..9e34cea 100644
--- a/src/BasicRoutingServiceApp.cpp
+++ b/src/BasicRoutingServiceApp.cpp
@@ -484,7 +484,7 @@ void BasicRoutingServiceApp::deregisterFromServiceLocator(bool includeManagement
             mComponentServiceManagement->unregister();
         }
     }
-    catch(...)
+    catch(const std::exception& e)
     {
         lg(Error) << BOOST_CURRENT_FUNCTION << e.what();
     }
@@ -588,7 +588,9 @@ void BasicRoutingServiceApp::initialize()
         // Create an adapter that is bound to the dedicated (non-movable) address of this component. 
         mManagementAdapter = mCommunicator->createObjectAdapter(mAppName + ".Management");
 
-        bool active = !(mCommunicator->getProperties()->getPropertyWithDefault(mAppName + ".Standby", "no") == "yes");
+        // Standalone instances are the only instances that default to being active. 
+        // Non-standalone instances must be made active via the Replica interface. 
+        bool active = (mCommunicator->getProperties()->getPropertyWithDefault(mAppName + ".Standalone", "no") == "yes");
 
         // Create the replication context.
         mReplicationContext = ReplicationContextPtr(new ReplicationContext(active));
diff --git a/src/ConnectBridgedSessionsWithDestinationOperation.cpp b/src/ConnectBridgedSessionsWithDestinationOperation.cpp
index ca07b82..56b438f 100644
--- a/src/ConnectBridgedSessionsWithDestinationOperation.cpp
+++ b/src/ConnectBridgedSessionsWithDestinationOperation.cpp
@@ -70,20 +70,6 @@ public:
 
         switch(state)
         {
-        case ConnectBridgedSessionsWithDestinationOp::STATE_LOOKUP:
-            {
-                // Push this information to the state replicator.
-                ConnectBridgedSessionsWithDestinationOpStartPtr 
-                     opStart(new ConnectBridgedSessionsWithDestinationOpStart());
-                opStart->operationId = mOperation->getOperationId();
-                opStart->key = mOperation->getOperationId() + 
-                     AsteriskSCF::BasicRoutingService::V1::ConnectBridgedSessionsWithDestStartKeyMod;
-                opStart->sessionToReplace = mOperation->getSessionToReplace();
-                opStart->destination = mOperation->getDestination();
-
-                pushState(opStart);
-            }
-        break;
 
         case ConnectBridgedSessionsWithDestinationOp::STATE_BRIDGING:
             {
@@ -119,8 +105,35 @@ public:
     /**
      * This callback is called just before the execution of a state machine's current state handler. 
      */
-    void stateExecutionComplete(ConnectBridgedSessionsWithDestinationOp::OperationState)
+    void stateExecutionComplete(ConnectBridgedSessionsWithDestinationOp::OperationState state)
     {
+        if (!mReplicationContext->isReplicating())
+        {
+            return;
+        }
+
+        switch(state)
+        {
+            case ConnectBridgedSessionsWithDestinationOp::STATE_LOOKUP:
+            {
+                // Push this information to the state replicator.
+                ConnectBridgedSessionsWithDestinationOpStartPtr 
+                     opStart(new ConnectBridgedSessionsWithDestinationOpStart());
+                opStart->operationId = mOperation->getOperationId();
+                opStart->key = mOperation->getOperationId() + 
+                     AsteriskSCF::BasicRoutingService::V1::ConnectBridgedSessionsWithDestStartKeyMod;
+                opStart->sessionToReplace = mOperation->getSessionToReplace();
+                opStart->destination = mOperation->getDestination();
+                opStart->bridge = mOperation->getBridge();
+
+                pushState(opStart);
+            }
+            break;
+
+
+        default:
+            break;
+        }
     }
 
     /**
@@ -169,7 +182,6 @@ public:
             bridgeOp->operationId = mOperation->getOperationId();
             bridgeOp->key = mOperation->getOperationId() + 
                     AsteriskSCF::BasicRoutingService::V1::RouteSessionOpBridgingKeyMod;
-            bridgeOp->bridge = mOperation->getBridge();
 
             pushState(bridgeOp);
             }
@@ -307,6 +319,7 @@ void ConnectBridgedSessionsWithDestinationOperation::reflectUpdate(const Asteris
     mSessionToReplace = item->sessionToReplace;
     mDestination = item->destination;
     mOperationId = item->operationId;
+    mBridge = item->bridge;
 
     mReplicatedStates.push_back(ConnectBridgedSessionsWithDestinationOp::STATE_LOOKUP);
 }
@@ -319,8 +332,6 @@ void ConnectBridgedSessionsWithDestinationOperation::reflectUpdate(const Asteris
 
 void ConnectBridgedSessionsWithDestinationOperation::reflectUpdate(const AsteriskSCF::BasicRoutingService::V1::ConnectBridgedSessionsWithDestinationOpBridgingStatePtr& item)
 {
-    mBridge = item->bridge;
-
     mReplicatedStates.push_back(ConnectBridgedSessionsWithDestinationOp::STATE_BRIDGING);
 }
 
@@ -336,6 +347,7 @@ bool ConnectBridgedSessionsWithDestinationOperation::fastForwardReplica()
     // If we didn't receive the initial call params, this replica is of no use. 
     if (i == mReplicatedStates.end())
     {
+        lg(Debug) << BOOST_CURRENT_FUNCTION << ": Insufficient operation replica to build on. " << mDestination;
         return false;
     }
     // Set to initial state.
@@ -345,6 +357,7 @@ bool ConnectBridgedSessionsWithDestinationOperation::fastForwardReplica()
     i = find(mReplicatedStates.begin(), mReplicatedStates.end(), ConnectBridgedSessionsWithDestinationOp::STATE_WAIT_LOOKUP_RESULTS);
     if (i == mReplicatedStates.end())
     {
+        lg(Debug) << BOOST_CURRENT_FUNCTION << ": Replicated operation fast-forwarded to WAIT_LOOKUP_RESULTS. " << mDestination;
         return true;
     }
 
@@ -355,11 +368,14 @@ bool ConnectBridgedSessionsWithDestinationOperation::fastForwardReplica()
     i = find(mReplicatedStates.begin(), mReplicatedStates.end(), ConnectBridgedSessionsWithDestinationOp::STATE_BRIDGING);
     if (i == mReplicatedStates.end())
     {
+        lg(Debug) << BOOST_CURRENT_FUNCTION << ": Replicated operation fast-forwarded to STATE_BRIDGING. " << mDestination;
         return true;
     }
 
     // Apparently nothing left to do but reply to the AMD callback. 
     mStateMachine.resetStartState(ConnectBridgedSessionsWithDestinationOp::STATE_SEND_RESPONSE);
+    lg(Debug) << BOOST_CURRENT_FUNCTION << ": Replicated operation fast-forwarded to SEND_RESPONSE. " << mDestination;
+
     return true;
 }
 
diff --git a/test/TestRouting.cpp b/test/TestRouting.cpp
index 3d9cae2..3561ddf 100644
--- a/test/TestRouting.cpp
+++ b/test/TestRouting.cpp
@@ -152,6 +152,10 @@ struct GlobalIceFixture
                 throw "Invalid Replica";
             }
 
+            // Note: This would be done by Pacemaker-initiated script in the real system. Something
+            // external must activate one of the sevice instances. 
+            SharedTestData::instance.serviceReplicaMgmt->activate();
+
             // Get a ref to the Replica interface and cache it for testing.
             Ice::ObjectPrx replicaObj2 = SharedTestData::instance.communicatorOut->propertyToProxy("BackupReplica.Proxy");
             SharedTestData::instance.backupServiceReplicaMgmt = ReplicaPrx::checkedCast(replicaObj2);
@@ -843,6 +847,10 @@ BOOST_FIXTURE_TEST_CASE(FailoverConnectBridgedSessWithDest, PerTestFixture)
         SharedTestData::instance.mBridgeConnected = false;
         SharedTestData::instance.mSessionReplaced = false;
 
+        // Give the state replicator time to push the state transitions of the replicated 
+        // operation to the standby component. 
+        IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1000));
+
         // Switch standby component to active. 
         SharedTestData::instance.serviceReplicaMgmt->activate();
         BOOST_CHECK(SharedTestData::instance.serviceReplicaMgmt->isActive() == true);

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


-- 
asterisk-scf/integration/routing.git



More information about the asterisk-scf-commits mailing list