[asterisk-scf-commits] asterisk-scf/integration/servicediscovery.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri Oct 1 14:25:45 CDT 2010


branch "master" has been updated
       via  3bb6fbf86fda0fcc479fdd4997e40f4691c078dd (commit)
      from  0dcb27d1526e09de25ceeb66c016aedbc7ff872d (commit)

Summary of changes:
 cmake                              |    2 +-
 config/test_icestorm.config        |   30 --------------
 config/test_service_locator.config |   28 +++++++++++++
 slice                              |    2 +-
 src/CMakeLists.txt                 |    5 ++
 src/CollocatedIceStorm.cpp         |   74 ++++++++++++++++++++++++++++++++++++
 src/CollocatedIceStorm.h           |   45 ++++++++++++++++++++++
 src/ServiceLocator.cpp             |    6 +++
 8 files changed, 160 insertions(+), 32 deletions(-)
 delete mode 100644 config/test_icestorm.config
 create mode 100644 src/CollocatedIceStorm.cpp
 create mode 100644 src/CollocatedIceStorm.h


- Log -----------------------------------------------------------------
commit 3bb6fbf86fda0fcc479fdd4997e40f4691c078dd
Author: Brent Eagles <beagles at digium.com>
Date:   Fri Oct 1 16:43:05 2010 -0230

    Add a collocated IceStorm instance to ServiceLocator. Also removed the icestorm
    specific configuration file as it is no longer needed.
    
    Also added property handler so the default IceStorm entry point can be
    overridden via properties (IceStorm.EntryPoint).

diff --git a/cmake b/cmake
index 364040a..d30f7d1 160000
--- a/cmake
+++ b/cmake
@@ -1 +1 @@
-Subproject commit 364040aa2e2252eb07d896dc98eee1d2362f56e9
+Subproject commit d30f7d1a5561c2bf086eacad2e0565c49c261e51
diff --git a/config/test_icestorm.config b/config/test_icestorm.config
deleted file mode 100644
index 62aeb7f..0000000
--- a/config/test_icestorm.config
+++ /dev/null
@@ -1,30 +0,0 @@
-# This is a configuration file used in conjunction with the service discovery test driver
-
-IceBox.Service.IceStorm=IceStormService,34:createIceStorm --Ice.Config=../config/test_icestorm.config
-
-IceStorm.InstanceName=HydraIceStorm
-#
-# This property defines the endpoints on which the IceStorm
-# TopicManager listens.
-#
-IceStorm.TopicManager.Endpoints=default -p 10000
-
-#
-# This property defines the endpoints on which the topic
-# publisher objects listen. If you want to federate
-# IceStorm instances this must run on a fixed port (or use
-# IceGrid).
-#
-IceStorm.Publish.Endpoints=tcp -p 10001:udp -p 10001
-
-#
-# TopicManager Tracing
-#
-# 0 = no tracing
-# 1 = trace topic creation, subscription, unsubscription
-# 2 = like 1, but with more detailed subscription information
-#
-IceStorm.Trace.TopicManager=2
-
-#
-IceStorm.Flush.Timeout=2000
diff --git a/config/test_service_locator.config b/config/test_service_locator.config
index dfa1e4a..47872bd 100644
--- a/config/test_service_locator.config
+++ b/config/test_service_locator.config
@@ -1,3 +1,31 @@
+# This is a configuration file used in conjunction with the service discovery test driver
+HydraIceStorm.InstanceName=HydraIceStorm
+#
+# This property defines the endpoints on which the IceStorm
+# TopicManager listens.
+#
+HydraIceStorm.TopicManager.Endpoints=default -p 10000
+
+#
+# This property defines the endpoints on which the topic
+# publisher objects listen. If you want to federate
+# IceStorm instances this must run on a fixed port (or use
+# IceGrid).
+#
+HydraIceStorm.Publish.Endpoints=tcp -p 10001:udp -p 10001
+
+#
+# TopicManager Tracing
+#
+# 0 = no tracing
+# 1 = trace topic creation, subscription, unsubscription
+# 2 = like 1, but with more detailed subscription information
+#
+HydraIceStorm.Trace.TopicManager=2
+HydraIceStorm.Transient=1
+
+#
+HydraIceStorm.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
diff --git a/slice b/slice
index 14413db..36a57a4 160000
--- a/slice
+++ b/slice
@@ -1 +1 @@
-Subproject commit 14413db47bfae3d1ff57d36e80cfe700d755ae0b
+Subproject commit 36a57a423c849ff5688d8c4f3569bf3639feed36
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f1d74e1..17f592e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -13,7 +13,12 @@ hydra_component_add_slice(service_locator ServiceLocatorEventsIf)
 hydra_component_add_file(service_locator ServiceLocator.cpp)
 hydra_component_add_file(service_locator ServiceLocatorManagement.cpp)
 hydra_component_add_file(service_locator ServiceManagement.cpp)
+hydra_component_add_file(service_locator CollocatedIceStorm.cpp)
+hydra_component_add_file(service_locator CollocatedIceStorm.h)
+hydra_component_add_file(service_locator ServiceManagement.h)
+hydra_component_add_file(service_locator ServiceLocatorManagement.h)
 hydra_component_add_ice_libraries(service_locator IceStorm)
+hydra_component_add_ice_libraries(service_locator IceBox)
 hydra_component_add_boost_libraries(service_locator core thread)
 hydra_component_build_standalone(service_locator)
 hydra_component_install(service_locator RUNTIME bin "Service Locator." Core)
