[asterisk-scf-commits] asterisk-scf/integration/servicediscovery.git branch "logging" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Oct 5 10:52:21 CDT 2010


branch "logging" has been created
        at  482bfdde0634f68608a33f86f185878f7012defd (commit)

- Log -----------------------------------------------------------------
commit 482bfdde0634f68608a33f86f185878f7012defd
Author: David M. Lee <dlee at digium.com>
Date:   Tue Oct 5 10:52:01 2010 -0500

    Integrating ServiceLocator with Logger.

diff --git a/config/test_component.config.in b/config/test_component.config.in
index 0583040..7da16da 100644
--- a/config/test_component.config.in
+++ b/config/test_component.config.in
@@ -41,6 +41,11 @@ ServiceLocatorAdapter.Endpoints=tcp -p 4411
 TopicManager.Proxy=HydraIceStorm/TopicManager:default -p 10000
 
 #
+# Logger configuration
+#
+LoggerAdapter.Endpoints=default
+
+#
 # test configuration
 #
 IceBox.Service.ServiceDiscoveryTest=. at service_locator_test:create --Ice.Config=config/test_component.config --report_sink=${CMAKE_BINARY_DIR}/service_locator_test-result.xml --report_format=XML --report_level=detailed
diff --git a/config/test_service_locator.config b/config/test_service_locator.config
index 492a0d5..671583b 100644
--- a/config/test_service_locator.config
+++ b/config/test_service_locator.config
@@ -36,6 +36,10 @@ ServiceLocatorManagementAdapter.Endpoints=tcp -p 4422
 
 # Test endpoints for the service locator adapter
 ServiceLocatorAdapter.Endpoints=tcp -p 4411
+LocatorService.Proxy=LocatorService:tcp -p 4411
 
 # Test endpoints for IceStorm
 TopicManager.Proxy=HydraIceStorm/TopicManager:default -p 10000
+
+# Logger configuration
+LoggerAdapter.Endpoints=default
diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index 6879bc5..0a5f37f 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -42,6 +42,8 @@ public:
 
 private:
    Ice::ObjectAdapterPtr discovery_adapter;
+   Ice::ObjectAdapterPtr management_adapter;
+   Ice::ObjectAdapterPtr logger_adapter;
    CollocatedIceStormPtr mIceStorm;
 };
 
