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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue May 8 17:27:31 CDT 2012


branch "master" has been updated
       via  de77e3607762845b42e3882d84300c7bb695a58e (commit)
      from  18e90fa36db599139d3f58deebc7d11faa77bd02 (commit)

Summary of changes:
 client/src/IceConfigurator.cpp             |    8 ++++--
 client/src/IceConfigurator.h               |    4 +-
 client/src/IceLogger.cpp                   |   25 ++++++++++++++++++-----
 client/test/IceConfigurator-test.cpp       |   20 ++++++++++++++++--
 include/AsteriskSCF/Logger/IceLogger.h     |   24 +++++++++++++++++-----
 server/config/testloggingserver.conf       |    2 +
 server/src/Component.cpp                   |   25 +++++++++++++++++++----
 server/src/Configuration.cpp               |   10 ++++++--
 server/src/Configuration.h                 |    9 +++++--
 server/src/LoggingServer.cpp               |    6 ++++-
 server/test/LoggingConfigurationHelper.cpp |   29 +++++++++++++++++++++++----
 11 files changed, 125 insertions(+), 37 deletions(-)


- Log -----------------------------------------------------------------
commit de77e3607762845b42e3882d84300c7bb695a58e
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue May 8 11:38:26 2012 -0500

    Changes for new retry logic.

diff --git a/client/src/IceConfigurator.cpp b/client/src/IceConfigurator.cpp
index 4f6e6ec..989fbd9 100644
--- a/client/src/IceConfigurator.cpp
+++ b/client/src/IceConfigurator.cpp
@@ -35,13 +35,15 @@ bool sortByName(const SourceConfiguration& lhs, const SourceConfiguration& rhs)
 }
 }
 
-void IceConfigurator::configured(const Configuration& logConfiguration,
+void IceConfigurator::configured(const AsteriskSCF::System::V1::OperationContextPtr& operationContext, 
+    const Configuration& logConfiguration,
     const Ice::Current&)
 {
-    return configured(logConfiguration);
+    return configured(operationContext, logConfiguration);
 }
 
-void IceConfigurator::configured(const Configuration& logConfiguration)
+void IceConfigurator::configured(const AsteriskSCF::System::V1::OperationContextPtr&, 
+    const Configuration& logConfiguration)
 {
     std::vector<std::string> oldConfig = mFactory.getLoggerNames();
     SourceConfigurationSeq newConfig = logConfiguration.sourceSettings;
diff --git a/client/src/IceConfigurator.h b/client/src/IceConfigurator.h
index 3348ecc..e597cc0 100644
--- a/client/src/IceConfigurator.h
+++ b/client/src/IceConfigurator.h
@@ -37,8 +37,8 @@ public:
     {
     }
 
-    ASTSCF_DLL_EXPORT void configured(const Configuration& logConfiguration, const Ice::Current&);
-    ASTSCF_DLL_EXPORT void configured(const Configuration& logConfiguration);
+    ASTSCF_DLL_EXPORT void configured(const AsteriskSCF::System::V1::OperationContextPtr& context, const Configuration& logConfiguration, const Ice::Current&);
+    ASTSCF_DLL_EXPORT void configured(const AsteriskSCF::System::V1::OperationContextPtr& context, const Configuration& logConfiguration);
 private:
     LoggerFactory& mFactory;
 };
diff --git a/client/src/IceLogger.cpp b/client/src/IceLogger.cpp
index 2924142..cfcb321 100644
--- a/client/src/IceLogger.cpp
+++ b/client/src/IceLogger.cpp
@@ -29,6 +29,7 @@
 
 using namespace AsteriskSCF::Core::Discovery::V1;
 using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::System::V1;
 
 void IceLogger::logs(const std::string& name, Level logLevel,
     const std::string& message)
@@ -171,19 +172,25 @@ void ConfiguredIceLogger::locateFinished(const Ice::AsyncResultPtr& r)
     }
 }
 