diff --git a/src/CollocatedIceStorm.cpp b/src/CollocatedIceStorm.cpp
new file mode 100644
index 0000000..a16198c
--- /dev/null
+++ b/src/CollocatedIceStorm.cpp
@@ -0,0 +1,74 @@
+/*
+* Asterisk Scalable Communications Framework
+*
+* Copyright (C) 2010 -- Digium, Inc.
+*
+* All rights reserved.
+*/
+#include <Ice/Ice.h>
+#include <IceStorm/IceStorm.h>
+#include <assert.h>
+#include <algorithm>
+#include "CollocatedIceStorm.h"
+
+//
+// The idea behind this class is that it needs to access the entry point that IceBox would
+// have used and then invoke the methods that are needed to start and stop the IceStorm
+// service.
+//
+typedef IceBox::Service* (*FACTORY)(Ice::CommunicatorPtr);
+
+CollocatedIceStorm::CollocatedIceStorm(const std::string& namePrefix, const Ice::PropertiesPtr& properties) :
+    mStopped(false)
+{
+    //
+    // We create our own communicator to avoid issues with call order on shutdown.
+    //
+    Ice::InitializationData initData;
+    initData.properties = properties;
+    mCommunicator = Ice::initialize(initData);
+
+    std::string loadString = mCommunicator->getProperties()->getPropertyWithDefault("IceStorm.EntryPoint", "IceStormService:createIceStorm");
+
+    mLibrary = new IceInternal::DynamicLibrary;
+    IceInternal::DynamicLibrary::symbol_type entry = mLibrary->loadEntryPoint(loadString);
+    if(entry == 0)
+    {
+        throw mLibrary->getErrorMessage();
+    }
+    FACTORY factory = (FACTORY)entry;
+    mService = factory(mCommunicator);
+    assert(mService != 0);
+    Ice::StringSeq options;
+    mService->start(namePrefix, mCommunicator, options);
+}
+
+CollocatedIceStorm::~CollocatedIceStorm()
+{
+    if(!mStopped)
+    {
+        try
+        {
+            stop();
+        }
+        catch(...)
+        {
+        }
+    }
+}
+
+void CollocatedIceStorm::stop()
+{
+    //
+    // NOTE: there isn't any mutex protection here. It can be added later if needed, but at the moment multiple threads
+    // do not have access to this object instance.
+    //
+    if(!mStopped)
+    {
+        if(mService)
+        {
+            mService->stop();
+        }
+        mStopped = true;
+    }
+}
diff --git a/src/CollocatedIceStorm.h b/src/CollocatedIceStorm.h
new file mode 100644
index 0000000..b276497
--- /dev/null
+++ b/src/CollocatedIceStorm.h
@@ -0,0 +1,45 @@
+/*
+* Asterisk Scalable Communications Framework
+*
+* Copyright (C) 2010 -- Digium, Inc.
+*
+* All rights reserved.
+*/
+#pragma once
+
+#include <Ice/DynamicLibrary.h>
+#include <Ice/Service.h>
+#include <IceBox/IceBox.h>
+#include <Ice/Ice.h>
+#include <IceStorm/IceStorm.h>
+#include <string>
+
+/**
+ * A helper class that instantiates IceStorm in-process, removing the need to launch
+ * a separate process to access IceStorm services. 
+ */
+
+class CollocatedIceStorm;
+typedef IceUtil::Handle<CollocatedIceStorm> CollocatedIceStormPtr;
+
+class CollocatedIceStorm : public IceUtil::Shared
+{
+public:
+    CollocatedIceStorm(const std::string&, const Ice::PropertiesPtr&);
+    ~CollocatedIceStorm();
+
+    /**
+     * "nice" applications should explictly call stop !
+     */
+    void stop();
+
+private:
+    IceInternal::DynamicLibraryPtr mLibrary;
+    IceBox::ServicePtr mService;
+    Ice::CommunicatorPtr mCommunicator;
+    bool mStopped;
+};
+
+typedef IceUtil::Handle<CollocatedIceStorm> CollocatedIceStormPtr;
+
+
diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index 1a7d1b7..a5ac3ba 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -14,6 +14,7 @@
 
 #include "ServiceLocatorManagement.h"
 #include "ServiceManagement.h"
+#include "CollocatedIceStorm.h"
 
 using namespace std;
 using namespace AsteriskSCF::System::Discovery;
@@ -29,6 +30,7 @@ public:
 	void interruptCallback(int);
 
 private:
+        CollocatedIceStormPtr mIceStorm;
 };
 
 /**
@@ -81,6 +83,8 @@ Ice::ObjectProxySeq ServiceLocatorImpl::locateAll(const ServiceLocatorParamsPtr&
  */
 int ServiceLocatorApp::run(int argc, char* argv[])
 {
+    mIceStorm = new CollocatedIceStorm("HydraIceStorm", communicator()->getProperties());
+
 	cout << "[INFO] Initializing service discovery component" << endl;
 
 	/* Talk to the topic manager to either create or get the service discovery topic, configured or default */
@@ -152,6 +156,8 @@ int ServiceLocatorApp::run(int argc, char* argv[])
 	/* Now that management and discovery are active we just sit here waiting until we shutdown */
 	communicator()->waitForShutdown();
 
+        mIceStorm->stop();
+
 	return EXIT_SUCCESS;
 }
 

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


-- 
asterisk-scf/integration/servicediscovery.git



More information about the asterisk-scf-commits mailing list