@@ -142,7 +144,7 @@ void ServiceLocatorApp::start(
     * management may want to be protected so arbitrary people can't inject bad services
     * into the infrastructure while discovery as a read only function may be allowed to all.
     */
-   Ice::ObjectAdapterPtr management_adapter = communicator->createObjectAdapter(
+    management_adapter= communicator->createObjectAdapter(
       "ServiceLocatorManagementAdapter");
 
    ServiceLocatorManagementImpl* LocatorServiceManagement =
@@ -157,15 +159,20 @@ void ServiceLocatorApp::start(
 
    discovery_adapter = communicator->createObjectAdapter("ServiceLocatorAdapter");
 
-   ConfiguredIceLoggerPtr mIceLogger = createIceLogger(discovery_adapter);
-   getLoggerFactory().setLogOutput(mIceLogger->getLogger());
-
    ServiceLocatorPtr LocatorService = new ServiceLocatorImpl(LocatorServiceManagement);
 
    discovery_adapter->add(LocatorService, communicator->stringToIdentity("LocatorService"));
 
    discovery_adapter->activate();
 
+   logger_adapter = communicator->createObjectAdapter("LoggerAdapter");
+
+   ConfiguredIceLoggerPtr mIceLogger = createIceLogger(logger_adapter);
+
+   getLoggerFactory().setLogOutput(mIceLogger->getLogger());
+
+   logger_adapter->activate();
+
    lg(Info) << "Activated service discovery.";
 
    lg(Info) << "Waiting for requests.";
diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index 93de1de..3d33c65 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -160,6 +160,7 @@ Ice::ObjectProxySeq ServiceLocatorManagementImpl::locateAll(
 ServiceManagementPrx ServiceLocatorManagementImpl::addService(
    const Ice::ObjectPrx& service, const string& guid, const Ice::Current&)
 {
+   lg(Info) << "addService " << guid << '.';
    boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
    ServiceManagementImplPtr new_service = new ServiceManagementImpl(this, service,
       mImpl->mAdapter, mImpl->mLocatorTopic, guid);
@@ -244,6 +245,7 @@ bool ServiceLocatorManagementImpl::isSupported(const string& compare_guid,
  */
 void ServiceLocatorManagementImpl::removeService(ServiceManagementImplPtr service)
 {
+   lg(Info) << "removeService " << service->getGuid() << '.';
    boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
    for (vector<ServiceManagementImplPtr>::iterator existing_service =
         mImpl->mServices.begin();
diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index 722f8dd..c5eafb8 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -171,6 +171,11 @@ bool ServiceManagementImpl::isSupported(const ServiceLocatorParamsPtr& params)
 	return false;
 }
 
+std::string const &ServiceManagementImpl::getGuid() const
+{
+	return mImpl->mGuid;
+}
+
 /**
  * An internal function which is called by the service locator to perform a locator parameters comparison
  * at the parameter and perhaps comparator level.
diff --git a/src/ServiceManagement.h b/src/ServiceManagement.h
index f3a9a54..5bf6ffd 100644
--- a/src/ServiceManagement.h
+++ b/src/ServiceManagement.h
@@ -31,6 +31,7 @@ public:
    Ice::ObjectPrx GetService();
    AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx GetServiceManagementPrx();
    bool isSupported(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
+   std::string const &getGuid() const;
 
 private:
    /**

commit 67c8d060eb1ae036cab1af3b86f3a5dfd1c0a2cf
Author: David M. Lee <dlee at digium.com>
Date:   Tue Oct 5 10:45:38 2010 -0500

    Pretty-print ServiceManagement.h

diff --git a/src/ServiceManagement.h b/src/ServiceManagement.h
index e8cc0ad..f3a9a54 100644
--- a/src/ServiceManagement.h
+++ b/src/ServiceManagement.h
@@ -23,19 +23,20 @@ class ServiceManagementImplPriv;
 class ServiceManagementImpl : public AsteriskSCF::Core::Discovery::V1::ServiceManagement
 {
 public:
-        ServiceManagementImpl(ServiceLocatorManagementImpl*, const Ice::ObjectPrx&, Ice::ObjectAdapterPtr, const AsteriskSCF::System::Discovery::EventsPrx&, const std::string&);
-	void addLocatorParams(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&, const std::string&, const Ice::Current&);
-	void suspend(const Ice::Current&);
-	void unsuspend(const Ice::Current&);
-	void unregister(const Ice::Current&);
-	Ice::ObjectPrx GetService();
-	AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx GetServiceManagementPrx();
-	bool isSupported(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
+   ServiceManagementImpl(ServiceLocatorManagementImpl*, const Ice::ObjectPrx&, Ice::ObjectAdapterPtr, const AsteriskSCF::System::Discovery::EventsPrx&, const std::string&);
+   void addLocatorParams(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&, const std::string&, const Ice::Current&);
+   void suspend(const Ice::Current&);
+   void unsuspend(const Ice::Current&);
+   void unregister(const Ice::Current&);
+   Ice::ObjectPrx GetService();
+   AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx GetServiceManagementPrx();
+   bool isSupported(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&);
+
 private:
-        /**
-	 * Private implementation data for ServiceManagementImpl.
-	 */
-	boost::shared_ptr<ServiceManagementImplPriv> mImpl;
+   /**
+    * Private implementation data for ServiceManagementImpl.
+    */
+   boost::shared_ptr<ServiceManagementImplPriv> mImpl;
 };
 
 #endif

commit 4847a2c03f767b804a286bbad26ff2e41e60d336
Author: David M. Lee <dlee at digium.com>
Date:   Tue Oct 5 09:12:34 2010 -0500

    Integrating with the logger.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index daadb06..92c53b1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -8,8 +8,10 @@
 
 # Create the actual standalone service locator component
 hydra_component_init(service_locator CXX)
+
 hydra_component_add_slice(service_locator ServiceLocatorIf)
 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)
@@ -17,8 +19,15 @@ 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)
+
+include_directories(../../logger/common)
+include_directories(../../logger/client/src)
+
 hydra_component_build_icebox(service_locator)
+target_link_libraries(service_locator logging-client)
 #hydra_component_install(service_locator RUNTIME bin "Service Locator." Core)
diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index d4c16bb..6879bc5 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -16,11 +16,19 @@
 #include "ServiceLocatorManagement.h"
 #include "ServiceManagement.h"
 #include "CollocatedIceStorm.h"
+#include "logger.h"
+#include "IceLogger.h"
 
 using namespace std;
 using namespace AsteriskSCF::System::Discovery;
+using namespace AsteriskSCF::System::Logging;
 using namespace AsteriskSCF::Core::Discovery::V1;
 
+namespace
+{
+   Logger const &lg = getLoggerFactory().getLogger("AsteriskSCF.System.Discovery");
+}
+
 /**
  * Implementation of the Ice::Application class
  */
@@ -83,9 +91,9 @@ void ServiceLocatorApp::start(
     const Ice::CommunicatorPtr& communicator,
     const Ice::StringSeq& args)
 {
-    mIceStorm = new CollocatedIceStorm("HydraIceStorm", communicator->getProperties());
+   mIceStorm = new CollocatedIceStorm("HydraIceStorm", communicator->getProperties());
 
-   cout << "[INFO] Initializing service discovery component" << endl;
+   lg(Info) << "Initializing service discovery component";
 
    /* Talk to the topic manager to either create or get the service discovery topic,
     * configured or default */
@@ -113,21 +121,21 @@ void ServiceLocatorApp::start(
       {
          try
          {
-       topic = topicManager->create(topicName);
+            topic = topicManager->create(topicName);
          }
          catch (const IceStorm::TopicExists&)
          {
-       cerr << "Oh snap! Race condition creating topic, aborting" << endl;
-       return;
+            lg(Error) << "Oh snap! Race condition creating topic, aborting";
+            return;
          }
-         cout << "[INFO] Created service discovery event topic" << endl;
+         lg(Info) << "Created service discovery event topic";
       }
 
       service_discovery_topic = EventsPrx::uncheckedCast(topic->getPublisher());
    }
    else
    {
-      cout << "[INFO] IceStorm topic manager proxy not present, events disabled." << endl;
+      lg(Info) << "IceStorm topic manager proxy not present, events disabled.";
    }
 
    /* Management and discovery use separate adapters to provide a level of security,
@@ -145,19 +153,22 @@ void ServiceLocatorApp::start(
 
    management_adapter->activate();
 
-   cout << "[INFO] Activated service discovery management." << endl;
+   lg(Info) << "Activated service discovery management.";
 
    discovery_adapter = communicator->createObjectAdapter("ServiceLocatorAdapter");
 
+   ConfiguredIceLoggerPtr mIceLogger = createIceLogger(discovery_adapter);
+   getLoggerFactory().setLogOutput(mIceLogger->getLogger());
+
    ServiceLocatorPtr LocatorService = new ServiceLocatorImpl(LocatorServiceManagement);
 
    discovery_adapter->add(LocatorService, communicator->stringToIdentity("LocatorService"));
 
    discovery_adapter->activate();
 
-   cout << "[INFO] Activated service discovery." << endl;
+   lg(Info) << "Activated service discovery.";
 
-   cout << "[INFO] Waiting for requests." << endl;
+   lg(Info) << "Waiting for requests.";
 }
 
 void ServiceLocatorApp::stop()
diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index de8f0bd..93de1de 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -16,11 +16,18 @@
 
 #include "ServiceLocatorManagement.h"
 #include "ServiceManagement.h"
+#include "logger.h"
 
 using namespace std;
 using namespace AsteriskSCF::System::Discovery;
+using namespace AsteriskSCF::System::Logging;
 using namespace AsteriskSCF::Core::Discovery::V1;
 
+namespace
+{
+   Logger const &lg = getLoggerFactory().getLogger("AsteriskSCF.System.Discovery");
+}
+
 /**
  * Small internal class which is used to store information about a comparator.
  */
@@ -227,7 +234,7 @@ bool ServiceLocatorManagementImpl::isSupported(const string& compare_guid,
    }
    catch (...)
    {
-      cout << "[ERROR] An exception was raised when attempting to contact comparator " << compare_guid << "." << endl;
+      lg(Error) << "An exception was raised when attempting to contact comparator " << compare_guid << ".";
       return false;
    }
 }

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


-- 
asterisk-scf/integration/servicediscovery.git



More information about the asterisk-scf-commits mailing list