-void ConfiguredIceLogger::comparisonRegistered(const std::string& /* guid */,
+void ConfiguredIceLogger::comparisonRegistered(
+    const OperationContextPtr& /* operationContext */,
+    const std::string& /* guid */,
     const Ice::Current&)
 {
     // no-op
 }
 
-void ConfiguredIceLogger::comparisonUnregistered(const std::string& /* guid */,
+void ConfiguredIceLogger::comparisonUnregistered(
+    const OperationContextPtr& /* operationContext */,
+    const std::string& /* guid */,
     const Ice::Current&)
 {
     // no-op
 }
 
-void ConfiguredIceLogger::serviceRegistered(const std::string& guid,
+void ConfiguredIceLogger::serviceRegistered(
+    const OperationContextPtr& /* operationContext */,
+    const std::string& guid,
     const Ice::Current&)
 {
     if (guid == LoggingServerGuid)
@@ -192,7 +199,9 @@ void ConfiguredIceLogger::serviceRegistered(const std::string& guid,
     }
 }
 
-void ConfiguredIceLogger::serviceUnregistered(const std::string& guid,
+void ConfiguredIceLogger::serviceUnregistered(
+    const OperationContextPtr& /* operationContext */,
+    const std::string& guid,
     const Ice::Current&)
 {
     if (guid == LoggingServerGuid)
@@ -201,7 +210,9 @@ void ConfiguredIceLogger::serviceUnregistered(const std::string& guid,
     }
 }
 
-void ConfiguredIceLogger::serviceSuspended(const std::string& guid,
+void ConfiguredIceLogger::serviceSuspended(
+    const OperationContextPtr& /* operationContext */,
+    const std::string& guid,
     const Ice::Current&)
 {
     if (guid == LoggingServerGuid)
@@ -210,7 +221,9 @@ void ConfiguredIceLogger::serviceSuspended(const std::string& guid,
     }
 }
 
-void ConfiguredIceLogger::serviceUnsuspended(const std::string& guid,
+void ConfiguredIceLogger::serviceUnsuspended(
+    const OperationContextPtr& /* operationContext */,
+    const std::string& guid,
     const Ice::Current&)
 {
     if (guid == LoggingServerGuid)
diff --git a/client/test/IceConfigurator-test.cpp b/client/test/IceConfigurator-test.cpp
index 51b3e56..576670e 100644
--- a/client/test/IceConfigurator-test.cpp
+++ b/client/test/IceConfigurator-test.cpp
@@ -14,6 +14,7 @@
  * at the top of the source tree.
  */
 
+#include <IceUtil/UUID.h>
 
 #include <boost/test/unit_test.hpp>
 
@@ -21,6 +22,7 @@
 #include "IceConfigurator.h"
 
 using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::System::V1;
 
 namespace
 {
@@ -32,6 +34,18 @@ void addConfig(Configuration& cfg, const std::string& name, Level logLevel)
 
     cfg.sourceSettings.push_back(sourceConfig);
 }
+
+OperationContextPtr createContext()
+{
+    AsteriskSCF::System::V1::OperationContextPtr newContext(new AsteriskSCF::System::V1::OperationContext);
+    newContext->id = IceUtil::generateUUID();
+
+    // To make it easy to identify the "source" operation id, we set the transaction id to the 
+    // same value as the original OperationContext id. 
+    newContext->transactionId = newContext->id;
+    return newContext;
+}
+
 }
 
 BOOST_AUTO_TEST_SUITE(IceConfiguratorTest)
@@ -49,7 +63,7 @@ BOOST_AUTO_TEST_CASE(test_simple)
     addConfig(cfg, "AsteriskSCF.Core", Debug);
     addConfig(cfg, "", Error);
 
-    uut.configured(cfg);
+    uut.configured(createContext(), cfg);
 
     BOOST_CHECK_EQUAL(Error, factory.getLogger("").getEffectiveLevel());
     BOOST_CHECK_EQUAL(Info, factory.getLogger("AsteriskSCF").getEffectiveLevel());
@@ -69,11 +83,11 @@ BOOST_AUTO_TEST_CASE(test_reset)
     addConfig(cfg, "AsteriskSCF", Info);
     addConfig(cfg, "AsteriskSCF.Core", Debug);
     addConfig(cfg, "AsteriskSCF.Media", Off);
-    uut.configured(cfg);
+    uut.configured(createContext(), cfg);
 
     cfg.sourceSettings.clear();
     addConfig(cfg, "", Critical);
-    uut.configured(cfg);
+    uut.configured(createContext(), cfg);
 
     BOOST_CHECK_EQUAL(Critical, factory.getLogger("").getEffectiveLevel());
     BOOST_CHECK_EQUAL(Critical, factory.getLogger("AsteriskSCF").getEffectiveLevel());
diff --git a/include/AsteriskSCF/Logger/IceLogger.h b/include/AsteriskSCF/Logger/IceLogger.h
index dbac457..80488e1 100644
--- a/include/AsteriskSCF/Logger/IceLogger.h
+++ b/include/AsteriskSCF/Logger/IceLogger.h
@@ -74,12 +74,24 @@ public:
 
     void updateLoggerFromServiceLocator();
 
-    void comparisonRegistered(const std::string& guid, const Ice::Current&);
-    void comparisonUnregistered(const std::string& guid, const Ice::Current&);
-    void serviceRegistered(const std::string& guid, const Ice::Current&);
-    void serviceUnregistered(const std::string& guid, const Ice::Current&);
-    void serviceSuspended(const std::string& guid, const Ice::Current&);
-    void serviceUnsuspended(const std::string& guid, const Ice::Current&);
+    void comparisonRegistered(
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+        const std::string& guid, const Ice::Current&);
+    void comparisonUnregistered(
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+        const std::string& guid, const Ice::Current&);
+    void serviceRegistered(
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+        const std::string& guid, const Ice::Current&);
+    void serviceUnregistered(
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+        const std::string& guid, const Ice::Current&);
+    void serviceSuspended(
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+        const std::string& guid, const Ice::Current&);
+    void serviceUnsuspended(
+        const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+        const std::string& guid, const Ice::Current&);
 
 protected:
     /**
diff --git a/server/config/testloggingserver.conf b/server/config/testloggingserver.conf
index 22993cb..8ff96ee 100644
--- a/server/config/testloggingserver.conf
+++ b/server/config/testloggingserver.conf
@@ -3,6 +3,7 @@ IceBox.InheritProperties=1
 IceBox.Service.ServiceDiscovery=ServiceLocator:create
 IceBox.Service.Logger=LoggingService:createLoggingService
 IceBox.Service.LoggerTest=LoggingConfigurationTest:create
+Ice.ThreadPool.Client.Size=4
 
 IceBox.LoadOrder=ServiceDiscovery,Logger,LoggerTest
 
@@ -22,6 +23,7 @@ TopicManager.Proxy=ServiceDiscovery/TopicManager:default -h 127.0.0.1 -p 4421
 
 #################################################
 # Properties for service locator
+ServiceDiscovery.Standalone=yes
 ServiceDiscovery.BackplaneAdapter.Endpoints=tcp -h 127.0.0.1 -p 4410
 ServiceDiscovery.Management.ServiceAdapter.Endpoints=tcp -h 127.0.0.1 -p 4412
 ServiceDiscovery.Locator.ServiceAdapter.Endpoints=tcp -h 127.0.0.1 -p 4411
diff --git a/server/src/Component.cpp b/server/src/Component.cpp
index e258ec5..2633ae3 100644
--- a/server/src/Component.cpp
+++ b/server/src/Component.cpp
@@ -18,7 +18,9 @@
 #include <Ice/Properties.h>
 #include <IceBox/IceBox.h>
 #include <IceStorm/IceStorm.h>
+#include <IceUtil/UUID.h>
 
+#include <AsteriskSCF/System/OperationsIf.h>
 #include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
 #include <AsteriskSCF/System/Component/ConfigurationIf.h>
 
@@ -29,6 +31,7 @@
 using namespace AsteriskSCF::System::Logging;
 using namespace AsteriskSCF::Core::Discovery::V1;
 using namespace AsteriskSCF::System::Configuration::V1;
+using namespace AsteriskSCF::System::V1;
 
 namespace
 {
@@ -58,6 +61,17 @@ private:
 };
 }
 
+OperationContextPtr createContext()
+{
+    AsteriskSCF::System::V1::OperationContextPtr newContext(new AsteriskSCF::System::V1::OperationContext);
+    newContext->id = IceUtil::generateUUID();
+
+    // To make it easy to identify the "source" operation id, we set the transaction id to the 
+    // same value as the original OperationContext id. 
+    newContext->transactionId = newContext->id;
+    return newContext;
+}
+
 void LoggingService::registerWithServiceLocator(const Ice::CommunicatorPtr& communicator)
 {
     try
@@ -76,26 +90,27 @@ void LoggingService::registerWithServiceLocator(const Ice::CommunicatorPtr& comm
                     communicator->stringToProxy(locatorManagementProxyString));
 
             {
-            mServiceManagement = management->addService(mServerPrx,
+            mServiceManagement = management->addService(createContext(), mServerPrx,
                 mName + "." + LoggingServerGuid);
 
             ServiceLocatorParamsPtr params(new ServiceLocatorParams);
             params->category = LoggingServerCategory;
             params->service = serviceName;
             params->id = mName;
-            mServiceManagement->addLocatorParams(params, "");
+            mServiceManagement->addLocatorParams(createContext(), params, "");
             }
 
             // Do the same for the configuration interface.
             {
-            mConfigManagement = management->addService(mConfigurationServicePrx,
+            mConfigManagement = management->addService(createContext(), 
+                mConfigurationServicePrx,
                 IceUtil::generateUUID());
 
             ServiceLocatorParamsPtr configParams(new ServiceLocatorParams);
             configParams->category = AsteriskSCF::Configuration::LoggingService::V1::ConfigurationDiscoveryCategory;
             configParams->service = serviceName;
             configParams->id = mName;
-             mConfigManagement->addLocatorParams(configParams, "");
+            mConfigManagement->addLocatorParams(createContext(), configParams, "");
             }
         }
         else
@@ -207,7 +222,7 @@ void LoggingService::stop()
 {
     if (mServiceManagement)
     {
-        mServiceManagement->unregister();
+        mServiceManagement->unregister(createContext());
     }
 }
 
diff --git a/server/src/Configuration.cpp b/server/src/Configuration.cpp
index eb3ed8b..52f80a8 100644
--- a/server/src/Configuration.cpp
+++ b/server/src/Configuration.cpp
@@ -29,6 +29,7 @@ namespace Logging
 
 using namespace AsteriskSCF::System::Configuration::V1;
 using namespace AsteriskSCF::Configuration::LoggingService::V1;
+using namespace AsteriskSCF::System::V1;
 
 class FileItemI : public FileItem
 {
@@ -221,7 +222,8 @@ ConfigurationGroupSeq LoggerConfigurationService::getConfigurationGroups(const I
     return groups;
 }
 
-void LoggerConfigurationService::setConfiguration(const ConfigurationGroupSeq& groups, const Ice::Current&)
+void LoggerConfigurationService::setConfiguration(const OperationContextPtr& operationContext,
+     const ConfigurationGroupSeq& groups, const Ice::Current&)
 {
     class GroupsVisitor : public LoggerConfigurationGroupVisitor
     {
@@ -324,7 +326,8 @@ void LoggerConfigurationService::setConfiguration(const ConfigurationGroupSeq& g
     }
 }
 
-void LoggerConfigurationService::removeConfigurationItems(const ConfigurationGroupSeq& groups, const Ice::Current&)
+void LoggerConfigurationService::removeConfigurationItems(const OperationContextPtr& operationContext,
+    const ConfigurationGroupSeq& groups, const Ice::Current&)
 {
 
     class GroupsVisitor : public LoggerConfigurationGroupVisitor
@@ -410,7 +413,8 @@ void LoggerConfigurationService::removeConfigurationItems(const ConfigurationGro
     }
 }
 
-void LoggerConfigurationService::removeConfigurationGroups(const ConfigurationGroupSeq& groups, const Ice::Current&)
+void LoggerConfigurationService::removeConfigurationGroups(const OperationContextPtr& operationContext,
+    const ConfigurationGroupSeq& groups, const Ice::Current&)
 {
     class LoggerGroupVisitor : public LoggerConfigurationGroupVisitor
     {
diff --git a/server/src/Configuration.h b/server/src/Configuration.h
index 32772b7..efb003d 100644
--- a/server/src/Configuration.h
+++ b/server/src/Configuration.h
@@ -49,9 +49,12 @@ public:
     AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfiguration(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
     AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfigurationAll(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
     AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfigurationGroups(const Ice::Current&);
-    void setConfiguration(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
-    void removeConfigurationItems(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
-    void removeConfigurationGroups(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
+    void setConfiguration(const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+        const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
+    void removeConfigurationItems(const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+        const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
+    void removeConfigurationGroups(const AsteriskSCF::System::V1::OperationContextPtr& operationContext,
+        const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
 private:
     /**
      * Private implementation details.
diff --git a/server/src/LoggingServer.cpp b/server/src/LoggingServer.cpp
index 83fb830..7b0cdf4 100644
--- a/server/src/LoggingServer.cpp
+++ b/server/src/LoggingServer.cpp
@@ -16,12 +16,16 @@
 
 #include <iomanip>
 
+#include <IceUtil/UUID.h>
+
 #include <AsteriskSCF/Logger/Level.h>
 #include <AsteriskSCF/Logger/LogConsts.h>
+#include <AsteriskSCF/System/OperationsIf.h>
 
 #include "LoggingServer.h"
 
 using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::System::V1;
 
 const std::string LoggingServerI::LoggingPropertyPrefix =
     "AsteriskSCF.Logging.";
@@ -73,7 +77,7 @@ void LoggingServerI::setLevel(const std::string& name, Level level)
 
     if (mConfigurationListener)
     {
-        mConfigurationListener->configured(getConfiguration());
+        mConfigurationListener->configured(new OperationContext(IceUtil::generateUUID(), IceUtil::generateUUID()), getConfiguration());
     }
 }
 
diff --git a/server/test/LoggingConfigurationHelper.cpp b/server/test/LoggingConfigurationHelper.cpp
index 8df5751..3c365d5 100644
--- a/server/test/LoggingConfigurationHelper.cpp
+++ b/server/test/LoggingConfigurationHelper.cpp
@@ -20,11 +20,30 @@
 
 #include "LoggingConfigurationHelper.h"
 
+#include <IceUtil/UUID.h>
+#include <AsteriskSCF/System/OperationsIf.h>
+
 namespace
 {
     const std::string FileItemName("file");
     const std::string FormatItemName("format");
     const std::string LevelItemName("level");
+}
+
+/*
+ * for consistency with helper method defined in ice-util-cpp. logger doesn't use it because it would
+ * create a circular dependency.
+ */
+namespace AsteriskSCF
+{
+
+AsteriskSCF::System::V1::OperationContextPtr createContext()
+{
+    AsteriskSCF::System::V1::OperationContextPtr newContext(new AsteriskSCF::System::V1::OperationContext);
+    newContext->id = IceUtil::generateUUID();
+    return newContext;
+}
+
 };
 
 using namespace AsteriskSCF::System::Configuration::V1;
@@ -97,7 +116,7 @@ void LoggingConfigurationHelper::setLogOutFile(const std::string &fileName, int
     fileItem->serialNumber = serialNumber;
     generalGroup->configurationItems.insert(make_pair(FileItemName, fileItem));
     groups.push_back(generalGroup);
-    mConfigPrx->setConfiguration(groups);
+    mConfigPrx->setConfiguration(AsteriskSCF::createContext(), groups);
 }
 
 void LoggingConfigurationHelper::removeLogOutFile(const std::string &fileName)
@@ -108,7 +127,7 @@ void LoggingConfigurationHelper::removeLogOutFile(const std::string &fileName)
     fileItem->fileName = fileName;
     generalGroup->configurationItems.insert(make_pair(FileItemName, fileItem));
     groups.push_back(generalGroup);
-    mConfigPrx->removeConfigurationItems(groups);
+    mConfigPrx->removeConfigurationItems(AsteriskSCF::createContext(), groups);
 }
 
 AsteriskSCF::Configuration::LoggingService::V1::FileItemPtr LoggingConfigurationHelper::getConfiguredOutputFile()
@@ -143,7 +162,7 @@ void LoggingConfigurationHelper::setFormat(const std::string& fmtStr, int serial
     formatItem->serialNumber = serialNumber;
     generalGroup->configurationItems.insert(make_pair(FormatItemName, formatItem));
     groups.push_back(generalGroup);
-    mConfigPrx->setConfiguration(groups);
+    mConfigPrx->setConfiguration(AsteriskSCF::createContext(), groups);
 }
 
 
@@ -155,7 +174,7 @@ void LoggingConfigurationHelper::unsetFormat(const std::string& fmtStr)
     formatItem->formatSpec = fmtStr;
     generalGroup->configurationItems.insert(make_pair(FormatItemName, formatItem));
     groups.push_back(generalGroup);
-    mConfigPrx->removeConfigurationItems(groups);
+    mConfigPrx->removeConfigurationItems(AsteriskSCF::createContext(), groups);
 }
 
 AsteriskSCF::Configuration::LoggingService::V1::FormatItemPtr LoggingConfigurationHelper::getConfiguredOutputFormat()
@@ -189,7 +208,7 @@ void LoggingConfigurationHelper::setLoggingLevel(const std::string& loggerName,
     levelItem->serialNumber = serialNumber;
     generalGroup->configurationItems.insert(make_pair(loggerName + ".level", levelItem));
     groups.push_back(generalGroup);
-    mConfigPrx->setConfiguration(groups);
+    mConfigPrx->setConfiguration(AsteriskSCF::createContext(), groups);
 }
 
 AsteriskSCF::System::Logging::Level LoggingConfigurationHelper::getLoggingLevel(const std::string& loggerName)

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


-- 
asterisk-scf/release/logger.git



More information about the asterisk-scf-commits mailing list