]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Bulk update (merge) of common-agent Communications, Framework,
authorOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:22:45 +0000 (11:22 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:22:45 +0000 (11:22 -0700)
InternalProviders, and ManagementAgent source code.

68 files changed:
open-vm-tools/common-agent/Cpp/Communication/Subsystems/amqpIntegration/src/CachingConnectionFactoryObj.cpp
open-vm-tools/common-agent/Cpp/Communication/amqpCore/src/amqpCore/AmqpMessageListenerSource.cpp
open-vm-tools/common-agent/Cpp/Communication/amqpCore/src/amqpCore/BlockingQueueConsumer.cpp
open-vm-tools/common-agent/Cpp/Communication/amqpListener/src/AmqpListenerWorker.cpp
open-vm-tools/common-agent/Cpp/Communication/amqpListener/src/amqpListenerMain.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/include/Doc/PersistenceDoc/CPersistenceProtocolDoc.h
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/AppConfigUtils.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/AppConfigUtils.h
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/CAppConfig.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/CAppConfig.h
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/CApplicationContext.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/CDaemonUtils.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/CDaemonUtils.h
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/CLoggingSetter.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/CLoggingSetter.h
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/CLoggingUtils.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/CLoggingUtils.h
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/CPersistenceUtils.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/CPersistenceUtils.h
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/CThreadSignal.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/CThreadSignal.h
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/CThreadUtils.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/CThreadUtils.h
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/IAppConfig.h
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/IAppConfigWrite.h
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Common/UriUtils.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Doc/DocXml/PersistenceXml/PersistenceProtocolXml.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Exception/StackWalker.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Integration/Caf/CCafMessageCreator.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Integration/Core/CAbstractPollableChannel.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Integration/Core/CIntegrationAppContext.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Integration/Core/CIntegrationAppContext.h
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Integration/Core/CSimpleAsyncTaskExecutor.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Integration/Core/CSimpleAsyncTaskExecutor.h
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Integration/Core/CSimpleAsyncTaskExecutorState.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Integration/Core/CSimpleAsyncTaskExecutorState.h
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Integration/Core/CSourcePollingChannelAdapter.cpp
open-vm-tools/common-agent/Cpp/Framework/Framework/src/Integration/Core/CSourcePollingChannelAdapter.h
open-vm-tools/common-agent/Cpp/Framework/Subsystems/CafIntegration/src/CErrorToResponseTransformerInstance.cpp
open-vm-tools/common-agent/Cpp/InternalProviders/Config_Provider/src/ConfigProvider.cpp
open-vm-tools/common-agent/Cpp/InternalProviders/Install_Provider/src/InstallProvider.cpp
open-vm-tools/common-agent/Cpp/InternalProviders/RemoteCommand_Provider/src/RemoteCommandProvider.cpp
open-vm-tools/common-agent/Cpp/InternalProviders/TestInfra_Provider/src/TestInfraProvider.cpp
open-vm-tools/common-agent/Cpp/ManagementAgent/ManagementAgent/src/CManagementAgentHostWork.cpp
open-vm-tools/common-agent/Cpp/ManagementAgent/ManagementAgent/src/ManagementAgentHostMain.cpp
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CAttachmentRequestTransformerInstance.cpp
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CCollectSchemaExecutor.cpp
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CConfigEnv.cpp
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CConfigEnv.h
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CConfigEnvMerge.cpp
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CConfigEnvMerge.h
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CConfigEnvOutboundChannelAdapterInstance.cpp
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CMonitorReadingMessageSource.cpp
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CMonitorReadingMessageSource.h
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CPersistenceInboundChannelAdapterInstance.cpp
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CPersistenceMerge.cpp
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CPersistenceNamespaceDb.cpp
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CPersistenceNamespaceDb.h
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CPersistenceOutboundChannelAdapterInstance.cpp
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CProviderCollectSchemaExecutor.cpp
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CProviderExecutorRequestHandler.cpp
open-vm-tools/common-agent/Cpp/ManagementAgent/Subsystems/MaIntegration/src/CProviderExecutorRequestHandler.h
open-vm-tools/common-agent/etc/config/CommAmqpListener-appconfig
open-vm-tools/common-agent/etc/config/ma-appconfig
open-vm-tools/common-agent/etc/config/providerFx-appconfig
open-vm-tools/common-agent/etc/install/caf-dbg.sh
open-vm-tools/common-agent/etc/install/install.sh
open-vm-tools/common-agent/etc/scripts/caf-common

index 75ad2d7b9e96a8dbf83cb1d504d8ed0383b13fe7..d84b7277ba4769a2ce246355fc592f4036a78834 100644 (file)
@@ -21,14 +21,20 @@ CachingConnectionFactoryObj::~CachingConnectionFactoryObj() {
 void CachingConnectionFactoryObj::initializeBean(
                const IBean::Cargs& ctorArgs,
                const IBean::Cprops& properties) {
-       CAF_CM_FUNCNAME_VALIDATE("initializeBean");
+       CAF_CM_FUNCNAME("initializeBean");
        CAF_CM_PRECOND_ISNOTINITIALIZED(_factory);
        CAF_CM_VALIDATE_STL_EMPTY(ctorArgs);
 
        const std::string persistenceDir = AppConfigUtils::getRequiredString(
                        "persistence_dir");
-       const SmartPtrCPersistenceProtocolDoc persistenceProtocol = CPersistenceUtils::loadPersistenceProtocol(
-                       persistenceDir);
+       const SmartPtrCPersistenceProtocolDoc persistenceProtocol =
+                       CPersistenceUtils::loadPersistenceProtocol(persistenceDir);
+
+       if (persistenceProtocol.IsNull()) {
+               CAF_CM_EXCEPTIONEX_VA1(IllegalStateException, ERROR_INVALID_STATE,
+                               "Persistence protocol is empty... Comm must be configured - %s",
+                               persistenceDir.c_str());
+       }
 
        UriUtils::SUriRecord uri;
        UriUtils::parseUriString(persistenceProtocol->getUri(), uri);
index fce9bc3a2b261b7e2ee747c8b70758278a136e73..876dce8c74bc3276b5107a09291e609b8370f2c1 100644 (file)
@@ -66,18 +66,20 @@ bool AmqpMessageListenerSource::doSend(
 }
 
 SmartPtrIIntMessage AmqpMessageListenerSource::doReceive(const int32 timeout) {
-       CAF_CM_FUNCNAME_VALIDATE("doReceive");
+       CAF_CM_FUNCNAME("doReceive");
        CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
        gpointer data = NULL;
        if (timeout < 0) {
                // blocking
-               data = g_async_queue_pop(_messageQueue);
+               CAF_CM_EXCEPTIONEX_VA1(UnsupportedOperationException, E_INVALIDARG,
+                       "Infinite blocking is not supported for a polled channel: %s", _id.c_str());
+               //data = g_async_queue_pop(_messageQueue);
        } else if (timeout == 0) {
                // immediate
                data = g_async_queue_try_pop(_messageQueue);
        } else {
                // timed
-               gint64 microTimeout = timeout * 1000;
+               guint64 microTimeout = static_cast<guint64>(timeout) * 1000;
                data = g_async_queue_timeout_pop(_messageQueue, microTimeout);
        }
 
index 7f1bf7a55495eb16dfde683f921dc85da916d448..9e59c724432d9171bb037a71378ea12bd0e6de84 100644 (file)
@@ -95,7 +95,7 @@ SmartPtrIIntMessage BlockingQueueConsumer::nextMessage(int32 timeout) {
        CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
        CAF_CM_ASSERT(_isRunning);
 
-       gint64 microTimeout = timeout * 1000;
+       guint64 microTimeout = static_cast<guint64>(timeout) * 1000;
        gpointer data = g_async_queue_timeout_pop(_deliveryQueue, microTimeout);
 
        checkShutdown();
index 67def663ab85c48ef9b542254b0bbf88900b913f..1c4a2f079f9ba86fe03736536aea2c24b7ce57e1 100644 (file)
@@ -34,8 +34,7 @@ void AmqpListenerWorker::doWork() {
        SmartPtrCIntegrationAppContext intAppContext;
        try {
                CLoggingUtils::setStartupConfigFile(
-                       AppConfigUtils::getRequiredString(_sAppConfigGlobalParamLogConfigFile));
-               CLoggingUtils::setLogDir(
+                       AppConfigUtils::getRequiredString(_sAppConfigGlobalParamLogConfigFile),
                        AppConfigUtils::getRequiredString(_sAppConfigGlobalParamLogDir));
 
                uint32 intStartupTimeout = AppConfigUtils::getOptionalUint32(
index 447bfe50910aaa41b1b8f5312199f4977a540689..c0b173c5d7eb194e213ceef9e75973595b491a74 100644 (file)
@@ -97,7 +97,8 @@ int32 main(int32 argc, char** argv) {
                CWinService::initialize(_gAmqpListenerWorker);
                CWinService::execute(argc, argv);
 #else
-               Cdeqstr parts = CStringUtils::split(argv[0], G_DIR_SEPARATOR);
+               const std::string procPath = argv[0];
+               Cdeqstr parts = CStringUtils::split(procPath, G_DIR_SEPARATOR);
                std::string procName = "CommAmqpListener";
                if (parts.size()) {
                        procName = parts.back();
@@ -106,14 +107,14 @@ int32 main(int32 argc, char** argv) {
                CDaemonUtils::MakeDaemon(
                        argc,
                        argv,
-                       procName.c_str(),
+                       procPath,
+                       procName,
                        TermHandler,
                        _gDaemonized,
                        _gSysLogInfos);
 
                CLoggingUtils::setStartupConfigFile(
-                       AppConfigUtils::getRequiredString(_sAppConfigGlobalParamLogConfigFile));
-               CLoggingUtils::setLogDir(
+                       AppConfigUtils::getRequiredString(_sAppConfigGlobalParamLogConfigFile),
                        AppConfigUtils::getRequiredString(_sAppConfigGlobalParamLogDir));
 
                _gAmqpListenerWorker->doWork();
index 681b4e39ec4e7278c015a95f2a5277f5cf9e90a2..8e01b72edcbaaffb95d5c7d5f678edba44fddbd1 100644 (file)
@@ -26,6 +26,8 @@ public:
        void initialize(
                        const std::string& protocolName = std::string(),
                        const std::string& uri = std::string(),
+                       const std::string& uriAmqp = std::string(),
+                       const std::string& uriTunnel = std::string(),
                        const std::string& tlsCert = std::string(),
                        const std::string& tlsProtocol = std::string(),
                        const Cdeqstr& tlsCipherCollection = Cdeqstr(),
@@ -35,6 +37,8 @@ public:
                if (! _isInitialized) {
                        _protocolName = protocolName;
                        _uri = uri;
+                       _uriAmqp = uriAmqp;
+                       _uriTunnel = uriTunnel;
                        _tlsCert = tlsCert;
                        _tlsProtocol = tlsProtocol;
                        _tlsCipherCollection = tlsCipherCollection;
@@ -58,6 +62,16 @@ public:
                return _uri;
        }
 
+       /// Accessor for the UriAmqp
+       std::string getUriAmqp() const {
+               return _uriAmqp;
+       }
+
+       /// Accessor for the UriTunnel
+       std::string getUriTunnel() const {
+               return _uriTunnel;
+       }
+
        /// Accessor for the TlsCert
        std::string getTlsCert() const {
                return _tlsCert;
@@ -91,6 +105,8 @@ public:
 private:
        std::string _protocolName;
        std::string _uri;
+       std::string _uriAmqp;
+       std::string _uriTunnel;
        std::string _tlsCert;
        std::string _tlsProtocol;
        Cdeqstr _tlsCipherCollection;
index 253738d6f79a1af189ee40b8d0bc8464f0f0a5db..a78fe0297b49ce823c4e1312c5977ff602a1438e 100644 (file)
@@ -25,6 +25,13 @@ uint32 AppConfigUtils::getRequiredUint32(
        return rc;
 }
 
+int32 AppConfigUtils::getRequiredInt32(
+       const std::string& parameterName) {
+       int32 rc;
+       getAppConfig()->getGlobalInt32(parameterName, rc, IConfigParams::PARAM_REQUIRED);
+       return rc;
+}
+
 bool AppConfigUtils::getRequiredBoolean(
        const std::string& parameterName) {
        bool rc;
@@ -46,6 +53,13 @@ uint32 AppConfigUtils::getOptionalUint32(
        return rc;
 }
 
+int32 AppConfigUtils::getOptionalInt32(
+       const std::string& parameterName) {
+       int32 rc = 0;
+       getAppConfig()->getGlobalInt32(parameterName, rc, IConfigParams::PARAM_OPTIONAL);
+       return rc;
+}
+
 bool AppConfigUtils::getOptionalBoolean(
        const std::string& parameterName) {
        bool rc = false;
@@ -69,6 +83,14 @@ uint32 AppConfigUtils::getRequiredUint32(
        return rc;
 }
 
+int32 AppConfigUtils::getRequiredInt32(
+       const std::string& sectionName,
+       const std::string& parameterName) {
+       int32 rc;
+       getAppConfig()->getInt32(sectionName, parameterName, rc, IConfigParams::PARAM_REQUIRED);
+       return rc;
+}
+
 bool AppConfigUtils::getRequiredBoolean(
        const std::string& sectionName,
        const std::string& parameterName) {
@@ -93,6 +115,14 @@ uint32 AppConfigUtils::getOptionalUint32(
        return rc;
 }
 
+int32 AppConfigUtils::getOptionalInt32(
+       const std::string& sectionName,
+       const std::string& parameterName) {
+       int32 rc = 0;
+       getAppConfig()->getInt32(sectionName, parameterName, rc, IConfigParams::PARAM_OPTIONAL);
+       return rc;
+}
+
 bool AppConfigUtils::getOptionalBoolean(
        const std::string& sectionName,
        const std::string& parameterName) {
index 8ad047b34bd26fb8ee3fe09a8e08a8234fc195d7..e180242c6a43be11de89623ca647918e491b6807 100644 (file)
@@ -15,10 +15,12 @@ namespace AppConfigUtils {
 
        std::string COMMONAGGREGATOR_LINKAGE getRequiredString(const std::string& parameterName);
        uint32 COMMONAGGREGATOR_LINKAGE getRequiredUint32(const std::string& parameterName);
+       int32 COMMONAGGREGATOR_LINKAGE getRequiredInt32(const std::string& parameterName);
        bool COMMONAGGREGATOR_LINKAGE getRequiredBoolean(const std::string& parameterName);
 
        std::string COMMONAGGREGATOR_LINKAGE getOptionalString(const std::string& parameterName);
        uint32 COMMONAGGREGATOR_LINKAGE getOptionalUint32(const std::string& parameterName);
+       int32 COMMONAGGREGATOR_LINKAGE getOptionalInt32(const std::string& parameterName);
        bool COMMONAGGREGATOR_LINKAGE getOptionalBoolean(const std::string& parameterName);
 
        std::string COMMONAGGREGATOR_LINKAGE getRequiredString(
@@ -27,6 +29,9 @@ namespace AppConfigUtils {
        uint32 COMMONAGGREGATOR_LINKAGE getRequiredUint32(
                const std::string& sectionName,
                const std::string& parameterName);
+       int32 COMMONAGGREGATOR_LINKAGE getRequiredInt32(
+               const std::string& sectionName,
+               const std::string& parameterName);
        bool COMMONAGGREGATOR_LINKAGE getRequiredBoolean(
                const std::string& sectionName,
                const std::string& parameterName);
@@ -37,6 +42,9 @@ namespace AppConfigUtils {
        uint32 COMMONAGGREGATOR_LINKAGE getOptionalUint32(
                const std::string& sectionName,
                const std::string& parameterName);
+       int32 COMMONAGGREGATOR_LINKAGE getOptionalInt32(
+               const std::string& sectionName,
+               const std::string& parameterName);
        bool COMMONAGGREGATOR_LINKAGE getOptionalBoolean(
                const std::string& sectionName,
                const std::string& parameterName);
index 4d53ad1c31acdb67d586f9e8c70d5d3a91c9d96e..aec3aa25176124de128106cbbc822b227bfa989e 100644 (file)
@@ -232,8 +232,8 @@ bool CAppConfig::getUint32(
                parameterName.c_str(),
                IConfigParams::PARAM_OPTIONAL);
        if (param) {
-               if (g_variant_is_of_type(param, G_VARIANT_TYPE_UINT32)) {
-                       value = g_variant_get_uint32(param);
+               if (g_variant_is_of_type(param, G_VARIANT_TYPE_INT32)) {
+                       value = static_cast<uint32>(g_variant_get_int32(param));
                        paramFound = true;
                } else {
                        std::string valueStr;
@@ -252,6 +252,43 @@ bool CAppConfig::getUint32(
        return paramFound;
 }
 
+bool CAppConfig::getInt32(
+       const std::string& sectionName,
+       const std::string& parameterName,
+       int32& value,
+       const IConfigParams::EParamDisposition disposition) {
+       CAF_CM_FUNCNAME("getInt32");
+       CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
+       CAF_CM_VALIDATE_STRING(sectionName);
+       CAF_CM_VALIDATE_STRING(parameterName);
+
+       bool paramFound = false;
+
+       SmartPtrIConfigParams params = getParameters(sectionName);
+       GVariant* param = params->lookup(
+               parameterName.c_str(),
+               IConfigParams::PARAM_OPTIONAL);
+       if (param) {
+               if (g_variant_is_of_type(param, G_VARIANT_TYPE_INT32)) {
+                       value = g_variant_get_int32(param);
+                       paramFound = true;
+               } else {
+                       std::string valueStr;
+                       getString(sectionName, parameterName, valueStr, disposition);
+                       value = CStringConv::fromString<int32>(valueStr);
+               }
+       } else {
+               if (IConfigParams::PARAM_REQUIRED == disposition) {
+                       CAF_CM_EXCEPTION_VA2(ERROR_TAG_NOT_FOUND,
+                               "Required config parameter [%s] is missing from section [%s]",
+                               parameterName.c_str(),
+                               sectionName.c_str());
+               }
+       }
+
+       return paramFound;
+}
+
 bool CAppConfig::getBoolean(
        const std::string& sectionName,
        const std::string& parameterName,
@@ -305,6 +342,13 @@ bool CAppConfig::getGlobalUint32(
        return getUint32(_sGlobalsSectionName, parameterName, value, disposition);
 }
 
+bool CAppConfig::getGlobalInt32(
+       const std::string& parameterName,
+       int32& value,
+       const IConfigParams::EParamDisposition disposition) {
+       return getInt32(_sGlobalsSectionName, parameterName, value, disposition);
+}
+
 bool CAppConfig::getGlobalBoolean(
        const std::string& parameterName,
        bool& value,
@@ -337,7 +381,21 @@ void CAppConfig::setUint32(
        CAF_CM_VALIDATE_STRING(parameterName);
 
        SmartPtrIConfigParams params = getParameters(sectionName);
-       params->insert(g_strdup(parameterName.c_str()), g_variant_new_uint32(
+       params->insert(g_strdup(parameterName.c_str()), g_variant_new_int32(
+               value));
+}
+
+void CAppConfig::setInt32(
+       const std::string& sectionName,
+       const std::string& parameterName,
+       const int32& value) {
+       CAF_CM_FUNCNAME_VALIDATE("setInt32");
+       CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
+       CAF_CM_VALIDATE_STRING(sectionName);
+       CAF_CM_VALIDATE_STRING(parameterName);
+
+       SmartPtrIConfigParams params = getParameters(sectionName);
+       params->insert(g_strdup(parameterName.c_str()), g_variant_new_int32(
                value));
 }
 
@@ -367,6 +425,12 @@ void CAppConfig::setGlobalUint32(
        setUint32(_sGlobalsSectionName, parameterName, value);
 }
 
+void CAppConfig::setGlobalInt32(
+       const std::string& parameterName,
+       const int32& value) {
+       setInt32(_sGlobalsSectionName, parameterName, value);
+}
+
 void CAppConfig::setGlobalBoolean(
        const std::string& parameterName,
        const bool& value) {
@@ -420,13 +484,13 @@ std::string CAppConfig::resolveValue(const std::string& value) {
 
                                if (!resolved) {
                                        try {
-                                               uint32 uval = 0;
-                                               getUint32(
+                                               int32 uval = 0;
+                                               getInt32(
                                                                section,
                                                                varName,
                                                                uval,
                                                                IConfigParams::PARAM_REQUIRED);
-                                               configVal = CStringConv::toString<uint32>(uval);
+                                               configVal = CStringConv::toString<int32>(uval);
                                                resolved = true;
                                        } catch (CCafException *ex) {
                                                if (ex->getError() == DISP_E_TYPEMISMATCH) {
@@ -685,7 +749,7 @@ void CAppConfig::internalLoadParameters(
 
                                for (gsize idx = 0; idx < numKeys; idx++) {
                                        // There is no way to tell if a value is an integer or string.
-                                       // We want to insert the value as either string or uint32 so
+                                       // We want to insert the value as either string or int32 so
                                        // try to read the value as an integer.  If it cannot be read
                                        // as an integer then insert it as a string.
                                        gint iValue = g_key_file_get_integer(
@@ -694,7 +758,7 @@ void CAppConfig::internalLoadParameters(
                                                keys[idx],
                                                &configError);
                                        if (!configError) {
-                                               configParams->insert(g_strdup(keys[idx]), g_variant_new_uint32(
+                                               configParams->insert(g_strdup(keys[idx]), g_variant_new_int32(
                                                        iValue));
 
                                                if (isGlobals) {
@@ -895,7 +959,7 @@ void CAppConfig::validateGlobals(const SmartPtrIConfigParams& globals) {
        GVariant* thread_stack_size_kb = globals->lookup(
                _sAppConfigGlobalThreadStackSizeKb,
                IConfigParams::PARAM_REQUIRED);
-       CAF_CM_ASSERT(g_variant_is_of_type(thread_stack_size_kb, G_VARIANT_TYPE_UINT32));
+       CAF_CM_ASSERT(g_variant_is_of_type(thread_stack_size_kb, G_VARIANT_TYPE_INT32));
 }
 
 std::string CAppConfig::calcConfigPath(
index b0884194c2705470cd5d0eaceb0f3574bd3c26e5..75759ed3b17523b399e3f8f925bde38ca6274d68 100644 (file)
@@ -36,6 +36,14 @@ public: // IAppConfig
                        const IConfigParams::EParamDisposition disposition =
                                IConfigParams::PARAM_REQUIRED);
 
+       bool
+               getInt32(
+                       const std::string& sectionName,
+                       const std::string& parameterName,
+                       int32& value,
+                       const IConfigParams::EParamDisposition disposition =
+                               IConfigParams::PARAM_REQUIRED);
+
        bool
                getBoolean(
                        const std::string& sectionName,
@@ -58,6 +66,13 @@ public: // IAppConfig
                        const IConfigParams::EParamDisposition disposition =
                                IConfigParams::PARAM_REQUIRED);
 
+       bool
+               getGlobalInt32(
+                       const std::string& parameterName,
+                       int32& value,
+                       const IConfigParams::EParamDisposition disposition =
+                               IConfigParams::PARAM_REQUIRED);
+
        bool
                getGlobalBoolean(
                        const std::string& parameterName,
@@ -86,6 +101,10 @@ public: // IAppConfigWrite
                                                const std::string& parameterName,
                                                const uint32& value);
 
+       void setInt32(const std::string& sectionName,
+                                         const std::string& parameterName,
+                                         const int32& value);
+
        void setBoolean(const std::string& sectionName,
                                                 const std::string& parameterName,
                                                 const bool& value);
@@ -96,6 +115,9 @@ public: // IAppConfigWrite
        void setGlobalUint32(const std::string& parameterName,
                                                                const uint32& value);
 
+       void setGlobalInt32(const std::string& parameterName,
+                                                         const int32& value);
+
        void setGlobalBoolean(const std::string& parameterName,
                                                                 const bool& value);
 
index ab1cdfb1a787b37fef6d2437be65815c55dac67c..30cdfd966964e0b713d85706ff112476d3752942 100644 (file)
@@ -21,147 +21,120 @@ CApplicationContext::~CApplicationContext(void) {
 
 void CApplicationContext::initialize() {
        CAF_CM_FUNCNAME_VALIDATE("initialize");
+       CAF_CM_PRECOND_ISNOTINITIALIZED(m_isInitialized);
 
-       CAF_CM_ENTER {
-               CAF_CM_PRECOND_ISNOTINITIALIZED(m_isInitialized);
+       const std::string beanConfigFile = getDefaultBeanConfigFile();
 
-               const std::string beanConfigFile = getDefaultBeanConfigFile();
+       Cdeqstr filenameCollection;
+       filenameCollection.push_front(beanConfigFile);
 
-               Cdeqstr filenameCollection;
-               filenameCollection.push_front(beanConfigFile);
-
-               initialize(filenameCollection);
-       }
-       CAF_CM_EXIT;
+       initialize(filenameCollection);
 }
 
 void CApplicationContext::initialize(const Cdeqstr& filenameCollection) {
        CAF_CM_FUNCNAME("initialize");
+       CAF_CM_PRECOND_ISNOTINITIALIZED(m_isInitialized);
+       CAF_CM_VALIDATE_STL(filenameCollection);
 
-       CAF_CM_ENTER {
-               CAF_CM_PRECOND_ISNOTINITIALIZED(m_isInitialized);
-               CAF_CM_VALIDATE_STL(filenameCollection);
+       for (TConstIterator<Cdeqstr> filenameIter(filenameCollection);
+               filenameIter; filenameIter++) {
+               const std::string beanConfigFile = *filenameIter;
 
-               for (TConstIterator<Cdeqstr> filenameIter(filenameCollection);
-                       filenameIter; filenameIter++) {
-                       const std::string beanConfigFile = *filenameIter;
+               parseBeanConfig(
+                               beanConfigFile,
+                               _beanCollection);
+       }
 
-                       parseBeanConfig(
-                                       beanConfigFile,
-                                       _beanCollection);
-               }
+       CBeanGraph beanGraph;
+       createBeanGraph(
+                       _beanCollection,
+                       beanGraph,
+                       _beanTopologySort);
 
-               CBeanGraph beanGraph;
-               createBeanGraph(
+       try {
+               initializeBeans(
                                _beanCollection,
-                               beanGraph,
                                _beanTopologySort);
+       } CAF_CM_CATCH_ALL;
 
+       if (CAF_CM_ISEXCEPTION) {
+               CAF_CM_LOG_CRIT_CAFEXCEPTION;
+               CCafException *ex = CAF_CM_GETEXCEPTION;
+               ex->AddRef();
+               CAF_CM_CLEAREXCEPTION;
                try {
-                       initializeBeans(
-                                       _beanCollection,
-                                       _beanTopologySort);
+                       terminateBeans(_beanTopologySort);
                } CAF_CM_CATCH_ALL;
-               if (CAF_CM_ISEXCEPTION) {
-                       CAF_CM_LOG_CRIT_CAFEXCEPTION;
-                       CCafException *ex = CAF_CM_GETEXCEPTION;
-                       ex->AddRef();
-                       CAF_CM_CLEAREXCEPTION;
-                       try {
-                               terminateBeans(_beanTopologySort);
-                       } CAF_CM_CATCH_ALL;
-                       CAF_CM_LOG_CRIT_CAFEXCEPTION;
-                       CAF_CM_CLEAREXCEPTION;
-                       _beanTopologySort.clear();
-                       _beanCollection.clear();
-                       CAF_CM_GETEXCEPTION = ex;
-                       CAF_CM_THROWEXCEPTION;
-               }
-               m_isInitialized = true;
+               CAF_CM_LOG_CRIT_CAFEXCEPTION;
+               CAF_CM_CLEAREXCEPTION;
+               _beanTopologySort.clear();
+               _beanCollection.clear();
+               CAF_CM_GETEXCEPTION = ex;
+               CAF_CM_THROWEXCEPTION;
        }
-       CAF_CM_EXIT;
+
+       m_isInitialized = true;
 }
 
 void CApplicationContext::terminate() {
        CAF_CM_FUNCNAME_VALIDATE("terminate");
+       CAF_CM_PRECOND_ISINITIALIZED(m_isInitialized);
 
-       CAF_CM_ENTER {
-               CAF_CM_PRECOND_ISINITIALIZED(m_isInitialized);
-               terminateBeans(_beanTopologySort);
-               _beanTopologySort.clear();
-               _beanCollection.clear();
-               _filenameCollection.clear();
-       }
-       CAF_CM_EXIT;
+       terminateBeans(_beanTopologySort);
+       _beanTopologySort.clear();
+       _beanCollection.clear();
+       _filenameCollection.clear();
 }
 
 IAppContext::SmartPtrCBeans CApplicationContext::getBeans() const {
        CAF_CM_FUNCNAME_VALIDATE("getBeans");
+       CAF_CM_PRECOND_ISINITIALIZED(m_isInitialized);
 
        SmartPtrCBeans beans;
        beans.CreateInstance();
-
-       CAF_CM_ENTER {
-               CAF_CM_PRECOND_ISINITIALIZED(m_isInitialized);
-
-               for (TSmartConstMapIterator<CBeanCollection> beanIter(_beanCollection);
-                       beanIter; beanIter++) {
-                       beans->insert(CBeans::value_type(
-                               beanIter.getKey().c_str(),
-                               beanIter->_bean));
-               }
+       for (TSmartConstMapIterator<CBeanCollection> beanIter(_beanCollection);
+               beanIter; beanIter++) {
+               beans->insert(CBeans::value_type(
+                       beanIter.getKey().c_str(),
+                       beanIter->_bean));
        }
-       CAF_CM_EXIT;
 
        return beans;
 }
 
 SmartPtrIBean CApplicationContext::getBean(const std::string& beanId) const {
        CAF_CM_FUNCNAME("getBean");
-
-       SmartPtrIBean rc;
-
-       CAF_CM_ENTER {
-               CAF_CM_PRECOND_ISINITIALIZED(m_isInitialized);
-               CAF_CM_VALIDATE_STRING(beanId);
-
-               CBeanCollection::const_iterator iter = _beanCollection.find(beanId);
-               if (iter == _beanCollection.end()) {
-                       CAF_CM_EXCEPTIONEX_VA1(
-                                       NoSuchElementException,
-                                       0,
-                                       "Bean not found - %s",
-                                       beanId.c_str());
-               }
-
-               CAF_CM_LOG_DEBUG_VA1(
-                               "Bean Found - %s",
+       CAF_CM_PRECOND_ISINITIALIZED(m_isInitialized);
+       CAF_CM_VALIDATE_STRING(beanId);
+
+       CBeanCollection::const_iterator iter = _beanCollection.find(beanId);
+       if (iter == _beanCollection.end()) {
+               CAF_CM_EXCEPTIONEX_VA1(
+                               NoSuchElementException,
+                               0,
+                               "Bean not found - %s",
                                beanId.c_str());
-               rc = iter->second->_bean;
        }
-       CAF_CM_EXIT;
 
-       return rc;
+       CAF_CM_LOG_DEBUG_VA1(
+                       "Bean Found - %s",
+                       beanId.c_str());
+       return iter->second->_bean;
 }
 
 std::string CApplicationContext::getDefaultBeanConfigFile() const {
-
        CAF_CM_FUNCNAME("parseBeanConfig");
 
-       std::string beanConfigFile;
-
-       CAF_CM_ENTER {
-               // Get the bean config file
-               beanConfigFile = AppConfigUtils::getRequiredString("bean_config_file");
-               if (!FileSystemUtils::doesFileExist(beanConfigFile)) {
-                       CAF_CM_EXCEPTIONEX_VA1(
-                                       FileNotFoundException,
-                                       0,
-                                       "The bean config file [%s] does not exist.",
-                                       beanConfigFile.c_str());
-               }
+       // Get the bean config file
+       const std::string beanConfigFile =
+                       AppConfigUtils::getRequiredString("bean_config_file");
+       if (!FileSystemUtils::doesFileExist(beanConfigFile)) {
+               CAF_CM_EXCEPTIONEX_VA1(
+                               FileNotFoundException,
+                               0,
+                               "The bean config file [%s] does not exist.",
+                               beanConfigFile.c_str());
        }
-       CAF_CM_EXIT;
 
        return beanConfigFile;
 }
@@ -169,151 +142,145 @@ std::string CApplicationContext::getDefaultBeanConfigFile() const {
 void CApplicationContext::parseBeanConfig(
        const std::string& beanConfigFile,
        CBeanCollection& beanCollection) const {
-
        CAF_CM_FUNCNAME("parseBeanConfig");
-
-       CAF_CM_ENTER {
-               CAF_CM_VALIDATE_STRING(beanConfigFile);
-
-               CAF_CM_LOG_DEBUG_VA1("Parsing bean config file %s", beanConfigFile.c_str());
-
-               // We will look up class references early in the process to fail as early
-               // as possible and to make logging better.
-               // Parse the bean config file
-               CXmlElement::SmartPtrCElementCollection rootElements =
-                               CXmlUtils::parseFile(beanConfigFile, "caf:beans")->getAllChildren();
-               for (TSmartConstMultimapIterator<CXmlElement::CElementCollection> rootChild(*rootElements);
-                               rootChild;
-                               rootChild++) {
-
-                       // if the child is a bean...
-                       if (rootChild->getName() == "bean") {
-                               // Syntactic sugar
-                               const SmartPtrCXmlElement beanElement = *rootChild;
-
-                               // Bean attributes
-                               const std::string beanId = beanElement->findRequiredAttribute("id");
-                               CAF_CM_LOG_DEBUG_VA1("Parsing bean [id=%s]", beanId.c_str());
-                               const std::string beanClass = beanElement->findRequiredAttribute("class");
-                               CAF_CM_LOG_DEBUG_VA2(
-                                               "Checking bean class [id=%s][class=%s]",
+       CAF_CM_VALIDATE_STRING(beanConfigFile);
+       CAF_CM_LOG_DEBUG_VA1("Parsing bean config file %s", beanConfigFile.c_str());
+
+       // We will look up class references early in the process to fail as early
+       // as possible and to make logging better.
+       // Parse the bean config file
+       CXmlElement::SmartPtrCElementCollection rootElements =
+                       CXmlUtils::parseFile(beanConfigFile, "caf:beans")->getAllChildren();
+       for (TSmartConstMultimapIterator<CXmlElement::CElementCollection> rootChild(*rootElements);
+                       rootChild;
+                       rootChild++) {
+
+               // if the child is a bean...
+               if (rootChild->getName() == "bean") {
+                       // Syntactic sugar
+                       const SmartPtrCXmlElement beanElement = *rootChild;
+
+                       // Bean attributes
+                       const std::string beanId = beanElement->findRequiredAttribute("id");
+                       CAF_CM_LOG_DEBUG_VA1("Parsing bean [id=%s]", beanId.c_str());
+                       const std::string beanClass = beanElement->findRequiredAttribute("class");
+                       CAF_CM_LOG_DEBUG_VA2(
+                                       "Checking bean class [id=%s][class=%s]",
+                                       beanId.c_str(),
+                                       beanClass.c_str());
+                       if (!CEcmSubSystemRegistry::IsRegistered(beanClass)) {
+                               CAF_CM_EXCEPTIONEX_VA3(
+                                               NoSuchElementException,
+                                               0,
+                                               "Bean class %s is not registered. Fix the AppConfig file. "
+                                               "[bean id=%s][bean_config_file=%s]",
+                                               beanClass.c_str(),
                                                beanId.c_str(),
-                                               beanClass.c_str());
-                               if (!CEcmSubSystemRegistry::IsRegistered(beanClass)) {
-                                       CAF_CM_EXCEPTIONEX_VA3(
-                                                       NoSuchElementException,
-                                                       0,
-                                                       "Bean class %s is not registered. Fix the AppConfig file. "
-                                                       "[bean id=%s][bean_config_file=%s]",
-                                                       beanClass.c_str(),
-                                                       beanId.c_str(),
-                                                       beanConfigFile.c_str());
-                               }
+                                               beanConfigFile.c_str());
+                       }
 
-                               // get optional constructor args and properties
-                               CBeanCtorArgCollection beanCtorArgs;
-                               Cmapstrstr beanProperties;
-                               CAF_CM_LOG_DEBUG_VA1("Parsing bean ctor args and properties [id=%s]", beanId.c_str());
-                               CXmlElement::SmartPtrCElementCollection beanElements = beanElement->getAllChildren();
-                               for (TSmartConstMultimapIterator<CXmlElement::CElementCollection> beanChild(*beanElements);
-                                               beanChild;
-                                               beanChild++) {
-                                       if (beanChild->getName() == "property") {
-                                               // Syntactic sugar
-                                               const SmartPtrCXmlElement propArgElement = *beanChild;
-
-                                               // property attributes
-                                               const std::string name = propArgElement->findRequiredAttribute("name");
-                                               const std::string value = propArgElement->findRequiredAttribute("value");
-                                               if (!beanProperties.insert(std::make_pair(name, value)).second) {
-                                                       CAF_CM_EXCEPTIONEX_VA3(
-                                                                       DuplicateElementException,
-                                                                       0,
-                                                                       "Bean property name is duplicated. "
-                                                                       "[bean id=%s][property name=%s][bean_config_file=%s]",
-                                                                       beanId.c_str(),
-                                                                       name.c_str(),
-                                                                       beanConfigFile.c_str());
-                                               }
+                       // get optional constructor args and properties
+                       CBeanCtorArgCollection beanCtorArgs;
+                       Cmapstrstr beanProperties;
+                       CAF_CM_LOG_DEBUG_VA1("Parsing bean ctor args and properties [id=%s]", beanId.c_str());
+                       CXmlElement::SmartPtrCElementCollection beanElements = beanElement->getAllChildren();
+                       for (TSmartConstMultimapIterator<CXmlElement::CElementCollection> beanChild(*beanElements);
+                                       beanChild;
+                                       beanChild++) {
+                               if (beanChild->getName() == "property") {
+                                       // Syntactic sugar
+                                       const SmartPtrCXmlElement propArgElement = *beanChild;
+
+                                       // property attributes
+                                       const std::string name = propArgElement->findRequiredAttribute("name");
+                                       const std::string value = propArgElement->findRequiredAttribute("value");
+                                       if (!beanProperties.insert(std::make_pair(name, value)).second) {
+                                               CAF_CM_EXCEPTIONEX_VA3(
+                                                               DuplicateElementException,
+                                                               0,
+                                                               "Bean property name is duplicated. "
+                                                               "[bean id=%s][property name=%s][bean_config_file=%s]",
+                                                               beanId.c_str(),
+                                                               name.c_str(),
+                                                               beanConfigFile.c_str());
                                        }
-                                       else if (beanChild->getName() == "constructor-arg") {
-                                               // Syntactic sugar
-                                               const SmartPtrCXmlElement ctorArgElement = *beanChild;
-
-                                               // ctor attributes
-                                               const uint32 ctorArgIndex = CStringConv::fromString<uint32>(ctorArgElement->findRequiredAttribute("index"));
-                                               CBeanCtorArg::ARG_TYPE ctorArgType = CBeanCtorArg::NOT_SET;
-                                               std::string ctorArgValue = ctorArgElement->findOptionalAttribute("value");
+                               }
+                               else if (beanChild->getName() == "constructor-arg") {
+                                       // Syntactic sugar
+                                       const SmartPtrCXmlElement ctorArgElement = *beanChild;
+
+                                       // ctor attributes
+                                       const uint32 ctorArgIndex = CStringConv::fromString<uint32>(ctorArgElement->findRequiredAttribute("index"));
+                                       CBeanCtorArg::ARG_TYPE ctorArgType = CBeanCtorArg::NOT_SET;
+                                       std::string ctorArgValue = ctorArgElement->findOptionalAttribute("value");
+                                       if (ctorArgValue.length() > 0) {
+                                               ctorArgType = CBeanCtorArg::VALUE;
+                                       } else {
+                                               ctorArgValue = ctorArgElement->findOptionalAttribute("ref");
                                                if (ctorArgValue.length() > 0) {
-                                                       ctorArgType = CBeanCtorArg::VALUE;
+                                                       ctorArgType = CBeanCtorArg::REFERENCE;
                                                } else {
-                                                       ctorArgValue = ctorArgElement->findOptionalAttribute("ref");
-                                                       if (ctorArgValue.length() > 0) {
-                                                               ctorArgType = CBeanCtorArg::REFERENCE;
-                                                       } else {
-                                                               CAF_CM_EXCEPTIONEX_VA2(
-                                                                               InvalidArgumentException,
-                                                                               0,
-                                                                               "Bean constructor argument must be of type value or ref and cannot be empty. "
-                                                                               "[bean id=%s][bean_config_file=%s]",
-                                                                               beanId.c_str(),
-                                                                               beanConfigFile.c_str());
-                                                       }
-                                               }
-
-                                               if (!beanCtorArgs.insert(
-                                                               CBeanCtorArgCollection::value_type(
-                                                                               ctorArgIndex,
-                                                                               CBeanCtorArg(ctorArgType, ctorArgValue))).second) {
-                                                       CAF_CM_EXCEPTIONEX_VA3(
-                                                                       DuplicateElementException,
+                                                       CAF_CM_EXCEPTIONEX_VA2(
+                                                                       InvalidArgumentException,
                                                                        0,
-                                                                       "Bean has a duplicate constructor-arg index. "
-                                                                       "[bean id=%s][bean_config_file=%s][arg-index=%d]",
+                                                                       "Bean constructor argument must be of type value or ref and cannot be empty. "
+                                                                       "[bean id=%s][bean_config_file=%s]",
                                                                        beanId.c_str(),
-                                                                       beanConfigFile.c_str(),
-                                                                       ctorArgIndex);
+                                                                       beanConfigFile.c_str());
                                                }
-                                               CAF_CM_LOG_DEBUG_VA4(
-                                                               "Bean ctor arg parsed [id=%s][arg-index=%d][arg-type=%s][arg-value=%s]",
-                                                               beanId.c_str(),
-                                                               ctorArgIndex,
-                                                               (CBeanCtorArg::VALUE == ctorArgType ? "VALUE" : "REFERENCE"),
-                                                               ctorArgValue.c_str());
                                        }
-                               }
 
-                               // Add the bean definition to the collection
-                               SmartPtrCBeanNode beanNode;
-                               beanNode.CreateInstance();
-                               beanNode->_id = beanId;
-                               beanNode->_class = beanClass;
-                               beanNode->_ctorArgs = beanCtorArgs;
-                               beanNode->_properties = beanProperties;
-
-                               if (!beanCollection.insert(
-                                               CBeanCollection::value_type(
-                                                               beanId,
-                                                               beanNode)).second) {
-                                       CAF_CM_EXCEPTIONEX_VA3(
-                                                       DuplicateElementException,
-                                                       0,
-                                                       "Duplicate bean definition detected. "
-                                                       "[bean id=%s][bean class=%s][bean_config_file=%s]",
+                                       if (!beanCtorArgs.insert(
+                                                       CBeanCtorArgCollection::value_type(
+                                                                       ctorArgIndex,
+                                                                       CBeanCtorArg(ctorArgType, ctorArgValue))).second) {
+                                               CAF_CM_EXCEPTIONEX_VA3(
+                                                               DuplicateElementException,
+                                                               0,
+                                                               "Bean has a duplicate constructor-arg index. "
+                                                               "[bean id=%s][bean_config_file=%s][arg-index=%d]",
+                                                               beanId.c_str(),
+                                                               beanConfigFile.c_str(),
+                                                               ctorArgIndex);
+                                       }
+                                       CAF_CM_LOG_DEBUG_VA4(
+                                                       "Bean ctor arg parsed [id=%s][arg-index=%d][arg-type=%s][arg-value=%s]",
                                                        beanId.c_str(),
-                                                       beanNode->_class.c_str(),
-                                                       beanConfigFile.c_str());
+                                                       ctorArgIndex,
+                                                       (CBeanCtorArg::VALUE == ctorArgType ? "VALUE" : "REFERENCE"),
+                                                       ctorArgValue.c_str());
                                }
                        }
-               }
 
-               CAF_CM_LOG_DEBUG_VA2(
-                               "Bean configuration file defined %d beans. "
-                               "[file=%s]",
-                               beanCollection.size(),
-                               beanConfigFile.c_str());
+                       // Add the bean definition to the collection
+                       SmartPtrCBeanNode beanNode;
+                       beanNode.CreateInstance();
+                       beanNode->_id = beanId;
+                       beanNode->_class = beanClass;
+                       beanNode->_ctorArgs = beanCtorArgs;
+                       beanNode->_properties = beanProperties;
+
+                       if (!beanCollection.insert(
+                                       CBeanCollection::value_type(
+                                                       beanId,
+                                                       beanNode)).second) {
+                               CAF_CM_EXCEPTIONEX_VA3(
+                                               DuplicateElementException,
+                                               0,
+                                               "Duplicate bean definition detected. "
+                                               "[bean id=%s][bean class=%s][bean_config_file=%s]",
+                                               beanId.c_str(),
+                                               beanNode->_class.c_str(),
+                                               beanConfigFile.c_str());
+                       }
+               }
        }
-       CAF_CM_EXIT;
+
+       CAF_CM_LOG_DEBUG_VA2(
+                       "Bean configuration file defined %d beans. "
+                       "[file=%s]",
+                       beanCollection.size(),
+                       beanConfigFile.c_str());
 }
 
 void CApplicationContext::createBeanGraph(
@@ -322,106 +289,103 @@ void CApplicationContext::createBeanGraph(
                CBeanGraph::ClistVertexEdges& beanTopologySort) const {
        CAF_CM_FUNCNAME("createBeanGraph");
 
-       CAF_CM_ENTER {
-               // Iterate the bean collection and create the beans. They will not be initialized.
-               // Two name sets will be built: bean names and contstructor-arg ref names.
-               // These two sets will be compared to ensure that all referenced beans exist.
-               Csetstr beanNames;
-               Csetstr beanCtorRefNames;
-               for (TSmartMapIterator<CBeanCollection> beanIter(beanCollection);
-                               beanIter;
-                               beanIter++) {
-
-                       // Create the bean and add it to the collection
-                       CAF_CM_LOG_DEBUG_VA2(
-                                       "Creating bean [id=%s][class=%s]",
-                                       beanIter.getKey().c_str(),
-                                       beanIter->_class.c_str());
-                       beanIter->_bean.CreateInstance(beanIter->_class.c_str());
-
-                       // Add the bean id to the beanNames set
-                       if (!beanNames.insert(beanIter->_id).second) {
-                               CAF_CM_LOG_DEBUG_VA1(
-                                       "Internal logic error: duplicate bean detected. "
-                                       "[id=%s]",
-                                       beanIter->_id.c_str());
-                       }
+       // Iterate the bean collection and create the beans. They will not be initialized.
+       // Two name sets will be built: bean names and contstructor-arg ref names.
+       // These two sets will be compared to ensure that all referenced beans exist.
+       Csetstr beanNames;
+       Csetstr beanCtorRefNames;
+       for (TSmartMapIterator<CBeanCollection> beanIter(beanCollection);
+                       beanIter;
+                       beanIter++) {
 
-                       // Add ref constructor args to the ctor ref name set
-                       for (TConstMapIterator<CBeanCtorArgCollection> beanCtorArg(beanIter->_ctorArgs);
-                                       beanCtorArg;
-                                       beanCtorArg++) {
-                               if (CBeanCtorArg::REFERENCE == beanCtorArg->_type) {
-                                       beanCtorRefNames.insert(beanCtorArg->_value);
-                               }
-                       }
+               // Create the bean and add it to the collection
+               CAF_CM_LOG_DEBUG_VA2(
+                               "Creating bean [id=%s][class=%s]",
+                               beanIter.getKey().c_str(),
+                               beanIter->_class.c_str());
+               beanIter->_bean.CreateInstance(beanIter->_class.c_str());
+
+               // Add the bean id to the beanNames set
+               if (!beanNames.insert(beanIter->_id).second) {
+                       CAF_CM_LOG_DEBUG_VA1(
+                               "Internal logic error: duplicate bean detected. "
+                               "[id=%s]",
+                               beanIter->_id.c_str());
                }
 
-               // Make sure that all beans referenced as ctor args exist
-               Csetstr beanNameDiff;
-               std::set_difference(
-                               beanCtorRefNames.begin(),
-                               beanCtorRefNames.end(),
-                               beanNames.begin(),
-                               beanNames.end(),
-                               std::inserter(beanNameDiff, beanNameDiff.end()));
-
-               if (beanNameDiff.size()) {
-                       for (TConstIterator<Csetstr> missingName(beanNameDiff);
-                                       missingName;
-                                       missingName++) {
-                               CAF_CM_LOG_ERROR_VA1(
-                                               "No bean definition exists for constructor-arg referenced bean '%s'",
-                                               missingName->c_str());
+               // Add ref constructor args to the ctor ref name set
+               for (TConstMapIterator<CBeanCtorArgCollection> beanCtorArg(beanIter->_ctorArgs);
+                               beanCtorArg;
+                               beanCtorArg++) {
+                       if (CBeanCtorArg::REFERENCE == beanCtorArg->_type) {
+                               beanCtorRefNames.insert(beanCtorArg->_value);
                        }
-                       CAF_CM_EXCEPTIONEX_VA0(
-                                       NoSuchElementException,
-                                       0,
-                                       "One or more bean constructor-args references beans that are not defined.");
                }
+       }
 
-               // Create a graph node for each bean
-               for (TSmartConstMapIterator<CBeanCollection> beanIter(beanCollection);
-                               beanIter;
-                               beanIter++) {
-                       beanGraph.addVertex(*beanIter);
+       // Make sure that all beans referenced as ctor args exist
+       Csetstr beanNameDiff;
+       std::set_difference(
+                       beanCtorRefNames.begin(),
+                       beanCtorRefNames.end(),
+                       beanNames.begin(),
+                       beanNames.end(),
+                       std::inserter(beanNameDiff, beanNameDiff.end()));
+
+       if (beanNameDiff.size()) {
+               for (TConstIterator<Csetstr> missingName(beanNameDiff);
+                               missingName;
+                               missingName++) {
+                       CAF_CM_LOG_ERROR_VA1(
+                                       "No bean definition exists for constructor-arg referenced bean '%s'",
+                                       missingName->c_str());
                }
+               CAF_CM_EXCEPTIONEX_VA0(
+                               NoSuchElementException,
+                               0,
+                               "One or more bean constructor-args references beans that are not defined.");
+       }
 
-               // Okay. Now connect the vertices according the constructor-arg references.
-               // The resulting graph will give us the initialization/tear-down order.
-               for (TSmartConstMapIterator<CBeanCollection> beanIter(beanCollection);
-                               beanIter;
-                               beanIter++) {
-                       for (TConstMapIterator<CBeanCtorArgCollection> ctorArg(beanIter->_ctorArgs);
-                                       ctorArg;
-                                       ctorArg++) {
-                               if (CBeanCtorArg::REFERENCE == ctorArg->_type) {
-                                       CBeanCollection::const_iterator ctorBean = beanCollection.find(ctorArg->_value);
-                                       if (beanCollection.end() == ctorBean) {
-                                               CAF_CM_EXCEPTIONEX_VA1(
-                                                               NoSuchElementException,
-                                                               0,
-                                                               "Internal error: constructor-arg referenced bean '%s' is missing",
-                                                               ctorArg->_value.c_str());
-                                       }
-                                       beanGraph.addEdge(ctorBean->second, *beanIter);
+       // Create a graph node for each bean
+       for (TSmartConstMapIterator<CBeanCollection> beanIter(beanCollection);
+                       beanIter;
+                       beanIter++) {
+               beanGraph.addVertex(*beanIter);
+       }
+
+       // Okay. Now connect the vertices according the constructor-arg references.
+       // The resulting graph will give us the initialization/tear-down order.
+       for (TSmartConstMapIterator<CBeanCollection> beanIter(beanCollection);
+                       beanIter;
+                       beanIter++) {
+               for (TConstMapIterator<CBeanCtorArgCollection> ctorArg(beanIter->_ctorArgs);
+                               ctorArg;
+                               ctorArg++) {
+                       if (CBeanCtorArg::REFERENCE == ctorArg->_type) {
+                               CBeanCollection::const_iterator ctorBean = beanCollection.find(ctorArg->_value);
+                               if (beanCollection.end() == ctorBean) {
+                                       CAF_CM_EXCEPTIONEX_VA1(
+                                                       NoSuchElementException,
+                                                       0,
+                                                       "Internal error: constructor-arg referenced bean '%s' is missing",
+                                                       ctorArg->_value.c_str());
                                }
+                               beanGraph.addEdge(ctorBean->second, *beanIter);
                        }
                }
+       }
 
-               // And finally - compute the bean topology sort order
-               beanTopologySort = beanGraph.topologySort();
+       // And finally - compute the bean topology sort order
+       beanTopologySort = beanGraph.topologySort();
 
-               // Debugging - you will thank me for this later
-               CAF_CM_LOG_DEBUG_VA0("BEGIN: Bean initialization order")
-               for (TSmartConstIterator<CBeanGraph::ClistVertexEdges> beanNode(beanTopologySort);
-                               beanNode;
-                               beanNode++) {
-                       CAF_CM_LOG_DEBUG_VA1("bean id=%s", beanNode->_id.c_str());
-               }
-               CAF_CM_LOG_DEBUG_VA0("END: Bean initialization order")
+       // Debugging - you will thank me for this later
+       CAF_CM_LOG_DEBUG_VA0("BEGIN: Bean initialization order")
+       for (TSmartConstIterator<CBeanGraph::ClistVertexEdges> beanNode(beanTopologySort);
+                       beanNode;
+                       beanNode++) {
+               CAF_CM_LOG_DEBUG_VA1("bean id=%s", beanNode->_id.c_str());
        }
-       CAF_CM_EXIT;
+       CAF_CM_LOG_DEBUG_VA0("END: Bean initialization order")
 }
 
 void CApplicationContext::initializeBeans(
@@ -429,28 +393,27 @@ void CApplicationContext::initializeBeans(
                CBeanGraph::ClistVertexEdges& beanTopologySort) const {
        CAF_CM_FUNCNAME("initializeBeans");
 
-       CAF_CM_ENTER {
-               for (TSmartIterator<CBeanGraph::ClistVertexEdges> beanNode(beanTopologySort);
-                               beanNode;
-                               beanNode++) {
-                       CAF_CM_LOG_DEBUG_VA1("Initializing bean %s", beanNode->_id.c_str());
+       for (TSmartIterator<CBeanGraph::ClistVertexEdges> beanNode(beanTopologySort);
+                       beanNode;
+                       beanNode++) {
+               CAF_CM_LOG_DEBUG_VA1("Initializing bean %s", beanNode->_id.c_str());
 
-                       // The bean should not have been initialized
-                       if (beanNode->_isInitialized) {
-                               CAF_CM_EXCEPTIONEX_VA1(
-                                               IllegalStateException,
-                                               0,
-                                               "Internal error: Bean [%s] has already been initialized.",
-                                               beanNode->_id.c_str());
-                       }
+               // The bean should not have been initialized
+               if (beanNode->_isInitialized) {
+                       CAF_CM_EXCEPTIONEX_VA1(
+                                       IllegalStateException,
+                                       0,
+                                       "Internal error: Bean [%s] has already been initialized.",
+                                       beanNode->_id.c_str());
+               }
 
-                       // Iterate the contructor-args and build a collection to
-                       // pass to the bean initializer
-                       IBean::Cargs beanInitArgs;
-                       for (TConstMapIterator<CBeanCtorArgCollection> ctorArg(beanNode->_ctorArgs);
-                                       ctorArg;
-                                       ctorArg++) {
-                               switch (ctorArg->_type) {
+               // Iterate the contructor-args and build a collection to
+               // pass to the bean initializer
+               IBean::Cargs beanInitArgs;
+               for (TConstMapIterator<CBeanCtorArgCollection> ctorArg(beanNode->_ctorArgs);
+                               ctorArg;
+                               ctorArg++) {
+                       switch (ctorArg->_type) {
                                case CBeanCtorArg::REFERENCE: {
                                                CBeanCollection::const_iterator bean = beanCollection.find(ctorArg->_value);
                                                if (!bean->second->_isInitialized) {
@@ -484,52 +447,47 @@ void CApplicationContext::initializeBeans(
                                                        "[bean id=%s][constructor-arg index=%d]",
                                                        beanNode->_id.c_str(),
                                                        ctorArg.getKey());
-                               }
                        }
+               }
 
-                       // Iterate the bean properties and resolve value references
-                       SmartPtrIAppConfig appConfig = getAppConfig();
-                       Cmapstrstr properties = beanNode->_properties;
-
-                       for (TMapIterator<Cmapstrstr> property(properties);
-                                       property;
-                                       property++) {
-                               *property = appConfig->resolveValue(*property);
-                       }
+               // Iterate the bean properties and resolve value references
+               SmartPtrIAppConfig appConfig = getAppConfig();
+               Cmapstrstr properties = beanNode->_properties;
 
-                       // Initialize the bean
-                       beanNode->_bean->initializeBean(beanInitArgs, properties);
-                       beanNode->_isInitialized = true;
+               for (TMapIterator<Cmapstrstr> property(properties);
+                               property;
+                               property++) {
+                       *property = appConfig->resolveValue(*property);
                }
+
+               // Initialize the bean
+               beanNode->_bean->initializeBean(beanInitArgs, properties);
+               beanNode->_isInitialized = true;
        }
-       CAF_CM_EXIT;
 }
 
 void CApplicationContext::terminateBeans(CBeanGraph::ClistVertexEdges& beanTopologySort) const {
        CAF_CM_FUNCNAME("terminateBeans");
 
-       CAF_CM_ENTER {
-               // Important! Iterate in reverse order of initialization
-               // Some beans may not be initialized because of exceptions during init process
-               for (CBeanGraph::ClistVertexEdges::reverse_iterator beanNode = beanTopologySort.rbegin();
-                               beanNode != beanTopologySort.rend();
-                               beanNode++) {
-                       if ((*beanNode)->_isInitialized) {
-                               CAF_CM_LOG_DEBUG_VA1(
-                                               "Terminating bean %s",
-                                               (*beanNode)->_id.c_str());
-                               try {
-                                       (*beanNode)->_bean->terminateBean();
-                               }
-                               CAF_CM_CATCH_ALL;
-                               CAF_CM_LOG_CRIT_CAFEXCEPTION;
-                               CAF_CM_CLEAREXCEPTION;
-                       } else {
-                               CAF_CM_LOG_DEBUG_VA1(
-                                               "Skipping termination of uninitialized bean %s",
-                                               (*beanNode)->_id.c_str());
+       // Important! Iterate in reverse order of initialization
+       // Some beans may not be initialized because of exceptions during init process
+       for (CBeanGraph::ClistVertexEdges::reverse_iterator beanNode = beanTopologySort.rbegin();
+                       beanNode != beanTopologySort.rend();
+                       beanNode++) {
+               if ((*beanNode)->_isInitialized) {
+                       CAF_CM_LOG_DEBUG_VA1(
+                                       "Terminating bean %s",
+                                       (*beanNode)->_id.c_str());
+                       try {
+                               (*beanNode)->_bean->terminateBean();
                        }
+                       CAF_CM_CATCH_ALL;
+                       CAF_CM_LOG_CRIT_CAFEXCEPTION;
+                       CAF_CM_CLEAREXCEPTION;
+               } else {
+                       CAF_CM_LOG_DEBUG_VA1(
+                                       "Skipping termination of uninitialized bean %s",
+                                       (*beanNode)->_id.c_str());
                }
        }
-       CAF_CM_EXIT;
 }
index 911c69da6431a2e547588acacdfdd14f4bee6427..a3aecd6c21033399d16568368a6b88712707c029 100644 (file)
@@ -36,16 +36,16 @@ extern "C" void DaemonUtilsCrashHandler(int32 sigNum, siginfo_t *info, void *con
 void CDaemonUtils::MakeDaemon(
                int32 argc,
                char** argv,
-               const char* processName,
+               const std::string& procPath,
+               const std::string& procName,
                void(*pfnShutdownHandler)(int32 signalNum),
                bool& isDaemonized,
                bool& logInfos) {
 
-       const char* logProcessName =
-                       (processName && *processName) ? processName : "CDaemonUtils";
-       ::openlog(logProcessName, LOG_PID, LOG_USER);
+       const std::string logProcName = procName.empty() ? "CDaemonUtils" : procName;
+       ::openlog(logProcName.c_str(), LOG_PID, LOG_USER);
        ::atexit(::closelog);
-       ::syslog(LOG_INFO, "Initializing %s", logProcessName);
+       ::syslog(LOG_INFO, "Initializing %s", logProcName.c_str());
 
        isDaemonized = true;
        logInfos = false;
@@ -151,7 +151,7 @@ void CDaemonUtils::MakeDaemon(
                }
 
                // and re-open syslog
-               ::openlog(logProcessName, LOG_CONS | LOG_PID, LOG_USER);
+               ::openlog(logProcName.c_str(), LOG_CONS | LOG_PID, LOG_USER);
                errno = 0;
        }
 
@@ -248,11 +248,11 @@ void CDaemonUtils::MakeDaemon(
        // to make sure we don't hold a file system open.
        if (rootDir.empty())    {
                if (logInfos) {
-                       ::syslog(LOG_INFO, "Switching to directory of %s", *argv);
+                       ::syslog(LOG_INFO, "Switching to directory of %s", procPath.c_str());
                }
-               const char * lastSlash = ::strrchr(*argv, '/');
+               const char * lastSlash = ::strrchr(procPath.c_str(), '/');
                if (*lastSlash) {
-                       std::string directory = *argv;
+                       std::string directory = procPath;
                        directory.erase(directory.rfind('/'));
                        if (logInfos) {
                                ::syslog(LOG_INFO, "chdir %s", directory.c_str());
@@ -404,6 +404,7 @@ extern "C" void DaemonUtilsCrashHandler(int32 sigNum, siginfo_t *info, void *con
                CAF_CM_LOG_ERROR_VA0(message.c_str());
        }
        CAF_CM_CATCH_ALL;
+       CAF_CM_CLEAREXCEPTION;
        ::exit(-1);
 }
 
index 2b8a65abe1f2f5d327e10e2cbe20cc176355a9bf..6f1a9bc9d0aea3ca019aabc6d894d25cbae5b0e0 100644 (file)
@@ -14,7 +14,8 @@ public:
        static void MakeDaemon(
                        int32 argc,
                        char** argv,
-                       const char* processName,
+                       const std::string& procPath,
+                       const std::string& procName,
                        void(*pfnShutdownHandler)(int32 signalNum),
                        bool& isDaemonized,
                        bool& logInfos);
index 1544b35adbf29cc8d79e9c9212f65dc96c234f87..0cad607a0c3c8d4badddc8205551d5f880ab5a1f 100644 (file)
@@ -15,7 +15,7 @@ using namespace Caf;
 ////////////////////////////////////////////////////////////////////////
 CLoggingSetter::CLoggingSetter() :
                _isInitialized(false),
-               _useSingleLogging(false),
+               _remapLoggingLocation(false),
        CAF_CM_INIT_LOG("CLoggingSetter") {
 }
 
@@ -29,7 +29,7 @@ CLoggingSetter::~CLoggingSetter() {
 
        try {
                if (_isInitialized) {
-                       if (! _useSingleLogging) {
+                       if (_remapLoggingLocation) {
                                CAF_CM_LOG_DEBUG_VA0("Resetting log config dir");
                                CLoggingUtils::resetConfigFile();
                                CAF_CM_LOG_DEBUG_VA0("Reset log config dir");
@@ -50,8 +50,8 @@ void CLoggingSetter::initialize(const std::string& logDir) {
        CAF_CM_PRECOND_ISNOTINITIALIZED(_isInitialized);
        CAF_CM_VALIDATE_STRING(logDir);
 
-       _useSingleLogging = AppConfigUtils::getOptionalBoolean("use_single_logging");
-       if (! _useSingleLogging) {
+       _remapLoggingLocation = AppConfigUtils::getOptionalBoolean("remap_logging_location");
+       if (_remapLoggingLocation) {
                CAF_CM_LOG_DEBUG_VA1("Setting log config dir - %s", logDir.c_str());
                CLoggingUtils::setLogDir(logDir);
                CAF_CM_LOG_DEBUG_VA1("Set log config dir - %s", logDir.c_str());
index b0bdfc7742ced9fad818018dec955fbeb80329cd..63e902ed6e8cf7e1852307c38566e2876cf41957 100644 (file)
@@ -18,7 +18,7 @@ public:
 
 private:
        bool _isInitialized;
-       bool _useSingleLogging;
+       bool _remapLoggingLocation;
 
 private:
        CAF_CM_CREATE;
index 35b681e28e30e53dc42ed133eb44e8c4885f2a60..bef4cecd73fb1deaf82241cb71587c6b8c7eb508 100644 (file)
@@ -30,12 +30,11 @@ bool CLoggingUtils::isConsoleAppenderUsed() {
        return rc;
 }
 
-void CLoggingUtils::setStartupConfigFile() {
-       setStartupConfigFile("log4cpp_config");
-}
-
-void CLoggingUtils::setStartupConfigFile(const std::string& configFile) {
+void CLoggingUtils::setStartupConfigFile(
+               const std::string& configFile,
+               const std::string& logDir) {
        CAF_CM_STATIC_FUNC("CLoggingUtils", "setStartupConfigFile");
+       CAF_CM_VALIDATE_STRING(configFile);
 
 #ifndef WIN32
        char configFileFullBuf[ 32768 ];
@@ -60,7 +59,11 @@ void CLoggingUtils::setStartupConfigFile(const std::string& configFile) {
        _sInstance->_configFile = configFileFull;
        _sInstance->loadProperties();
 
-       _sInstance->loadConfig(configFileFull);
+       if (logDir.empty()) {
+               _sInstance->loadConfig(configFileFull);
+       } else {
+               setLogDir(logDir);
+       }
 }
 
 SmartPtrCLoggingUtils CLoggingUtils::getInstance() {
index 280b1ca31c5ae8e774ca64fc7a1736fe838b88d3..8fa93b15401860bafb86dc1c6711add39725f791 100644 (file)
@@ -24,8 +24,9 @@ private:
 
 public:
        static bool isConsoleAppenderUsed();
-       static void setStartupConfigFile();
-       static void setStartupConfigFile(const std::string& configFile);
+       static void setStartupConfigFile(
+                       const std::string& configFile = "log4cpp_config",
+                       const std::string& logDir = std::string());
        static std::string getConfigFile();
        static void resetConfigFile();
        static void setLogDir(const std::string& logDir);
index f8f0d109b03c5dff801c5d5a42fa7723d655a836..58f41b9ba1aeb3a96e35b3b41b87252e0bd4186a 100644 (file)
@@ -158,6 +158,8 @@ SmartPtrCPersistenceProtocolCollectionDoc CPersistenceUtils::loadPersistenceProt
                        persistenceProtocol->initialize(
                                        loadTextFile(protocolIdDir, "protocolName.txt"),
                                        loadTextFile(protocolIdDir, "uri.txt"),
+                                       loadTextFile(protocolIdDir, "uri_amqp.txt"),
+                                       loadTextFile(protocolIdDir, "uri_tunnel.txt"),
                                        loadTextFile(protocolIdDir, "tlsCert.pem"),
                                        loadTextFile(protocolIdDir, "tlsProtocol.txt"),
                                        tlsCipherCollection,
@@ -194,10 +196,14 @@ SmartPtrCPersistenceProtocolDoc CPersistenceUtils::loadPersistenceProtocol(
 
        std::deque<SmartPtrCPersistenceProtocolDoc> persistenceProtocolCollectionInner =
                        persistenceProtocolCollection->getPersistenceProtocol();
-       CAF_CM_VALIDATE_BOOL(! persistenceProtocolCollectionInner.empty());
-       CAF_CM_VALIDATE_BOOL(persistenceProtocolCollectionInner.size() == 1);
+       CAF_CM_VALIDATE_BOOL(persistenceProtocolCollectionInner.size() <= 1);
 
-       return persistenceProtocolCollectionInner.front();
+       SmartPtrCPersistenceProtocolDoc rc;
+       if (persistenceProtocolCollectionInner.size() == 1) {
+               rc = persistenceProtocolCollectionInner.front();
+       }
+
+       return rc;
 }
 
 void CPersistenceUtils::savePersistence(
@@ -337,6 +343,16 @@ void CPersistenceUtils::savePersistenceProtocolCollection(
                                                        amqpQueueDir, "uri.txt", persistenceProtocol->getUri());
                                }
 
+                               if (! persistenceProtocol->getUriAmqp().empty()) {
+                                       FileSystemUtils::saveTextFile(
+                                                       amqpQueueDir, "uri_amqp.txt", persistenceProtocol->getUriAmqp());
+                               }
+
+                               if (! persistenceProtocol->getUriTunnel().empty()) {
+                                       FileSystemUtils::saveTextFile(
+                                                       amqpQueueDir, "uri_tunnel.txt", persistenceProtocol->getUriTunnel());
+                               }
+
                                if (! persistenceProtocol->getTlsCert().empty()) {
                                        FileSystemUtils::saveTextFile(
                                                        amqpQueueDir, "tlsCert.pem", persistenceProtocol->getTlsCert());
@@ -371,7 +387,8 @@ void CPersistenceUtils::savePersistenceProtocolCollection(
 std::string CPersistenceUtils::loadTextFile(
                const std::string& dir,
                const std::string& file,
-               const std::string& defaultVal) {
+               const std::string& defaultVal,
+               const bool isTrimRight) {
        CAF_CM_STATIC_FUNC_VALIDATE("CPersistenceUtils", "loadTextFile");
        CAF_CM_VALIDATE_STRING(dir);
        CAF_CM_VALIDATE_STRING(file);
@@ -381,6 +398,9 @@ std::string CPersistenceUtils::loadTextFile(
        std::string rc;
        if (FileSystemUtils::doesFileExist(path)) {
                rc = FileSystemUtils::loadTextFile(path);
+               if (isTrimRight) {
+                       rc = CStringUtils::trimRight(rc);
+               }
        } else {
                rc = defaultVal;
        }
index c454cb493b953f5cf863381a77b62200cd80a10c..9a609913ec67461ef55166893e22e76aa4dc39bc 100644 (file)
@@ -54,7 +54,8 @@ private:
        static std::string loadTextFile(
                        const std::string& dir,
                        const std::string& file,
-                       const std::string& defaultVal = std::string());
+                       const std::string& defaultVal = std::string(),
+                       const bool isTrimRight = true);
 
 private:
        static std::string createDirectory(
index c4c1879af91cda1aed31920b74fc6b2e4ffc1d55..65098e9d6f7340c3b7fa894c033b4a0cfd4946f4 100644 (file)
@@ -13,7 +13,6 @@ using namespace Caf;
 
 CThreadSignal::CThreadSignal(void) :
        _isInitialized(false),
-       _waitCnt(0),
        CAF_CM_INIT("CThreadSignal") {
        CAF_CM_INIT_THREADSAFE
        ;
@@ -42,11 +41,7 @@ void CThreadSignal::signal() {
        CAF_CM_LOCK_UNLOCK;
        CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
 
-       for (uint32 iter = 0; iter < _waitCnt; iter++) {
-               _condition.signal();
-       }
-
-       _waitCnt = 0;
+       _condition.signal();
 }
 
 void CThreadSignal::wait(SmartPtrCAutoMutex& mutex, const uint32 timeoutMs) {
@@ -66,11 +61,6 @@ bool CThreadSignal::waitOrTimeout(SmartPtrCAutoMutex& mutex, const uint32 timeou
        CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
        CAF_CM_VALIDATE_SMARTPTR(mutex);
 
-       {
-               CAF_CM_LOCK_UNLOCK;
-               _waitCnt++;
-       }
-
        bool rc = false;
        if (0 == timeoutMs) {
                _condition.wait(mutex);
@@ -79,10 +69,6 @@ bool CThreadSignal::waitOrTimeout(SmartPtrCAutoMutex& mutex, const uint32 timeou
                gint64 endTime;
                endTime = ::g_get_monotonic_time() + timeoutMs * G_TIME_SPAN_MILLISECOND;
                rc = _condition.waitUntil(mutex, endTime);
-               if (!rc) {
-                       CAF_CM_LOCK_UNLOCK;
-                       _waitCnt--;
-               }
        }
 
        return rc;
@@ -100,7 +86,6 @@ void CThreadSignal::close() {
 
        if (_isInitialized) {
                _condition.close();
-               _waitCnt = 0;
                _isInitialized = false;
        }
 }
index a99fa00954d7aff8ff0be143b2516d20044d85c7..19b53a2b0464275c689be70df10d1e6112b54b82 100644 (file)
@@ -47,8 +47,6 @@ private:
        bool _isInitialized;
        CAutoCondition _condition;
 
-       uint32 _waitCnt;
-
 private:
        CAF_CM_CREATE;
        CAF_CM_CREATE_THREADSAFE;
index 2aebcb2bb6dc826f0716d52a1884b247a8875049..c6b36b3d9870ed8cd27309599e24a83c613a8754 100644 (file)
@@ -26,16 +26,7 @@ uint32 CThreadUtils::getThreadStackSizeKb() {
        return stackSizeKb;
 }
 
-void CThreadUtils::start(
-       threadFunc func,
-       void* data) {
-       (void)startJoinable(func, data);
-}
-
-GThread* CThreadUtils::startJoinable(
-       threadFunc func,
-       void* data) {
-
+GThread* CThreadUtils::startJoinable(threadFunc func, void* data) {
        CAF_CM_STATIC_FUNC("CThreadUtils", "startJoinable");
 
        GThread *rc = g_thread_new("CThreadUtils::startJoinable", func, data);
@@ -46,6 +37,10 @@ GThread* CThreadUtils::startJoinable(
        return rc;
 }
 
+void CThreadUtils::join(GThread* thread) {
+       (void) g_thread_join(thread);
+}
+
 void CThreadUtils::sleep(
        const uint32 milliseconds) {
 
index 12ebeedcbd34b028167e691a26d98a8011f41447..7b398bda975416806f484ab96fd5bf7e35062e5b 100644 (file)
@@ -17,8 +17,8 @@ public:
 
 public:
        static uint32 getThreadStackSizeKb();
-       static void start(threadFunc func, void* data);
        static GThread* startJoinable(threadFunc func, void* data);
+       static void join(GThread* thread);
        static void sleep(const uint32 milliseconds);
 
 private:
index 95b423969cb5b1ec9575f26ebda7c6e28ae41097..96b001c66c7a4ee0e58b65b187597a65158efd80 100644 (file)
@@ -29,6 +29,12 @@ IAppConfig : public ICafObject {
                        uint32& value,
                        const IConfigParams::EParamDisposition disposition = IConfigParams::PARAM_REQUIRED) = 0;
 
+       virtual bool getInt32(
+                       const std::string& sectionName,
+                       const std::string& parameterName,
+                       int32& value,
+                       const IConfigParams::EParamDisposition disposition = IConfigParams::PARAM_REQUIRED) = 0;
+
        virtual bool getBoolean(
                        const std::string& sectionName,
                        const std::string& parameterName,
@@ -45,6 +51,11 @@ IAppConfig : public ICafObject {
                        uint32& value,
                        const IConfigParams::EParamDisposition disposition = IConfigParams::PARAM_REQUIRED) = 0;
 
+       virtual bool getGlobalInt32(
+                       const std::string& parameterName,
+                       int32& value,
+                       const IConfigParams::EParamDisposition disposition = IConfigParams::PARAM_REQUIRED) = 0;
+
        virtual bool getGlobalBoolean(
                        const std::string& parameterName,
                        bool& value,
index 5d20484819321da37ea9f04f4a371e378f37d920..d8595bd13613786eb8195948a0304b05f73dd538 100644 (file)
@@ -25,6 +25,11 @@ IAppConfigWrite : public ICafObject {
                        const std::string& parameterName,
                        const uint32& value) = 0;
 
+       virtual void setInt32(
+                       const std::string& sectionName,
+                       const std::string& parameterName,
+                       const int32& value) = 0;
+
        virtual void setBoolean(
                        const std::string& sectionName,
                        const std::string& parameterName,
@@ -38,6 +43,10 @@ IAppConfigWrite : public ICafObject {
                        const std::string& parameterName,
                        const uint32& value) = 0;
 
+       virtual void setGlobalInt32(
+                       const std::string& parameterName,
+                       const int32& value) = 0;
+
        virtual void setGlobalBoolean(
                        const std::string& parameterName,
                        const bool& value) = 0;
index 4fa47027b76f183aff0bbcad84abbbce05a9e346..f8d5d3512cfeca9aa42a31ed410b945f2d4fa0b3 100644 (file)
@@ -110,6 +110,9 @@ void UriUtils::parseUriString(
                                                hostpath = value;
                                                g_free(value);
                                        }
+                                       g_match_info_free(matchInfo);
+                                       matchInfo = NULL;
+
                                        if (g_regex_match(regexHost, hostpath.c_str(), (GRegexMatchFlags)0, &matchInfo)) {
                                                value = g_match_info_fetch_named(matchInfo, "host");
                                                data.host = value;
@@ -119,11 +122,16 @@ void UriUtils::parseUriString(
                                                data.port = CStringConv::fromString<uint32>(value);
                                                g_free(value);
                                        }
+                                       g_match_info_free(matchInfo);
+                                       matchInfo = NULL;
+
                                        if (g_regex_match(regexPath, hostpath.c_str(), (GRegexMatchFlags)0, &matchInfo)) {
                                                value = g_match_info_fetch_named(matchInfo, "path");
                                                data.path = value;
                                                g_free(value);
                                        }
+                                       g_match_info_free(matchInfo);
+                                       matchInfo = NULL;
                                }
 
                                if (params.length()) {
@@ -148,6 +156,8 @@ void UriUtils::parseUriString(
                                                        }
                                                }
                                        }
+                                       g_match_info_free(matchInfo);
+                                       matchInfo = NULL;
                                }
                        }
                }
@@ -226,9 +236,9 @@ void UriUtils::parseFileAddress(const std::string& fileUri, UriUtils::SFileUriRe
 
                        GError *error = NULL;
                        regexAddress = g_regex_new(addressPattern.c_str(),
-                                                                  (GRegexCompileFlags)(G_REGEX_RAW),
-                                                                  (GRegexMatchFlags)0,
-                                                                  &error);
+                                       (GRegexCompileFlags)(G_REGEX_RAW),
+                                       (GRegexMatchFlags)0,
+                                       &error);
                        if (error) {
                                throw error;
                        }
@@ -244,19 +254,18 @@ void UriUtils::parseFileAddress(const std::string& fileUri, UriUtils::SFileUriRe
                                matchInfo = NULL;
 
                                regexDrive = g_regex_new(drivePattern.c_str(),
-                                                                          (GRegexCompileFlags)(G_REGEX_RAW),
-                                                                          (GRegexMatchFlags)0,
-                                                                          &error);
+                                               (GRegexCompileFlags)(G_REGEX_RAW),
+                                               (GRegexMatchFlags)0,
+                                               &error);
                                if (error) {
                                        throw error;
                                }
 
-                               if (g_regex_match(regexDrive, data.path.c_str(), (GRegexMatchFlags)0, &matchInfo)) {
-                                       g_match_info_free(matchInfo);
-                                       matchInfo = NULL;
-                               } else {
+                               if (! g_regex_match(regexDrive, data.path.c_str(), (GRegexMatchFlags)0, &matchInfo)) {
                                        data.path = "/" + data.path;
                                }
+                               g_match_info_free(matchInfo);
+                               matchInfo = NULL;
                        }
                }
                CAF_CM_CATCH_CAF
index 579eafb021a8c745a1bbc951baafa4f7b4e92749..4b819af6a116e6b049522e7d76af4e1cd2885dca 100644 (file)
@@ -29,6 +29,16 @@ void PersistenceProtocolXml::add(
                thisXml->addAttribute("uri", uriVal);
        }
 
+       const std::string uriAmqpVal = persistenceProtocolDoc->getUriAmqp();
+       if (! uriAmqpVal.empty()) {
+               thisXml->addAttribute("uriAmqp", uriAmqpVal);
+       }
+
+       const std::string uriTunnelVal = persistenceProtocolDoc->getUriTunnel();
+       if (! uriTunnelVal.empty()) {
+               thisXml->addAttribute("uriTunnel", uriTunnelVal);
+       }
+
        const std::string tlsCertVal = persistenceProtocolDoc->getTlsCert();
        if (! tlsCertVal.empty()) {
                const SmartPtrCXmlElement tlsCertXml = thisXml->createAndAddElement("tlsCert");
@@ -85,6 +95,12 @@ SmartPtrCPersistenceProtocolDoc PersistenceProtocolXml::parse(
        const std::string uriVal =
                thisXml->findOptionalAttribute("uri");
 
+       const std::string uriAmqpVal =
+               thisXml->findOptionalAttribute("uriAmqp");
+
+       const std::string uriTunnelVal =
+               thisXml->findOptionalAttribute("uriTunnel");
+
        std::string tlsCertVal;
        const SmartPtrCXmlElement tlsCertXml = thisXml->findOptionalChild("tlsCert");
        if (tlsCertXml) {
@@ -132,6 +148,8 @@ SmartPtrCPersistenceProtocolDoc PersistenceProtocolXml::parse(
        persistenceProtocolDoc->initialize(
                        protocolNameVal,
                        uriVal,
+                       uriAmqpVal,
+                       uriTunnelVal,
                        tlsCertVal,
                        tlsProtocolVal,
                        tlsCipherCollectionVal,
index 904b13f32240cd22d8d65be79538050f4480f6d3..289910fc84f5af43e75b7a86314527f0a0da717d 100644 (file)
@@ -289,64 +289,65 @@ public:
       return FALSE;
     // Dynamically load the Entry-Points for dbghelp.dll:
     // First try to load the newsest one from
-    TCHAR szTemp[4096];
+    TCHAR localFile[4096];
     // But before wqe do this, we first check if the ".local" file exists
-    if (GetModuleFileName(NULL, szTemp, 4096) > 0)
+    if (GetModuleFileName(NULL, localFile, 4096) > 0)
     {
-      _tcscat_s(szTemp, _T(".local"));
-      if (GetFileAttributes(szTemp) == INVALID_FILE_ATTRIBUTES)
+      _tcscat_s(localFile, _T(".local"));
+      if (GetFileAttributes(localFile) == INVALID_FILE_ATTRIBUTES)
       {
         // ".local" file does not exist, so we can try to load the dbghelp.dll from the "Debugging Tools for Windows"
         // Ok, first try the new path according to the archtitecture:
+         TCHAR dbghelpFile[4096];
 #ifdef _M_IX86
-        if ( (m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), szTemp, 4096) > 0) )
+        if ( (m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), dbghelpFile, 4096) > 0) )
         {
-          _tcscat_s(szTemp, _T("\\Debugging Tools for Windows (x86)\\dbghelp.dll"));
+          _tcscat_s(dbghelpFile, _T("\\Debugging Tools for Windows (x86)\\dbghelp.dll"));
           // now check if the file exists:
-          if (GetFileAttributes(szTemp) != INVALID_FILE_ATTRIBUTES)
+          if (GetFileAttributes(dbghelpFile) != INVALID_FILE_ATTRIBUTES)
           {
-            m_hDbhHelp = LoadLibrary(szTemp);
+            m_hDbhHelp = LoadLibrary(dbghelpFile);
           }
         }
 #elif _M_X64
-        if ( (m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), szTemp, 4096) > 0) )
+        if ( (m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), dbghelpFile, 4096) > 0) )
         {
-          _tcscat_s(szTemp, _T("\\Debugging Tools for Windows (x64)\\dbghelp.dll"));
+          _tcscat_s(dbghelpFile, _T("\\Debugging Tools for Windows (x64)\\dbghelp.dll"));
           // now check if the file exists:
-          if (GetFileAttributes(szTemp) != INVALID_FILE_ATTRIBUTES)
+          if (GetFileAttributes(dbghelpFile) != INVALID_FILE_ATTRIBUTES)
           {
-            m_hDbhHelp = LoadLibrary(szTemp);
+            m_hDbhHelp = LoadLibrary(dbghelpFile);
           }
         }
 #elif _M_IA64
-        if ( (m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), szTemp, 4096) > 0) )
+        if ( (m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), dbghelpFile, 4096) > 0) )
         {
-          _tcscat_s(szTemp, _T("\\Debugging Tools for Windows (ia64)\\dbghelp.dll"));
+          _tcscat_s(dbghelpFile, _T("\\Debugging Tools for Windows (ia64)\\dbghelp.dll"));
           // now check if the file exists:
-          if (GetFileAttributes(szTemp) != INVALID_FILE_ATTRIBUTES)
+          if (GetFileAttributes(dbghelpFile) != INVALID_FILE_ATTRIBUTES)
           {
-            m_hDbhHelp = LoadLibrary(szTemp);
+            m_hDbhHelp = LoadLibrary(dbghelpFile);
           }
         }
 #endif
         // If still not found, try the old directories...
-        if ( (m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), szTemp, 4096) > 0) )
+        if ( (m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), dbghelpFile, 4096) > 0) )
         {
-          _tcscat_s(szTemp, _T("\\Debugging Tools for Windows\\dbghelp.dll"));
+          _tcscat_s(dbghelpFile, _T("\\Debugging Tools for Windows\\dbghelp.dll"));
           // now check if the file exists:
-          if (GetFileAttributes(szTemp) != INVALID_FILE_ATTRIBUTES)
+          if (GetFileAttributes(dbghelpFile) != INVALID_FILE_ATTRIBUTES)
           {
-            m_hDbhHelp = LoadLibrary(szTemp);
+            m_hDbhHelp = LoadLibrary(dbghelpFile);
           }
         }
 #if defined _M_X64 || defined _M_IA64
         // Still not found? Then try to load the (old) 64-Bit version:
-        if ( (m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), szTemp, 4096) > 0) )
+        if ( (m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), dbghelpFile, 4096) > 0) )
         {
-          _tcscat_s(szTemp, _T("\\Debugging Tools for Windows 64-Bit\\dbghelp.dll"));
-          if (GetFileAttributes(szTemp) != INVALID_FILE_ATTRIBUTES)
+          _tcscat_s(dbghelpFile, _T("\\Debugging Tools for Windows 64-Bit\\dbghelp.dll"));
+          if (GetFileAttributes(dbghelpFile) != INVALID_FILE_ATTRIBUTES)
           {
-            m_hDbhHelp = LoadLibrary(szTemp);
+            m_hDbhHelp = LoadLibrary(dbghelpFile);
           }
         }
 #endif
@@ -651,7 +652,7 @@ private:
     pGMI = (tGMI) GetProcAddress( hPsapi, "GetModuleInformation" );
     if ( (pEPM == NULL) || (pGMFNE == NULL) || (pGMBN == NULL) || (pGMI == NULL) )
     {
-      // we couldn´t find all functions
+      // we couldn�t find all functions
       FreeLibrary(hPsapi);
       return FALSE;
     }
index 36bb9a271bec1a0bb0169ac3c57b0b2d02a53e85..26a7387a6511156779fef9aff4c7ccbc2e474119 100644 (file)
@@ -373,7 +373,7 @@ SmartPtrIIntMessage CCafMessageCreator::createPayloadEnvelope(
        const std::string destAttachmentFilename =
                        BasePlatform::UuidToString(requestId) + "-EnvelopePayload.xml";
        const std::string destAttachmentPath = FileSystemUtils::buildPath(
-                       outputDir, destAttachmentFilename);
+                       outputDir, "att", destAttachmentFilename);
        const std::string destAttachmentUri =
                        "file:///" + destAttachmentPath + "?relPath=" + destAttachmentFilename;
 
index 41de333fdbd41a1a7655b285d96644dfcf3676f4..a2adcc55ebd0f335dbb253549e77344a52c1d6e4 100644 (file)
@@ -17,7 +17,7 @@ CAbstractPollableChannel::~CAbstractPollableChannel() {
 }
 
 SmartPtrIIntMessage CAbstractPollableChannel::receive() {
-       return receive(-1);
+       return receive(0);
 }
 
 SmartPtrIIntMessage CAbstractPollableChannel::receive(const int32 timeout) {
index 9f8ddbdd3ae1f852b448403af35c1e32ade139cd..b7e0b6ce9751d4aeebedc2f9b4b95622a961e796 100644 (file)
@@ -14,6 +14,8 @@ using namespace Caf;
 CIntegrationAppContext::CIntegrationAppContext() :
        _isInitialized(false),
        _isIntegrationObjectCollectionReady(false),
+       _lifecycleBeansStarted(false),
+       _timeoutMs(0),
        CAF_CM_INIT_LOG("CIntegrationAppContext") {
 }
 
@@ -23,21 +25,45 @@ CIntegrationAppContext::~CIntegrationAppContext() {
        }
 }
 
-void CIntegrationAppContext::initialize(const uint32 timeoutMs) {
+void CIntegrationAppContext::initialize(
+               const uint32 timeoutMs) {
        CAF_CM_FUNCNAME_VALIDATE("initialize");
        CAF_CM_PRECOND_ISNOTINITIALIZED(_isInitialized);
 
        const std::string beanConfigPath = getDefaultBeanConfigPath();
-       initialize(timeoutMs, beanConfigPath);
+       initializeRaw(timeoutMs, beanConfigPath, true);
 }
 
 void CIntegrationAppContext::initialize(
        const uint32 timeoutMs,
        const std::string& beanConfigPath) {
-       CAF_CM_FUNCNAME("initialize");
+       CAF_CM_FUNCNAME_VALIDATE("initialize");
        CAF_CM_PRECOND_ISNOTINITIALIZED(_isInitialized);
        CAF_CM_VALIDATE_STRING(beanConfigPath);
 
+       initializeRaw(timeoutMs, beanConfigPath, true);
+}
+
+void CIntegrationAppContext::initializeTwoPhase(
+       const uint32 timeoutMs,
+       const std::string& beanConfigPath) {
+       CAF_CM_FUNCNAME_VALIDATE("initializeTwoPhase");
+       CAF_CM_PRECOND_ISNOTINITIALIZED(_isInitialized);
+       CAF_CM_VALIDATE_STRING(beanConfigPath);
+
+       initializeRaw(timeoutMs, beanConfigPath, false);
+}
+
+void CIntegrationAppContext::initializeRaw(
+       const uint32 timeoutMs,
+       const std::string& beanConfigPath,
+       const bool startLifecycleBeans) {
+       CAF_CM_FUNCNAME("initializeRaw");
+       CAF_CM_PRECOND_ISNOTINITIALIZED(_isInitialized);
+       CAF_CM_VALIDATE_STRING(beanConfigPath);
+
+       _timeoutMs = timeoutMs;
+
        _weakSelfReference.CreateInstance();
        _weakSelfReference->set(this);
 
@@ -132,14 +158,27 @@ void CIntegrationAppContext::initialize(
        }
 
        // Start the lifecycle objects
-       startStop(_lifecycleBeans, timeoutMs, true);
+       if (startLifecycleBeans) {
+               _lifecycleBeansStarted = true;
+               startStop(_lifecycleBeans, _timeoutMs, true);
+       }
 
        _isInitialized = true;
 }
 
+void CIntegrationAppContext::startLifecycleBeans() {
+       CAF_CM_FUNCNAME_VALIDATE("startLifecycleBeans");
+       CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
+       CAF_CM_PRECOND_ISNOTINITIALIZED(_lifecycleBeansStarted);
+
+       _lifecycleBeansStarted = true;
+       startStop(_lifecycleBeans, _timeoutMs, true);
+}
+
 void CIntegrationAppContext::terminate(const uint32 timeoutMs) {
        CAF_CM_FUNCNAME("terminate");
        CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
+       CAF_CM_PRECOND_ISINITIALIZED(_lifecycleBeansStarted);
 
        try {
                _weakSelfReference->set(NULL);
index 945416c2e311c47799915cc2fcbd7a2cbc61761c..e47f264f5f7536a382f1ba77b7da3410227f944c 100644 (file)
@@ -24,9 +24,11 @@ public:
 public:
        void initialize(const uint32 timeoutMs);
        void initialize(const uint32 timeoutMs, const std::string& beanConfigPath);
+       void initializeTwoPhase(const uint32 timeoutMs, const std::string& beanConfigPath);
        void terminate(const uint32 timeoutMs);
 
 public: // IIntegrationAppContext
+       void startLifecycleBeans();
        SmartPtrIIntegrationObject getIntegrationObject(const std::string& id) const;
        void getIntegrationObject(const IID& iid, void **ppv) const;
        SmartPtrCObjectCollection getIntegrationObjects(const IID& iid) const;
@@ -45,6 +47,11 @@ private:
        typedef std::multimap<int32, SmartPtrILifecycle> LifecycleBeans;
 
 private:
+       void initializeRaw(
+                       const uint32 timeoutMs,
+                       const std::string& beanConfigPath,
+                       const bool startLifecycleBeans);
+
        SmartPtrCIntegrationObjectCollection assign(
                const IAppContext::SmartPtrCBeans& contextBeans,
                const Cdeqstr& beanConfigPathCollection) const;
@@ -102,6 +109,8 @@ private:
 private:
        bool _isInitialized;
        bool _isIntegrationObjectCollectionReady;
+       bool _lifecycleBeansStarted;
+       uint32 _timeoutMs;
        SmartPtrCApplicationContext _applicationContext;
        SmartPtrCChannelResolver _channelResolver;
        SmartPtrCIntegrationObjectCollection _integrationObjectCollection;
index 0698e1d5506aa4435922533e5435e7eb4402f548..a6674612ee781c5c82aa6f14ffb41b75379bdce6 100644 (file)
@@ -13,10 +13,12 @@ using namespace Caf;
 
 CSimpleAsyncTaskExecutor::CSimpleAsyncTaskExecutor() :
        _isInitialized(false),
+       _thread(NULL),
        CAF_CM_INIT_LOG("CSimpleAsyncTaskExecutor") {
        CAF_CM_FUNCNAME("CSimpleAsyncTaskExecutor");
 
        try {
+               CAF_CM_INIT_THREADSAFE;
                CAF_THREADSIGNAL_INIT;
        }
        CAF_CM_CATCH_ALL;
@@ -25,12 +27,30 @@ CSimpleAsyncTaskExecutor::CSimpleAsyncTaskExecutor() :
 }
 
 CSimpleAsyncTaskExecutor::~CSimpleAsyncTaskExecutor() {
+       CAF_CM_FUNCNAME("~CSimpleAsyncTaskExecutor");
+
+       try {
+               cancel(0);
+       }
+       CAF_CM_CATCH_ALL;
+       CAF_CM_LOG_CRIT_CAFEXCEPTION;
+       CAF_CM_CLEAREXCEPTION;
+
+       try {
+               if (_thread) {
+                       CThreadUtils::join(_thread);
+               }
+       }
+       CAF_CM_CATCH_ALL;
+       CAF_CM_LOG_CRIT_CAFEXCEPTION;
+       CAF_CM_CLEAREXCEPTION;
 }
 
 void CSimpleAsyncTaskExecutor::initialize(
        const SmartPtrIRunnable& runnable,
        const SmartPtrIErrorHandler& errorHandler) {
        CAF_CM_FUNCNAME_VALIDATE("initialize");
+       CAF_CM_LOCK_UNLOCK;
        CAF_CM_PRECOND_ISNOTINITIALIZED(_isInitialized);
        CAF_CM_VALIDATE_INTERFACE(runnable);
        CAF_CM_VALIDATE_INTERFACE(errorHandler);
@@ -44,6 +64,7 @@ void CSimpleAsyncTaskExecutor::initialize(
 void CSimpleAsyncTaskExecutor::execute(
        const uint32 timeoutMs) {
        CAF_CM_FUNCNAME("execute");
+       CAF_CM_LOCK_UNLOCK;
        CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
 
        if (ITaskExecutor::ETaskStateNotStarted == _state->getState()) {
@@ -59,14 +80,19 @@ void CSimpleAsyncTaskExecutor::execute(
                        CThreadData threadData = std::make_pair(
                                        CAF_THREADSIGNAL_MUTEX,
                                        _state.GetNonAddRefedInterface());
-                       CThreadUtils::start(threadFunc, &threadData);
+                       CAF_CM_VALIDATE_NULLPTR(_thread);
+                       _thread = CThreadUtils::startJoinable(threadFunc, &threadData);
+
+                       CAF_CM_UNLOCK_LOCK;
                        _state->waitForStart(CAF_THREADSIGNAL_MUTEX, timeoutMs);
                }
                if (_state->getState() != ITaskExecutor::ETaskStateStarted) {
-                       CAF_CM_EXCEPTION_VA1(ERROR_INVALID_STATE, "Not Started: %s", _state->getStateStr().c_str());
+                       CAF_CM_EXCEPTION_VA1(ERROR_INVALID_STATE,
+                                       "Not Started: %s", _state->getStateStr().c_str());
                }
        } else if (ITaskExecutor::ETaskStateStarted != _state->getState()) {
-               CAF_CM_EXCEPTION_VA1(ERROR_INVALID_STATE, "Invalid State: %s", _state->getStateStr().c_str());
+               CAF_CM_EXCEPTION_VA1(ERROR_INVALID_STATE,
+                               "Invalid State: %s", _state->getStateStr().c_str());
        }
 
        CAF_CM_LOG_INFO_VA0("Started");
@@ -75,6 +101,7 @@ void CSimpleAsyncTaskExecutor::execute(
 void CSimpleAsyncTaskExecutor::cancel(
        const uint32 timeoutMs) {
        CAF_CM_FUNCNAME("cancel");
+       CAF_CM_LOCK_UNLOCK;
        CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
 
        if (ITaskExecutor::ETaskStateStarted == _state->getState()) {
@@ -93,7 +120,15 @@ void CSimpleAsyncTaskExecutor::cancel(
                // mutex is guaranteed to unlock
                {
                        CAF_THREADSIGNAL_LOCK_UNLOCK;
-                       _state->waitForStop(CAF_THREADSIGNAL_MUTEX, timeoutMs);
+                       CAF_CM_UNLOCK_LOCK;
+                       while (! _state->getHasThreadExited()) {
+                               _state->waitForStop(CAF_THREADSIGNAL_MUTEX, timeoutMs);
+                       }
+               }
+
+               if (_thread) {
+                       CThreadUtils::join(_thread);
+                       _thread = NULL;
                }
 
                if (_state->getState() != ITaskExecutor::ETaskStateFinished) {
@@ -111,6 +146,7 @@ void CSimpleAsyncTaskExecutor::cancel(
 
 ITaskExecutor::ETaskState CSimpleAsyncTaskExecutor::getState() const {
        CAF_CM_FUNCNAME_VALIDATE("getState");
+       CAF_CM_LOCK_UNLOCK;
        CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
 
        return _state->getState();
@@ -121,6 +157,7 @@ void* CSimpleAsyncTaskExecutor::threadFunc(void* data) {
 
        SmartPtrCSimpleAsyncTaskExecutorState state;
        SmartPtrCAutoMutex mutex;
+       ITaskExecutor::ETaskState stateState = ITaskExecutor::ETaskStateFailed;
 
        try {
                CAF_CM_VALIDATE_PTR(data);
@@ -132,8 +169,9 @@ void* CSimpleAsyncTaskExecutor::threadFunc(void* data) {
                CAF_CM_VALIDATE_SMARTPTR(state);
 
                try {
-                       CAF_CM_LOCK_UNLOCK1(mutex);
                        state->setState(ITaskExecutor::ETaskStateStarted);
+
+                       CAF_CM_LOCK_UNLOCK1(mutex);
                        state->signalStart();
                }
                CAF_CM_CATCH_ALL;
@@ -142,6 +180,7 @@ void* CSimpleAsyncTaskExecutor::threadFunc(void* data) {
                if (!CAF_CM_ISEXCEPTION) {
                        try {
                                state->getRunnable()->run();
+                               stateState = ITaskExecutor::ETaskStateFinished;
                        }
                        CAF_CM_CATCH_ALL;
                        CAF_CM_LOG_CRIT_CAFEXCEPTION;
@@ -149,16 +188,12 @@ void* CSimpleAsyncTaskExecutor::threadFunc(void* data) {
 
                try {
                        if (CAF_CM_ISEXCEPTION) {
-                               state->setState(ITaskExecutor::ETaskStateFailed);
-
                                SmartPtrCIntException intException;
                                intException.CreateInstance();
                                intException->initialize(CAF_CM_GETEXCEPTION);
                                state->getErrorHandler()->handleError(intException, SmartPtrIIntMessage());
 
                                CAF_CM_CLEAREXCEPTION;
-                       } else {
-                               state->setState(ITaskExecutor::ETaskStateFinished);
                        }
                }
                CAF_CM_CATCH_ALL;
@@ -169,12 +204,12 @@ void* CSimpleAsyncTaskExecutor::threadFunc(void* data) {
        CAF_CM_LOG_CRIT_CAFEXCEPTION;
        CAF_CM_CLEAREXCEPTION;
 
-       CAF_CM_LOG_INFO_VA0("**** Thread exiting ****");
        if (! state.IsNull()) {
                try {
-                       CAF_CM_VALIDATE_PTR(mutex);
+                       state->setState(stateState);
+                       state->setThreadExited();
+
                        CAF_CM_LOCK_UNLOCK1(mutex);
-                       state->detach();
                        state->signalStop();
                }
                CAF_CM_CATCH_ALL;
@@ -182,5 +217,7 @@ void* CSimpleAsyncTaskExecutor::threadFunc(void* data) {
                CAF_CM_CLEAREXCEPTION;
        }
 
+       CAF_CM_LOG_INFO_VA0("**** Thread exiting ****");
+
        return NULL;
 }
index cf67abf8ce9f0baa5f02e7200cc6136a78662e39..9213e879ad20e1884a0c890beea34913c536be90 100644 (file)
@@ -32,6 +32,7 @@ private:
 
 private:
        bool _isInitialized;
+       GThread* _thread;
        SmartPtrCSimpleAsyncTaskExecutorState _state;
        typedef std::pair<SmartPtrCAutoMutex, CSimpleAsyncTaskExecutorState*> CThreadData;
 
@@ -39,6 +40,7 @@ private:
        CAF_CM_CREATE;
        CAF_CM_CREATE_LOG;
        CAF_THREADSIGNAL_CREATE;
+       CAF_CM_CREATE_THREADSAFE;
        CAF_CM_DECLARE_NOCOPY(CSimpleAsyncTaskExecutor);
 };
 
index f11fc9c0234d9c3ef4132dc50934f8fdfa725bec..51399fcb68257bc718157c270f4672d84ed7c7c8 100644 (file)
@@ -13,6 +13,7 @@ using namespace Caf;
 
 CSimpleAsyncTaskExecutorState::CSimpleAsyncTaskExecutorState() :
        _isInitialized(false),
+       _hasThreadExited(false),
        _runnableState(ITaskExecutor::ETaskStateNotStarted),
        CAF_CM_INIT_LOG("CSimpleAsyncTaskExecutorState") {
        CAF_CM_INIT_THREADSAFE;
@@ -84,6 +85,22 @@ void CSimpleAsyncTaskExecutorState::setState(
        _runnableState = runnableState;
 }
 
+bool CSimpleAsyncTaskExecutorState::getHasThreadExited() {
+       CAF_CM_FUNCNAME_VALIDATE("getHasThreadExited");
+       CAF_CM_LOCK_UNLOCK;
+       CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
+
+       return _hasThreadExited;
+}
+
+void CSimpleAsyncTaskExecutorState::setThreadExited() {
+       CAF_CM_FUNCNAME_VALIDATE("setThreadExited");
+       CAF_CM_LOCK_UNLOCK;
+       CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
+
+       _hasThreadExited = true;
+}
+
 SmartPtrIRunnable CSimpleAsyncTaskExecutorState::getRunnable() const {
        CAF_CM_FUNCNAME_VALIDATE("getRunnable");
        CAF_CM_LOCK_UNLOCK;
@@ -105,7 +122,7 @@ void CSimpleAsyncTaskExecutorState::signalStart() {
        CAF_CM_LOCK_UNLOCK;
        CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
 
-       CAF_CM_LOG_DEBUG_VA1("Signal (%s)", _threadSignalStart.getName().c_str());
+       CAF_CM_LOG_DEBUG_VA2("Signal (%s) - %p", _threadSignalStart.getName().c_str(), this);
        _threadSignalStart.signal();
 }
 
@@ -128,15 +145,6 @@ void CSimpleAsyncTaskExecutorState::signalStop() {
        _threadSignalStop.signal();
 }
 
-void CSimpleAsyncTaskExecutorState::detach() {
-       CAF_CM_FUNCNAME_VALIDATE("detach");
-       CAF_CM_LOCK_UNLOCK;
-       CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
-
-       _runnable = NULL;
-       _errorHandler = NULL;
-}
-
 void CSimpleAsyncTaskExecutorState::waitForStop(
        SmartPtrCAutoMutex& mutex,
        const uint32 timeoutMs) {
index 5b33f36454186e6eae90c3b6d648445cf5d2c59c..f819a98ec51b754944ea7bb14d77c688229c59d4 100644 (file)
@@ -23,21 +23,23 @@ public:
 
        SmartPtrIRunnable getRunnable() const;
        SmartPtrIErrorHandler getErrorHandler() const;
+
        ITaskExecutor::ETaskState getState() const;
        std::string getStateStr() const;
-
        void setState(const ITaskExecutor::ETaskState runnableState);
 
+       bool getHasThreadExited();
+       void setThreadExited();
+
        void signalStart();
        void waitForStart(SmartPtrCAutoMutex& mutex, const uint32 timeoutMs);
 
        void signalStop();
        void waitForStop(SmartPtrCAutoMutex& mutex, const uint32 timeoutMs);
 
-       void detach();
-
 private:
        bool _isInitialized;
+       bool _hasThreadExited;
        ITaskExecutor::ETaskState _runnableState;
        SmartPtrIRunnable _runnable;
        SmartPtrIErrorHandler _errorHandler;
index 0ec9b2e93344e74377eb5013f10cdd7a0a3debdb..7b701982d1fbba78d82bc759deada6b9a4eed0b0 100644 (file)
@@ -18,6 +18,7 @@ CSourcePollingChannelAdapter::CSourcePollingChannelAdapter() :
        _timeout(0),
        CAF_CM_INIT_LOG("CSourcePollingChannelAdapter") {
        CAF_CM_INIT_THREADSAFE;
+       CAF_THREADSIGNAL_INIT;
 }
 
 CSourcePollingChannelAdapter::~CSourcePollingChannelAdapter() {
@@ -54,12 +55,13 @@ void CSourcePollingChannelAdapter::initialize(
        _timeout = timeout;
        _isTimeoutSet = true;
 
+       _threadSignalCancel.initialize("Cancel");
+
        _isInitialized = true;
 }
 
 void CSourcePollingChannelAdapter::run() {
        CAF_CM_FUNCNAME("run");
-
        CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
 
        uint32 messageCount = 0;
@@ -95,7 +97,15 @@ void CSourcePollingChannelAdapter::run() {
 
                if (message.IsNull()
                        || (messageCount >= _pollerMetadata->getMaxMessagesPerPoll())) {
-                       CThreadUtils::sleep(_pollerMetadata->getFixedRate());
+                       {
+                               CAF_THREADSIGNAL_LOCK_UNLOCK;
+//                             CAF_CM_LOG_DEBUG_VA2("Wait (%s) - waitMs: %d",
+//                                             _threadSignalCancel.getName().c_str(),
+//                                             _pollerMetadata->getFixedRate());
+                               _threadSignalCancel.waitOrTimeout(
+                                               CAF_THREADSIGNAL_MUTEX, _pollerMetadata->getFixedRate());
+                       }
+
                        messageCount = 0;
                }
        }
@@ -105,35 +115,18 @@ void CSourcePollingChannelAdapter::run() {
 
 void CSourcePollingChannelAdapter::cancel() {
        CAF_CM_FUNCNAME_VALIDATE("cancel");
+       CAF_CM_LOCK_UNLOCK;
        CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
 
-       CAF_CM_LOG_DEBUG_VA0("Canceling");
-       setIsCancelled(true);
+       CAF_CM_LOG_DEBUG_VA1("Signal (%s)", _threadSignalCancel.getName().c_str());
+       _isCancelled = true;
+       _threadSignalCancel.signal();
 }
 
 bool CSourcePollingChannelAdapter::getIsCancelled() const {
        CAF_CM_FUNCNAME_VALIDATE("getIsCancelled");
+       CAF_CM_LOCK_UNLOCK;
+       CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
 
-       bool isCancelled = false;
-
-       CAF_CM_ENTER_AND_LOCK {
-               CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
-
-               isCancelled = _isCancelled;
-       }
-       CAF_CM_UNLOCK_AND_EXIT;
-
-       return isCancelled;
-}
-
-void CSourcePollingChannelAdapter::setIsCancelled(
-       const bool isCancelled) {
-       CAF_CM_FUNCNAME_VALIDATE("setIsCancelled");
-
-       CAF_CM_ENTER_AND_LOCK {
-               CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
-
-               _isCancelled = isCancelled;
-       }
-       CAF_CM_UNLOCK_AND_EXIT;
+       return _isCancelled;
 }
index f90e2b0d58a2b89d7ce708b554e4fab27e8702ae..7cc72060237fcf3556107952bb8bd6d8dd160f95 100644 (file)
@@ -35,7 +35,6 @@ public: // IRunnable
 
 private:
        bool getIsCancelled() const;
-       void setIsCancelled(const bool isCancelled);
 
 private:
        bool _isInitialized;
@@ -46,11 +45,13 @@ private:
        SmartPtrIPollableChannel _inputPollableChannel;
        SmartPtrIErrorHandler _errorHandler;
        SmartPtrCPollerMetadata _pollerMetadata;
+       CThreadSignal _threadSignalCancel;
 
 private:
        CAF_CM_CREATE;
        CAF_CM_CREATE_LOG;
        CAF_CM_CREATE_THREADSAFE;
+       CAF_THREADSIGNAL_CREATE;
        CAF_CM_DECLARE_NOCOPY(CSourcePollingChannelAdapter);
 };
 
index aee35b5e04c88bb5c0d44b31061aba95432e6042..5c01a7a0262433fc611faf1bf9f558d3aacfa773 100644 (file)
@@ -115,8 +115,8 @@ SmartPtrIIntMessage CErrorToResponseTransformerInstance::processErrorMessage(
                                errorResponse, relFilename, message->getHeaders());
 
                // Writing the error response for debugging purposes
-               const std::string outputDir = AppConfigUtils::getRequiredString(_sConfigOutputDir);
-               FileSystemUtils::saveTextFile(outputDir, _sErrorResponseFilename,
+               const std::string tmpDir = AppConfigUtils::getRequiredString(_sConfigTmpDir);
+               FileSystemUtils::saveTextFile(tmpDir, _sErrorResponseFilename,
                                newMessage->getPayloadStr());
        }
        CAF_CM_CATCH_ALL;
index dbc89e415b68442a955c7ac1a3b398fbfd416b66..e805e027ab2b353de0caf8fbb1a91eb2fa8550c4 100644 (file)
 
 using namespace Caf;
 
-int main(int csz, char* asz[])
-{
-       CConfigProvider provider;
-       return CProviderDriver::processProviderCommandline(provider, csz, asz);
+int main(int csz, char* asz[]) {
+       CAF_CM_STATIC_FUNC_LOG("ConfigProvider", "main");
+
+       int rc = 0;
+       try {
+               CConfigProvider provider;
+               rc = CProviderDriver::processProviderCommandline(provider, csz, asz);
+       }
+       CAF_CM_CATCH_CAF
+       CAF_CM_CATCH_DEFAULT
+       CAF_CM_LOG_CRIT_CAFEXCEPTION;
+
+       rc = CAF_CM_ISEXCEPTION ? 1 : rc;
+       CAF_CM_CLEAREXCEPTION;
+
+       return rc;
 }
index 3702454874d6400b670772d7ecb32390cb9f94dc..c79ce17d7df1c8b4c1d6619f2fba1d3e552db7b7 100644 (file)
@@ -15,8 +15,20 @@ namespace Caf {
        const char* _sInstallProviderSpecFilename = "installProviderSpec.xml";
 }
 
-int main(int csz, char* asz[])
-{
-       CInstallProvider provider;
-       return CProviderDriver::processProviderCommandline(provider, csz, asz);
+int main(int csz, char* asz[]) {
+       CAF_CM_STATIC_FUNC_LOG("InstallProvider", "main");
+
+       int rc = 0;
+       try {
+               CInstallProvider provider;
+               rc = CProviderDriver::processProviderCommandline(provider, csz, asz);
+       }
+       CAF_CM_CATCH_CAF
+       CAF_CM_CATCH_DEFAULT
+       CAF_CM_LOG_CRIT_CAFEXCEPTION;
+
+       rc = CAF_CM_ISEXCEPTION ? 1 : rc;
+       CAF_CM_CLEAREXCEPTION;
+
+       return rc;
 }
index 43076f2f77343d6de7984af75511190059547a1e..3d38ff2bb36a78a84a94617fa1049389780b48bf 100644 (file)
 
 using namespace Caf;
 
-int main(int csz, char* asz[])
-{
-       CRemoteCommandProvider provider;
-       return CProviderDriver::processProviderCommandline(provider, csz, asz);
+int main(int csz, char* asz[]) {
+       CAF_CM_STATIC_FUNC_LOG("RemoteCommandProvider", "main");
+
+       int rc = 0;
+       try {
+               CRemoteCommandProvider provider;
+               rc = CProviderDriver::processProviderCommandline(provider, csz, asz);
+       }
+       CAF_CM_CATCH_CAF
+       CAF_CM_CATCH_DEFAULT
+       CAF_CM_LOG_CRIT_CAFEXCEPTION;
+
+       rc = CAF_CM_ISEXCEPTION ? 1 : rc;
+       CAF_CM_CLEAREXCEPTION;
+
+       return rc;
 }
index db3447415fab3f43b321faa0d228e79a856067ff..9613926ab7d297f6f2f09da4bb380bb56684529e 100644 (file)
 
 using namespace Caf;
 
-int main(int csz, char* asz[])
-{
-       CTestInfraProvider provider;
-       return CProviderDriver::processProviderCommandline(provider, csz, asz);
+int main(int csz, char* asz[]) {
+       CAF_CM_STATIC_FUNC_LOG("TestInfraProvider", "main");
+
+       int rc = 0;
+       try {
+               CTestInfraProvider provider;
+               rc = CProviderDriver::processProviderCommandline(provider, csz, asz);
+       }
+       CAF_CM_CATCH_CAF
+       CAF_CM_CATCH_DEFAULT
+       CAF_CM_LOG_CRIT_CAFEXCEPTION;
+
+       rc = CAF_CM_ISEXCEPTION ? 1 : rc;
+       CAF_CM_CLEAREXCEPTION;
+
+       return rc;
 }
index 20670e2a683cffb128043030ab568627f5d49b6c..636aca46a74f29e599a25af87f123b948c5e482a 100644 (file)
@@ -43,8 +43,7 @@ void CManagementAgentHostWork::doWork() {
                _isWorking = true;
 
                CLoggingUtils::setStartupConfigFile(
-                       AppConfigUtils::getRequiredString(_sAppConfigGlobalParamLogConfigFile));
-               CLoggingUtils::setLogDir(
+                       AppConfigUtils::getRequiredString(_sAppConfigGlobalParamLogConfigFile),
                        AppConfigUtils::getRequiredString(_sAppConfigGlobalParamLogDir));
 
                const uint32 hostDelaySec = AppConfigUtils::getRequiredUint32(
@@ -61,6 +60,7 @@ void CManagementAgentHostWork::doWork() {
        }
        CAF_CM_CATCH_ALL;
        CAF_CM_LOG_CRIT_CAFEXCEPTION;
+       CAF_CM_CLEAREXCEPTION;
 
        try {
                if (! integrationAppContext.IsNull()) {
index 5cda71877e0d2ca79ed2adc43dc43c9dbf566d75..06e8559328a4ab2dc82898e0aadf223cb422e2d9 100644 (file)
@@ -32,11 +32,11 @@ int32 main(int32 argc, char** argv) {
                return 1;
        }
 
-       CafInitialize::serviceConfig();
 
        SmartPtrIAppConfig appConfig;
-
        try {
+               CafInitialize::serviceConfig();
+
                std::string appConfigEnv;
                CEnvironmentUtils::readEnvironmentVar("CAF_APPCONFIG", appConfigEnv);
                if (appConfigEnv.empty()) {
@@ -83,20 +83,20 @@ int32 main(int32 argc, char** argv) {
                                "ManagementAgentHost: getAppConfig() failed . unknown exception\n");
        }
 
-       if (!appConfig) {
-               CafInitialize::term();
-               return 1;
-       }
-
-       const std::string cafBinDir = AppConfigUtils::getRequiredString("globals", "bin_dir");
-       g_setenv("CAF_BIN_DIR", cafBinDir.c_str(), TRUE);
-
-       const std::string cafLibDir = AppConfigUtils::getRequiredString("globals", "lib_dir");
-       g_setenv("CAF_LIB_DIR", cafLibDir.c_str(), TRUE);
-
        CAF_CM_STATIC_FUNC_LOG("ManagementAgentHostMain", "main");
        int32 iRc = 0;
        try {
+               if (!appConfig) {
+                       CafInitialize::term();
+                       return 1;
+               }
+
+               const std::string cafBinDir = AppConfigUtils::getRequiredString("globals", "bin_dir");
+               g_setenv("CAF_BIN_DIR", cafBinDir.c_str(), TRUE);
+
+               const std::string cafLibDir = AppConfigUtils::getRequiredString("globals", "lib_dir");
+               g_setenv("CAF_LIB_DIR", cafLibDir.c_str(), TRUE);
+
                _gManagementAgentHostWork.CreateInstance();
                _gManagementAgentHostWork->initialize();
 
@@ -109,17 +109,18 @@ int32 main(int32 argc, char** argv) {
                        return 1;
                }
 
+               const std::string procPath = argv[0];
                CDaemonUtils::MakeDaemon(
                        argc,
                        argv,
+                       procPath,
                        "ManagementAgentHost",
                        TermHandler,
                        _gDaemonized,
                        _gSysLogInfos);
 
                CLoggingUtils::setStartupConfigFile(
-                       AppConfigUtils::getRequiredString(_sAppConfigGlobalParamLogConfigFile));
-               CLoggingUtils::setLogDir(
+                       AppConfigUtils::getRequiredString(_sAppConfigGlobalParamLogConfigFile),
                        AppConfigUtils::getRequiredString(_sAppConfigGlobalParamLogDir));
 
                _gManagementAgentHostWork->doWork();
index 8bb6176a8edbf04d3888c43219a37b6806ebc75c..3b5c575818cc3661894e66fa25d7ee673a184c10 100644 (file)
@@ -148,7 +148,7 @@ std::string CAttachmentRequestTransformerInstance::calcOutputDirPath(
                const std::string outputDir = AppConfigUtils::getRequiredString(_sConfigOutputDir);
 
                outputDirPath = FileSystemUtils::buildPath(
-                       outputDir, clientIdStr, requestIdStr, pmeIdStr);
+                       outputDir, "att", clientIdStr, requestIdStr, pmeIdStr);
 
                outputDirPath = CStringUtils::expandEnv(outputDirPath);
                if (! FileSystemUtils::doesDirectoryExist(outputDirPath)) {
index df0d5f4b42bc63c3d1f4c833c6b92bacaf8d1813..1f13a6af2a89ec5ae57b1343a51d1e1f440fc180 100644 (file)
@@ -73,11 +73,9 @@ SmartPtrIIntMessage CCollectSchemaExecutor::processMessage(
                const std::string outputDir = FileSystemUtils::buildPath(
                        configOutputDir, _sProviderHostArea, relDirectory);
 
-               if (AppConfigUtils::getRequiredBoolean("managementAgent", "remap_logging_location")) {
-                       SmartPtrCLoggingSetter loggingSetter;
-                       loggingSetter.CreateInstance();
-                       loggingSetter->initialize(outputDir);
-               }
+               SmartPtrCLoggingSetter loggingSetter;
+               loggingSetter.CreateInstance();
+               loggingSetter->initialize(outputDir);
 
                const std::string providerCollectSchemaMem = message->getPayloadStr();
                const SmartPtrCProviderCollectSchemaRequestDoc providerCollectSchemaRequest =
index d3a1006d424239e682cc482169f075a0b31bb349..a61d67c1c1955e65f62eaaefab0f23aa7b094f71 100644 (file)
@@ -37,6 +37,8 @@ void CConfigEnv::initialize(
                        _persistenceRemove = persistenceRemove;
                }
        } else {
+               _persistenceRemove = persistenceRemove;
+
                _persistenceDir = AppConfigUtils::getRequiredString("persistence_dir");
 
                _configDir = AppConfigUtils::getRequiredString("config_dir");
@@ -60,7 +62,7 @@ void CConfigEnv::initialize(
 
                _persistence = CPersistenceUtils::loadPersistence(_persistenceDir);
                _persistenceUpdated = _persistence;
-               _persistenceRemove = persistenceRemove;
+               savePersistenceAppconfig(_persistence, _configDir);
 
                _isInitialized = true;
        }
@@ -74,13 +76,13 @@ SmartPtrCPersistenceDoc CConfigEnv::getUpdated(
 
        const SmartPtrCPersistenceDoc persistenceTmp =
                        CConfigEnvMerge::mergePersistence(_persistence, _cacertPath, _vcidPath);
-       if (! persistenceTmp.IsNull() || ! FileSystemUtils::doesFileExist(_persistenceAppconfigPath)) {
-               if (! persistenceTmp.IsNull()) {
-                       _persistence = persistenceTmp;
-               }
+       if (! persistenceTmp.IsNull()) {
+               _persistence = persistenceTmp;
+               _persistenceUpdated = _persistence;
 
                savePersistenceAppconfig(_persistence, _configDir);
-               restartListener("Updated persistence-appconfig");
+               CPersistenceUtils::savePersistence(_persistence, _persistenceDir);
+               restartListener("Info changed on disk");
        }
 
        SmartPtrCPersistenceDoc rc;
@@ -102,16 +104,15 @@ void CConfigEnv::update(
        const SmartPtrCPersistenceDoc persistenceTmp =
                        CPersistenceMerge::mergePersistence(_persistence, persistence);
        if (! persistenceTmp.IsNull()) {
-               CAF_CM_LOG_DEBUG_VA1("Updating persistence info - %s", _persistenceDir.c_str());
-
                _persistence = persistenceTmp;
-               _persistenceUpdated = createPersistenceUpdated(_persistence);
+               _persistenceUpdated = _persistence;
+
+               savePersistenceAppconfig(_persistence, _configDir);
                CPersistenceUtils::savePersistence(_persistence, _persistenceDir);
 
-               const std::string reason = "Updated persistence info";
+               const std::string reason = "Info changed at source";
                listenerConfigured(reason);
                restartListener(reason);
-
                removePrivateKey(_persistence, _persistenceRemove);
        } else {
                CAF_CM_LOG_DEBUG_VA0("Persistence info did not change");
@@ -125,32 +126,38 @@ void CConfigEnv::savePersistenceAppconfig(
        CAF_CM_VALIDATE_SMARTPTR(persistence);
        CAF_CM_VALIDATE_STRING(configDir);
 
-       #ifdef WIN32
+       const SmartPtrCPersistenceProtocolDoc persistenceProtocol =
+                       CPersistenceUtils::loadPersistenceProtocol(
+                                       persistence->getPersistenceProtocolCollection());
+       if (persistenceProtocol.IsNull() || persistenceProtocol->getUri().empty()) {
+               CAF_CM_LOG_DEBUG_VA1(
+                               "Can't create persistence-appconfig until protocol is established - %s",
+                               configDir.c_str());
+       } else {
+#ifdef WIN32
        const std::string newLine = "\r\n";
 #else
        const std::string newLine = "\n";
 #endif
-       CAF_CM_LOG_DEBUG_VA1("Saving persistence-appconfig - %s", configDir.c_str());
 
-       const SmartPtrCPersistenceProtocolDoc persistenceProtocol =
-                       CPersistenceUtils::loadPersistenceProtocol(
-                                       persistence->getPersistenceProtocolCollection());
+               CAF_CM_LOG_DEBUG_VA1("Saving persistence-appconfig - %s", configDir.c_str());
 
-       UriUtils::SUriRecord uriRecord;
-       UriUtils::parseUriString(persistenceProtocol->getUri(), uriRecord);
-       CAF_CM_VALIDATE_STRING(uriRecord.path);
+               UriUtils::SUriRecord uriRecord;
+               UriUtils::parseUriString(persistenceProtocol->getUri(), uriRecord);
+               CAF_CM_VALIDATE_STRING(uriRecord.path);
 
-       const std::string listenerContext = calcListenerContext(uriRecord.protocol, configDir);
+               const std::string listenerContext = calcListenerContext(uriRecord.protocol, configDir);
 
-       CAF_CM_LOG_DEBUG_VA2("Calculated listener context - uri: %s, protocol: %s",
-                       persistenceProtocol->getUri().c_str(), uriRecord.protocol.c_str());
+               CAF_CM_LOG_DEBUG_VA2("Calculated listener context - uri: %s, protocol: %s",
+                               persistenceProtocol->getUri().c_str(), uriRecord.protocol.c_str());
 
-       std::string appconfigContents;
-       appconfigContents = "[globals]" + newLine;
-       appconfigContents += "reactive_request_amqp_queue_id=" + uriRecord.path + newLine;
-       appconfigContents += "comm_amqp_listener_context=" + listenerContext + newLine;
+               std::string appconfigContents;
+               appconfigContents = "[globals]" + newLine;
+               appconfigContents += "reactive_request_amqp_queue_id=" + uriRecord.path + newLine;
+               appconfigContents += "comm_amqp_listener_context=" + listenerContext + newLine;
 
-       FileSystemUtils::saveTextFile(_persistenceAppconfigPath, appconfigContents);
+               FileSystemUtils::saveTextFile(_persistenceAppconfigPath, appconfigContents);
+       }
 }
 
 void CConfigEnv::removePrivateKey(
@@ -175,48 +182,6 @@ void CConfigEnv::removePrivateKey(
        }
 }
 
-SmartPtrCPersistenceDoc CConfigEnv::createPersistenceUpdated(
-               const SmartPtrCPersistenceDoc& persistence) const {
-       CAF_CM_FUNCNAME_VALIDATE("createPersistenceUpdated");
-       CAF_CM_VALIDATE_SMARTPTR(persistence);
-
-       SmartPtrCLocalSecurityDoc localSecurity;
-       if (! persistence->getLocalSecurity().IsNull()
-                       && ! persistence->getLocalSecurity()->getLocalId().empty()) {
-               localSecurity.CreateInstance();
-               localSecurity->initialize(persistence->getLocalSecurity()->getLocalId());
-       }
-
-       SmartPtrCPersistenceProtocolCollectionDoc persistenceProtocolCollection;
-       if (! persistence->getPersistenceProtocolCollection().IsNull()
-                       && ! persistence->getPersistenceProtocolCollection()->getPersistenceProtocol().empty()) {
-               const SmartPtrCPersistenceProtocolDoc persistenceProtocolTmp =
-                               CPersistenceUtils::loadPersistenceProtocol(persistence->getPersistenceProtocolCollection());
-               if (! persistenceProtocolTmp->getUri().empty()) {
-                       SmartPtrCPersistenceProtocolDoc persistenceProtocol;
-                       persistenceProtocol.CreateInstance();
-                       persistenceProtocol->initialize(
-                                       persistenceProtocolTmp->getProtocolName(),
-                                       persistenceProtocolTmp->getUri());
-
-                       std::deque<SmartPtrCPersistenceProtocolDoc> persistenceProtocolInner;
-                       persistenceProtocolInner.push_back(persistenceProtocol);
-
-                       persistenceProtocolCollection.CreateInstance();
-                       persistenceProtocolCollection->initialize(persistenceProtocolInner);
-               }
-       }
-
-       SmartPtrCPersistenceDoc rc;
-       if (! localSecurity.IsNull() || ! persistenceProtocolCollection.IsNull()) {
-               rc.CreateInstance();
-               rc->initialize(localSecurity, SmartPtrCRemoteSecurityCollectionDoc(),
-                               persistenceProtocolCollection, persistence->getVersion());
-       }
-
-       return rc;
-}
-
 std::string CConfigEnv::calcListenerContext(
                const std::string& uriSchema,
                const std::string& configDir) const {
index 95654d236885b411b2fd3b1ea891c97c4cdb59d2..94b850cb6248b456170ca4b0520824e7710f2916 100644 (file)
@@ -57,9 +57,6 @@ private:
                        const SmartPtrCPersistenceDoc& persistence,
                        const SmartPtrIPersistence& persistenceRemove) const;
 
-       SmartPtrCPersistenceDoc createPersistenceUpdated(
-                       const SmartPtrCPersistenceDoc& persistence) const;
-
        std::string calcListenerContext(
                        const std::string& uriSchema,
                        const std::string& configDir) const;
index aad7fa41f5b7ad426822e3a23f69ebf6b165927a..545dd5061c093cd06c12c97d6c79af150d1b42a2 100644 (file)
@@ -9,6 +9,15 @@
 #include "stdafx.h"
 #include "CConfigEnvMerge.h"
 
+#ifdef WIN32
+       #include <winsock.h>
+       #pragma comment (lib, "wsock32.lib")
+#else
+       #include <sys/socket.h>
+       #include <netinet/in.h>
+       #include <arpa/inet.h>
+#endif
+
 using namespace Caf;
 
 SmartPtrCPersistenceDoc CConfigEnvMerge::mergePersistence(
@@ -20,34 +29,30 @@ SmartPtrCPersistenceDoc CConfigEnvMerge::mergePersistence(
        CAF_CM_VALIDATE_STRING(cacertPath);
        CAF_CM_VALIDATE_STRING(vcidPath);
 
-       const std::string cacert = FileSystemUtils::doesFileExist(cacertPath) ?
-                       FileSystemUtils::loadTextFile(cacertPath) : std::string();
-       const std::string vcid = FileSystemUtils::doesFileExist(vcidPath) ?
-                       FileSystemUtils::loadTextFile(vcidPath) : std::string();
-       const std::string protocol = isTunnelEnabled() ? "tunnel" : "amqp";
-
-       std::string vcidDiff;
-       if (! vcid.empty()) {
-               if (persistence->getLocalSecurity()->getLocalId().compare(vcid) != 0) {
-                       CAF_CM_LOG_DEBUG_VA2("vcid changed - %s != %s",
-                                       persistence->getLocalSecurity()->getLocalId().c_str(), vcid.c_str());
-                       vcidDiff = vcid;
-               }
+       const std::string localId = mergeLocalId(persistence, vcidPath);
+
+       std::string localIdDiff;
+       if (persistence->getLocalSecurity()->getLocalId().compare(localId) != 0) {
+               CAF_CM_LOG_DEBUG_VA2("LocalId changed - %s != %s",
+                               persistence->getLocalSecurity()->getLocalId().c_str(), localId.c_str());
+               localIdDiff = localId;
        }
 
+       const std::string cacert = loadTextFile(cacertPath);
+
        const std::deque<SmartPtrCPersistenceProtocolDoc> persistenceProtocolCollectionInnerDiff =
                        mergePersistenceProtocolCollectionInner(
                                        persistence->getPersistenceProtocolCollection()->getPersistenceProtocol(),
-                                       protocol, vcid, cacert);
+                                       localId, cacert);
 
        SmartPtrCPersistenceDoc rc;
-       if (! vcidDiff.empty() || ! persistenceProtocolCollectionInnerDiff.empty()) {
+       if (! localIdDiff.empty() || ! persistenceProtocolCollectionInnerDiff.empty()) {
                SmartPtrCLocalSecurityDoc localSecurity = persistence->getLocalSecurity();
-               if (! vcidDiff.empty()) {
+               if (! localIdDiff.empty()) {
                        CAF_CM_LOG_DEBUG_VA0("Creating local security diff");
                        localSecurity.CreateInstance();
                        localSecurity->initialize(
-                                       vcidDiff,
+                                       localIdDiff,
                                        persistence->getLocalSecurity()->getPrivateKey(),
                                        persistence->getLocalSecurity()->getCert(),
                                        persistence->getLocalSecurity()->getPrivateKeyPath(),
@@ -73,13 +78,32 @@ SmartPtrCPersistenceDoc CConfigEnvMerge::mergePersistence(
        return rc;
 }
 
+std::string CConfigEnvMerge::mergeLocalId(
+               const SmartPtrCPersistenceDoc& persistence,
+               const std::string& vcidPath) {
+       CAF_CM_STATIC_FUNC_LOG_VALIDATE("CConfigEnvMerge", "mergeLocalId");
+       CAF_CM_VALIDATE_SMARTPTR(persistence);
+       CAF_CM_VALIDATE_STRING(vcidPath);
+
+       std::string rc = loadTextFile(vcidPath);
+       if (rc.empty()) {
+               if (persistence->getLocalSecurity()->getLocalId().empty()) {
+                       rc = CStringUtils::createRandomUuid();
+               } else {
+                       rc = persistence->getLocalSecurity()->getLocalId();
+               }
+       }
+
+       return rc;
+}
+
 std::deque<SmartPtrCPersistenceProtocolDoc> CConfigEnvMerge::mergePersistenceProtocolCollectionInner(
                const std::deque<SmartPtrCPersistenceProtocolDoc>& persistenceProtocolCollectionInner,
-               const std::string& protocol,
-               const std::string& vcid,
+               const std::string& localId,
                const std::string& cacert) {
        CAF_CM_STATIC_FUNC_LOG_VALIDATE("CConfigEnvMerge", "mergePersistenceProtocolCollectionInner");
-       CAF_CM_VALIDATE_BOOL(persistenceProtocolCollectionInner.size() <= 1);
+       CAF_CM_VALIDATE_BOOL(persistenceProtocolCollectionInner.size() == 1);
+       CAF_CM_VALIDATE_STRING(localId);
 
        std::deque<SmartPtrCPersistenceProtocolDoc> rc;
        std::deque<SmartPtrCPersistenceProtocolDoc> persistenceProtocolCollectionInnerDiff;
@@ -88,7 +112,11 @@ std::deque<SmartPtrCPersistenceProtocolDoc> CConfigEnvMerge::mergePersistencePro
                persistenceProtocolIter; persistenceProtocolIter++) {
                const SmartPtrCPersistenceProtocolDoc persistenceProtocol = *persistenceProtocolIter;
 
-               const std::string uriDiff = mergeUri(persistenceProtocol->getUri(), protocol, vcid);
+               const std::string uriDiff = mergeUri(
+                               persistenceProtocol->getUri(),
+                               persistenceProtocol->getUriAmqp(),
+                               persistenceProtocol->getUriTunnel(),
+                               localId);
                const SmartPtrCCertCollectionDoc tlsCertCollectionDiff =
                                mergeTlsCertCollection(persistenceProtocol->getTlsCertCollection(), cacert);
 
@@ -97,6 +125,8 @@ std::deque<SmartPtrCPersistenceProtocolDoc> CConfigEnvMerge::mergePersistencePro
                persistenceProtocolDiff->initialize(
                                persistenceProtocol->getProtocolName(),
                                uriDiff.empty() ? persistenceProtocol->getUri() : uriDiff,
+                               persistenceProtocol->getUriAmqp(),
+                               persistenceProtocol->getUriTunnel(),
                                persistenceProtocol->getTlsCert(),
                                persistenceProtocol->getTlsProtocol(),
                                persistenceProtocol->getTlsCipherCollection(),
@@ -118,34 +148,44 @@ std::deque<SmartPtrCPersistenceProtocolDoc> CConfigEnvMerge::mergePersistencePro
 }
 
 std::string CConfigEnvMerge::mergeUri(
-               const std::string& srcUri,
-               const std::string& protocol,
-               const std::string& vcid) {
-       CAF_CM_STATIC_FUNC_LOG_ONLY("CConfigEnvMerge", "mergeUri");
-       std::string rc;
-       if (! srcUri.empty()) {
-               UriUtils::SUriRecord uriData;
-               UriUtils::parseUriString(srcUri, uriData);
-
-               bool isUriChanged = false;
-               //TODO: Comment back in once isTunnelEnabled() has been implemented
-//             if (uriData.protocol.compare(protocol) != 0) {
-//                     uriData.protocol = protocol;
-//                     isUriChanged = true;
-//             }
-               std::string tunnelVcid = vcid;
-               if (uriData.protocol.compare("tunnel") == 0) {
-                       tunnelVcid += "-agentId1";
-               }
-               if (! tunnelVcid.empty() && (uriData.path.compare(tunnelVcid) != 0)) {
-                       uriData.path = tunnelVcid;
-                       isUriChanged = true;
-               }
+               const std::string& uri,
+               const std::string& uriAmqp,
+               const std::string& uriTunnel,
+               const std::string& localId) {
+       CAF_CM_STATIC_FUNC_LOG_VALIDATE("CConfigEnvMerge", "mergeUri");
+       CAF_CM_VALIDATE_STRING(uriAmqp);
+       CAF_CM_VALIDATE_STRING(uriTunnel);
+       CAF_CM_VALIDATE_STRING(localId);
 
-               if (isUriChanged) {
-                       rc = UriUtils::buildUriString(uriData);
-                       CAF_CM_LOG_DEBUG_VA2("uri changed - %s != %s", srcUri.c_str(), rc.c_str());
-               }
+       UriUtils::SUriRecord uriData;
+       if (! uri.empty()) {
+               UriUtils::parseUriString(uri, uriData);
+       }
+
+       const bool isTunnelEnabled = isTunnelEnabledFunc();
+       const std::string uriProtocol = isTunnelEnabled ? "tunnel" : "amqp";
+
+       bool isUriChanged = false;
+       if (uriData.protocol.compare(uriProtocol) != 0) {
+               const std::string uriTmp = isTunnelEnabled ? uriTunnel : uriAmqp;
+               UriUtils::parseUriString(uriTmp, uriData);
+               isUriChanged = true;
+       }
+
+       std::string amqpQueueId = localId;
+       if (isTunnelEnabled) {
+               amqpQueueId += "-agentId1";
+       }
+
+       if (uriData.path.compare(amqpQueueId) != 0) {
+               uriData.path = amqpQueueId;
+               isUriChanged = true;
+       }
+
+       std::string rc;
+       if (isUriChanged) {
+               rc = UriUtils::buildUriString(uriData);
+               CAF_CM_LOG_DEBUG_VA2("uri changed - %s != %s", uri.c_str(), rc.c_str());
        }
 
        return rc;
@@ -177,7 +217,81 @@ SmartPtrCCertCollectionDoc CConfigEnvMerge::mergeTlsCertCollection(
        return rc;
 }
 
-//TODO: Implement isTunnelEnabled
-bool CConfigEnvMerge::isTunnelEnabled() {
-       return false;
+bool CConfigEnvMerge::isTunnelEnabledFunc() {
+       CAF_CM_STATIC_FUNC_LOG("CConfigEnvMerge", "isTunnelEnabledFunc");
+
+       bool rc = false;
+
+#ifdef WIN32
+       try {
+               WSADATA wsaData;
+               int result = ::WSAStartup(MAKEWORD(2, 2), &wsaData);
+               if (result != NO_ERROR) {
+                       CAF_CM_EXCEPTION_VA0(E_UNEXPECTED, "WSAStartup() Failed");
+               }
+
+               SOCKADDR_IN socketClient;
+               memset(&socketClient, 0, sizeof(SOCKADDR_IN));
+               socketClient.sin_family = AF_INET;
+               socketClient.sin_addr.s_addr = ::inet_addr("127.0.0.1");
+               socketClient.sin_port = ::htons(6672);
+
+               SOCKET socketFd = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+               if (socketFd == INVALID_SOCKET) {
+                       CAF_CM_EXCEPTION_VA1(E_UNEXPECTED, "Failed to open socket - %s", WSAGetLastError());
+               }
+
+               rc = (0 == ::connect(socketFd, (SOCKADDR*) &socketClient, sizeof(socketClient)));
+       }
+       CAF_CM_CATCH_CAF
+       CAF_CM_CATCH_DEFAULT
+       CAF_CM_LOG_CRIT_CAFEXCEPTION;
+       CAF_CM_CLEAREXCEPTION;
+
+       WSACleanup();
+#else
+       int socketFd = -1;
+       try {
+               socketFd = ::socket(AF_INET, SOCK_STREAM, 0);
+               if (socketFd < 0) {
+                       CAF_CM_EXCEPTION_VA0(E_UNEXPECTED, "Failed to open socket");
+               }
+
+               struct sockaddr_in socketClient;
+               memset(&socketClient, 0, sizeof(sockaddr_in));
+               socketClient.sin_family = AF_INET;
+               socketClient.sin_port = htons(6672);
+
+               int result = ::inet_aton("127.0.0.1", &socketClient.sin_addr);
+               if (0 == result) {
+                       CAF_CM_EXCEPTION_VA0(ERROR_PATH_NOT_FOUND,
+                                       "Failed to get address of 127.0.0.1");
+               }
+
+               rc = (0 == ::connect(socketFd, (struct sockaddr *) &socketClient,
+                               sizeof(socketClient)));
+       }
+       CAF_CM_CATCH_CAF
+       CAF_CM_CATCH_DEFAULT
+       CAF_CM_LOG_CRIT_CAFEXCEPTION;
+       CAF_CM_CLEAREXCEPTION;
+
+       if (socketFd >= 0) {
+               ::close(socketFd);
+       }
+#endif
+
+       return rc;
+}
+
+std::string CConfigEnvMerge::loadTextFile(
+               const std::string& path) {
+
+       std::string rc;
+       if (FileSystemUtils::doesFileExist(path)) {
+               rc = FileSystemUtils::loadTextFile(path);
+               rc = CStringUtils::trimRight(rc);
+       }
+
+       return rc;
 }
index 047a67fbb52d828d9f3ed5dd925f856ed670a85d..083baf8596b4e4cf4ca5c2ea7fbe1ee573ec0dab 100644 (file)
@@ -22,21 +22,28 @@ public:
 private:
        static std::deque<SmartPtrCPersistenceProtocolDoc> mergePersistenceProtocolCollectionInner(
                        const std::deque<SmartPtrCPersistenceProtocolDoc>& persistenceProtocolCollectionInner,
-                       const std::string& protocol,
-                       const std::string& vcid,
+                       const std::string& localId,
                        const std::string& cacert);
 
+       static std::string mergeLocalId(
+                       const SmartPtrCPersistenceDoc& persistence,
+                       const std::string& vcidPath);
+
        static std::string mergeUri(
-                       const std::string& srcUri,
-                       const std::string& protocol,
-                       const std::string& vcid);
+                       const std::string& uri,
+                       const std::string& uriAmqp,
+                       const std::string& uriTunnel,
+                       const std::string& localId);
 
        static SmartPtrCCertCollectionDoc mergeTlsCertCollection(
                        const SmartPtrCCertCollectionDoc& tlsCertCollection,
                        const std::string& cacert);
 
 private:
-       static bool isTunnelEnabled();
+       static bool isTunnelEnabledFunc();
+
+       static std::string loadTextFile(
+                       const std::string& path);
 
 private:
        CAF_CM_DECLARE_NOCREATE(CConfigEnvMerge);
index d6ec6c0d8b7d1196f39687ff2f6007649e3d76a5..9ac2409eed39681bcd9b3d68a0af00bb66354e84 100644 (file)
@@ -142,6 +142,7 @@ SmartPtrIPersistence CConfigEnvOutboundChannelAdapterInstance::createOptPersiste
                        CAF_CM_LOG_WARN_VA2("initialize failed - ref: %s, msg: %s",
                                        removeRefStr.c_str(), (CAF_CM_EXCEPTION_GET_FULLMSG).c_str());
                        rc = SmartPtrIPersistence();
+                       CAF_CM_CLEAREXCEPTION;
                }
        }
 
index cc53113b8d80d52091874b912bf37036cf297d79..d5d5a8fc6c795fe71686d8eefa89bb2dfa6c29c6 100644 (file)
@@ -38,9 +38,9 @@ void CMonitorReadingMessageSource::initialize(
        _restartListenerPath = FileSystemUtils::buildPath(_monitorDir, "restartListener.txt");
        _listenerConfiguredPath = FileSystemUtils::buildPath(_monitorDir, "listenerConfigured.txt");
 
-       _outputDir = AppConfigUtils::getRequiredString(_sAppConfigGlobalParamOutputDir);
+       _scriptOutputDir = AppConfigUtils::getRequiredString(_sConfigTmpDir);
        _listenerStartupType = AppConfigUtils::getRequiredString("monitor", "listener_startup_type");
-       _listenerRetryMax = AppConfigUtils::getRequiredUint32("monitor", "listener_retry_max");
+       _listenerRetryMax = AppConfigUtils::getRequiredInt32("monitor", "listener_retry_max");
 
        _listenerRestartMs = calcListenerRestartMs();
        CAF_CM_LOG_DEBUG_VA1("_listenerRestartMs: %d", _listenerRestartMs);
@@ -56,6 +56,9 @@ void CMonitorReadingMessageSource::initialize(
        _isListenerRunningScript = FileSystemUtils::buildPath(scriptsDir, "is-listener-running");
 #endif
 
+       if (! FileSystemUtils::doesDirectoryExist(_monitorDir)) {
+               FileSystemUtils::createDirectory(_monitorDir);
+       }
        _isInitialized = true;
 }
 
@@ -104,15 +107,15 @@ SmartPtrIIntMessage CMonitorReadingMessageSource::doReceive(
                                if (_listenerStartupType.compare("Automatic") == 0) {
                                        if ((_listenerRetryMax < 0) || (_listenerRetryCnt < _listenerRetryMax)) {
                                                reason = "Listener not running... Starting - "
-                                                               + CStringConv::toString<uint32>(_listenerRetryCnt + 1) + " of "
-                                                               + CStringConv::toString<uint32>(_listenerRetryMax);
+                                                               + CStringConv::toString<int32>(_listenerRetryCnt + 1) + " of "
+                                                               + CStringConv::toString<int32>(_listenerRetryMax);
                                                _listenerRetryCnt++;
                                                _listenerStartTimeMs = CDateTimeUtils::getTimeMs();
                                                startListener(reason);
                                        } else {
                                                reason = "Listener not running... Retries exhausted - "
-                                                               + CStringConv::toString<uint32>(_listenerRetryCnt + 1) + " of "
-                                                               + CStringConv::toString<uint32>(_listenerRetryMax);
+                                                               + CStringConv::toString<int32>(_listenerRetryCnt + 1) + " of "
+                                                               + CStringConv::toString<int32>(_listenerRetryMax);
                                                CAF_CM_LOG_WARN_VA0(reason.c_str());
                                        }
                                } else {
@@ -138,7 +141,7 @@ SmartPtrIIntMessage CMonitorReadingMessageSource::doReceive(
 }
 
 bool CMonitorReadingMessageSource::isListenerRunning() const {
-       const std::string stdoutStr = executeScript(_isListenerRunningScript, _outputDir);
+       const std::string stdoutStr = executeScript(_isListenerRunningScript, _scriptOutputDir);
        return (stdoutStr.compare("true") == 0);
 }
 
@@ -148,7 +151,7 @@ void CMonitorReadingMessageSource::startListener(
 
        CAF_CM_LOG_DEBUG_VA1(
                        "Starting the listener - reason: %s", reason.c_str());
-       executeScript(_startListenerScript, _outputDir);
+       executeScript(_startListenerScript, _scriptOutputDir);
 }
 
 void CMonitorReadingMessageSource::stopListener(
@@ -157,7 +160,7 @@ void CMonitorReadingMessageSource::stopListener(
 
        CAF_CM_LOG_DEBUG_VA1(
                        "Stopping the listener - reason: %s", reason.c_str());
-       executeScript(_stopListenerScript, _outputDir);
+       executeScript(_stopListenerScript, _scriptOutputDir);
 }
 
 void CMonitorReadingMessageSource::restartListener(
@@ -166,8 +169,8 @@ void CMonitorReadingMessageSource::restartListener(
 
        CAF_CM_LOG_DEBUG_VA1(
                        "Restarting the listener - reason: %s", reason.c_str());
-       executeScript(_stopListenerScript, _outputDir);
-       executeScript(_startListenerScript, _outputDir);
+       executeScript(_stopListenerScript, _scriptOutputDir);
+       executeScript(_startListenerScript, _scriptOutputDir);
 }
 
 std::string CMonitorReadingMessageSource::executeScript(
index 08790179ab1a6072f1f37f7e58fdd45907d4860b..4e58d3964492eb1b334aeda99df29259e6513753 100644 (file)
@@ -65,14 +65,14 @@ private:
        std::string _restartListenerPath;
        std::string _listenerConfiguredPath;
 
-       std::string _outputDir;
+       std::string _scriptOutputDir;
        std::string _stopListenerScript;
        std::string _startListenerScript;
        std::string _isListenerRunningScript;
 
        std::string _listenerStartupType;
-       uint32 _listenerRetryCnt;
-       uint32 _listenerRetryMax;
+       int32 _listenerRetryCnt;
+       int32 _listenerRetryMax;
 
 private:
        CAF_CM_CREATE;
index 2a391a2518b4378e1d0955d6e2ea8d575f93f58e..d0ccb5eedc72821185d9b3f400521ff64970dfae 100644 (file)
@@ -145,6 +145,7 @@ SmartPtrIPersistence CPersistenceInboundChannelAdapterInstance::createPersistenc
                CAF_CM_LOG_WARN_VA2("initialize failed - ref: %s, msg: %s",
                                removeRefStr.c_str(), (CAF_CM_EXCEPTION_GET_FULLMSG).c_str());
                rc = SmartPtrIPersistence();
+               CAF_CM_CLEAREXCEPTION;
        }
 
        return rc;
index 0a64219e050d88382c8f4b7b3c49e435add81aba..ac329af0540041c226e1526fbde0453215079709 100644 (file)
@@ -191,6 +191,8 @@ SmartPtrCPersistenceProtocolDoc CPersistenceMerge::mergePersistenceProtocol(
                                rc->initialize(
                                                protocolName.empty() ? persistenceProtocolIn->getProtocolName() : protocolName,
                                                uri.empty() ? persistenceProtocolIn->getUri() : uri,
+                                               persistenceProtocolLoaded->getUriAmqp(),
+                                               persistenceProtocolLoaded->getUriTunnel(),
                                                tlsCert.empty() ? persistenceProtocolIn->getTlsCert() : tlsCert,
                                                tlsProtocol.empty() ? persistenceProtocolIn->getTlsProtocol() : tlsProtocol,
                                                tlsCipherCollection.empty() ? persistenceProtocolIn->getTlsCipherCollection() : tlsCipherCollection,
index 099bc6fb5aa522e2f306e209db981f90f59fff50..b439d6233621ca219e187a3b59092282f8ee6288 100644 (file)
 #include <string>
 
 using namespace Caf;
-using namespace std;
-
-#ifdef WIN32
-       const string CPersistenceNamespaceDb::_NAMESPACE_DB_CMD_FILE = "VMwareNamespaceCmd.exe";
-#else
-       const string CPersistenceNamespaceDb::_NAMESPACE_DB_CMD_FILE = "vmware-namespace-cmd";
-#endif
-
-const string CPersistenceNamespaceDb::_NAMESPACE = "com.vmware.caf.guest.rw";
 
 CPersistenceNamespaceDb::CPersistenceNamespaceDb() :
        _isInitialized(false),
        _isReady(false),
        CAF_CM_INIT_LOG("CPersistenceNamespaceDb") {
        CAF_CM_INIT_THREADSAFE;
+       _nsdbNamespace = "com.vmware.caf.guest.rw";
 }
 
 CPersistenceNamespaceDb::~CPersistenceNamespaceDb() {
@@ -57,30 +49,31 @@ SmartPtrCPersistenceDoc CPersistenceNamespaceDb::getUpdated(
        SmartPtrCPersistenceDoc rc;
        if (isReady()) {
                //If nothing has been updated, skip all of the unneeded work
-               string updates = getValue("updates");
+               const std::string updates = getValue("updates");
                if (!updates.empty()) {
-                       string version = getValue("version");
+                       const std::string version = getValue("version");
 
                        //EP Doc
-                       string epLocalId = getValue("ep.local_id");
-                       string epPrivateKey = getValue("ep.private_key");
-                       string epCert = getValue("ep.cert");
+                       const std::string epLocalId = getValue("ep.local_id");
+                       const std::string epPrivateKey = getValue("ep.private_key");
+                       const std::string epCert = getValue("ep.cert");
+
                        SmartPtrCLocalSecurityDoc endpoint;
                        endpoint.CreateInstance();
                        endpoint->initialize(epLocalId, epPrivateKey, epCert);
 
                        //App collection
                        std::deque<SmartPtrCRemoteSecurityDoc> applicationCollectionInner;
-                       string applications = getValue("applications");
+                       const std::string applications = getValue("applications");
                        Cdeqstr appList = CStringUtils::split(applications, ',');
                        for (Cdeqstr::iterator appIt = appList.begin(); appIt != appList.end(); appIt++) {
-                               string appKey = "app." + *appIt;
-                               string appId = getValue(appKey + ".remote_id");
-                               string appProtocolName = getValue(appKey + ".protocol_name");
-                               string appCmsCipher = getValue(appKey + ".cms.cipher");
+                               const std::string appKey = "app." + *appIt;
+                               const std::string appId = getValue(appKey + ".remote_id");
+                               const std::string appProtocolName = getValue(appKey + ".protocol_name");
+                               const std::string appCmsCipher = getValue(appKey + ".cms.cipher");
 
                                std::deque<std::string> cmsCertCollectionInner;
-                               string appCmsCertChain = getValue(appKey + ".cms.cert_chain");
+                               const std::string appCmsCertChain = getValue(appKey + ".cms.cert_chain");
                                Cdeqstr appCertList = CStringUtils::split(appCmsCertChain, ',');
                                for (Cdeqstr::iterator appCertIt = appCertList.begin(); appCertIt != appCertList.end(); appCertIt++) {
                                        cmsCertCollectionInner.push_back(*appCertIt);
@@ -90,10 +83,11 @@ SmartPtrCPersistenceDoc CPersistenceNamespaceDb::getUpdated(
                                cmsCertCollection.CreateInstance();
                                cmsCertCollection->initialize(cmsCertCollectionInner);
 
-                               string cmsCert = getValue(appKey + ".cms.cert");
+                               const std::string cmsCert = getValue(appKey + ".cms.cert");
                                SmartPtrCRemoteSecurityDoc application;
                                application.CreateInstance();
-                               application->initialize(appId, appProtocolName, cmsCert, appCmsCipher, cmsCertCollection);
+                               application->initialize(appId, appProtocolName, cmsCert, appCmsCipher,
+                                               cmsCertCollection);
 
                                applicationCollectionInner.push_back(application);
                        }
@@ -102,21 +96,21 @@ SmartPtrCPersistenceDoc CPersistenceNamespaceDb::getUpdated(
                        applicationCollection.CreateInstance();
                        applicationCollection->initialize(applicationCollectionInner);
 
-                       string protocols = getValue("protocols");
+                       const std::string protocols = getValue("protocols");
                        Cdeqstr protocolList = CStringUtils::split(protocols, ',');
                        std::deque<SmartPtrCPersistenceProtocolDoc> persistenceProtocolCollectionInner;
                        for (Cdeqstr::iterator protocolIt = protocolList.begin(); protocolIt != protocolList.end(); protocolIt++) {
-                               string protocolKey = "protocol." + *protocolIt;
+                               const std::string protocolKey = "protocol." + *protocolIt;
                                //Protoccol Doc
                                std::deque<std::string> tlsCertCollectionInner;
-                               string tlsCertChain = getValue(protocolKey + ".tls.cert.chain");
+                               const std::string tlsCertChain = getValue(protocolKey + ".tls.cert.chain");
                                Cdeqstr tlsCertList = CStringUtils::split(tlsCertChain, ',');
                                for (Cdeqstr::iterator tlsCertIt = tlsCertList.begin(); tlsCertIt != tlsCertList.end(); tlsCertIt++) {
                                        tlsCertCollectionInner.push_back(*tlsCertIt);
                                }
 
                                Cdeqstr tlsCipherCollection;
-                               string tlsCiphers = getValue(protocolKey + ".tls.ciphers");
+                               const std::string tlsCiphers = getValue(protocolKey + ".tls.ciphers");
                                Cdeqstr tlsCipherList = CStringUtils::split(tlsCiphers, ',');
                                for (Cdeqstr::iterator tlsCipherIt = tlsCipherList.begin(); tlsCipherIt != tlsCipherList.end(); tlsCipherIt++) {
                                        tlsCipherCollection.push_back(*tlsCipherIt);
@@ -127,13 +121,18 @@ SmartPtrCPersistenceDoc CPersistenceNamespaceDb::getUpdated(
                                tlsCertCollection->initialize(tlsCertCollectionInner);
 
                                //For now, we only support one broker.
-                               string protocolName = getValue(protocolKey + ".protocol_name");
-                               string uri = getValue(protocolKey + ".uri");
-                               string tlsCert = getValue(protocolKey + ".tls.cert");
-                               string tlsProtocol = getValue(protocolKey + ".tls.protocol");
+                               const std::string protocolName = getValue(protocolKey + ".protocol_name");
+                               const std::string uri = getValue(protocolKey + ".uri");
+                               const std::string uriAmqp = getValue(protocolKey + ".uri.amqp");
+                               const std::string uriTunnel = getValue(protocolKey + ".uri.tunnel");
+                               const std::string tlsCert = getValue(protocolKey + ".tls.cert");
+                               const std::string tlsProtocol = getValue(protocolKey + ".tls.protocol");
+
                                SmartPtrCPersistenceProtocolDoc persistenceProtocol;
                                persistenceProtocol.CreateInstance();
-                               persistenceProtocol->initialize(protocolName, uri, tlsCert, tlsProtocol, tlsCipherCollection, tlsCertCollection);
+                               persistenceProtocol->initialize(
+                                               protocolName, uri, uriAmqp, uriTunnel, tlsCert, tlsProtocol,
+                                               tlsCipherCollection, tlsCertCollection);
 
                                persistenceProtocolCollectionInner.push_back(persistenceProtocol);
                        }
@@ -172,14 +171,17 @@ void CPersistenceNamespaceDb::update(
 
                        //Update RemoteSecurity info
                        if (!persistenceCur->getRemoteSecurityCollection().IsNull()){
-                               deque<SmartPtrCRemoteSecurityDoc> applications = persistenceCur->getRemoteSecurityCollection()->getRemoteSecurity();
-                               for (deque<SmartPtrCRemoteSecurityDoc>::iterator appIt=applications.begin(); appIt != applications.end(); appIt++) {
-                                       string appKey = "app." + (*appIt)->getRemoteId();
+                               std::deque<SmartPtrCRemoteSecurityDoc> applications =
+                                               persistenceCur->getRemoteSecurityCollection()->getRemoteSecurity();
+                               for (std::deque<SmartPtrCRemoteSecurityDoc>::iterator appIt = applications.begin(); appIt != applications.end(); appIt++) {
+                                       const std::string appKey = "app." + (*appIt)->getRemoteId();
+
                                        setValue(appKey + ".remote_id", (*appIt)->getRemoteId());
                                        setValue(appKey + ".cms.cert", (*appIt)->getCmsCert());
                                        setValue(appKey + ".cms.cipher", (*appIt)->getCmsCipherName());
                                        setValue(appKey + ".protocol_name", (*appIt)->getProtocolName());
-                                       string cmsCertChain;
+
+                                       std::string cmsCertChain;
                                        if (! (*appIt)->getCmsCertCollection().IsNull()) {
                                                Cdeqstr cmsCertList = (*appIt)->getCmsCertCollection()->getCert();
                                                for (Cdeqstr::iterator cmsCertIt=cmsCertList.begin(); cmsCertIt != cmsCertList.end(); cmsCertIt++) {
@@ -188,6 +190,7 @@ void CPersistenceNamespaceDb::update(
                                                        }
                                                        cmsCertChain += *cmsCertIt;
                                                }
+
                                                setValue(appKey + ".cms.cert_chain", cmsCertChain);
                                        }
                                }
@@ -198,16 +201,18 @@ void CPersistenceNamespaceDb::update(
                                //For now, we only support one broker.
                                CAF_CM_ASSERT(persistenceCur->getPersistenceProtocolCollection()->getPersistenceProtocol().size() <= 1);
 
-                               deque<SmartPtrCPersistenceProtocolDoc> brokerList = persistenceCur->getPersistenceProtocolCollection()->getPersistenceProtocol();
-                               for (deque<SmartPtrCPersistenceProtocolDoc>::iterator protIt=brokerList.begin(); protIt != brokerList.end(); protIt++) {
-                                       string protocolKey = "protocol." + (*protIt)->getProtocolName();
+                               std::deque<SmartPtrCPersistenceProtocolDoc> brokerList = persistenceCur->getPersistenceProtocolCollection()->getPersistenceProtocol();
+                               for (std::deque<SmartPtrCPersistenceProtocolDoc>::iterator protIt=brokerList.begin(); protIt != brokerList.end(); protIt++) {
+                                       const std::string protocolKey = "protocol." + (*protIt)->getProtocolName();
                                        setValue(protocolKey + ".protocol_name", (*protIt)->getProtocolName());
                                        setValue(protocolKey + ".uri", (*protIt)->getUri());
+                                       setValue(protocolKey + ".uri.amqp", (*protIt)->getUriAmqp());
+                                       setValue(protocolKey + ".uri.tunnel", (*protIt)->getUriTunnel());
                                        setValue(protocolKey + ".tls.cert", (*protIt)->getTlsCert());
                                        setValue(protocolKey + ".tls.protocol", (*protIt)->getTlsProtocol());
 
                                        Cdeqstr tlsCipherList = (*protIt)->getTlsCipherCollection();
-                                       string tlsCiphers;
+                                       std::string tlsCiphers;
                                        for (Cdeqstr::iterator tlsCipherIt=tlsCipherList.begin(); tlsCipherIt != tlsCipherList.end(); tlsCipherIt++) {
                                                if (!tlsCiphers.empty()) {
                                                        tlsCiphers += ",";
@@ -218,7 +223,7 @@ void CPersistenceNamespaceDb::update(
 
                                        if (! (*protIt)->getTlsCertCollection().IsNull()) {
                                                Cdeqstr tlsCertList = (*protIt)->getTlsCertCollection()->getCert();
-                                               string tlsCerts;
+                                               std::string tlsCerts;
                                                for (Cdeqstr::iterator tlsCertIt=tlsCertList.begin(); tlsCertIt != tlsCertList.end(); tlsCertIt++) {
                                                        if (!tlsCerts.empty()) {
                                                                tlsCerts += ",";
@@ -261,9 +266,9 @@ void CPersistenceNamespaceDb::remove(
 
                        //Remove RemoteSecurity info
                        if (!persistenceCur->getRemoteSecurityCollection().IsNull()){
-                               deque<SmartPtrCRemoteSecurityDoc> applications = persistenceCur->getRemoteSecurityCollection()->getRemoteSecurity();
-                               for (deque<SmartPtrCRemoteSecurityDoc>::iterator it=applications.begin(); it != applications.end(); it++) {
-                                       string appKey = "app." + (*it)->getRemoteId();
+                               std::deque<SmartPtrCRemoteSecurityDoc> applications = persistenceCur->getRemoteSecurityCollection()->getRemoteSecurity();
+                               for (std::deque<SmartPtrCRemoteSecurityDoc>::iterator it=applications.begin(); it != applications.end(); it++) {
+                                       std::string appKey = "app." + (*it)->getRemoteId();
                                        if (!(*it)->getProtocolName().empty()) {
                                                removeKey(appKey + ".protocol_name");
                                        }
@@ -284,12 +289,18 @@ void CPersistenceNamespaceDb::remove(
                                //For now, we only support one broker.
                                CAF_CM_ASSERT(persistenceCur->getPersistenceProtocolCollection()->getPersistenceProtocol().size() <= 1);
 
-                               deque<SmartPtrCPersistenceProtocolDoc> brokerList = persistenceCur->getPersistenceProtocolCollection()->getPersistenceProtocol();
-                               for (deque<SmartPtrCPersistenceProtocolDoc>::iterator it=brokerList.begin(); it != brokerList.end(); it++) {
-                                       string protocolKey = "protocol." + (*it)->getProtocolName();
+                               std::deque<SmartPtrCPersistenceProtocolDoc> brokerList = persistenceCur->getPersistenceProtocolCollection()->getPersistenceProtocol();
+                               for (std::deque<SmartPtrCPersistenceProtocolDoc>::iterator it=brokerList.begin(); it != brokerList.end(); it++) {
+                                       std::string protocolKey = "protocol." + (*it)->getProtocolName();
                                        if (!(*it)->getUri().empty()) {
                                                removeKey(protocolKey + "uri");
                                        }
+                                       if (!(*it)->getUriAmqp().empty()) {
+                                               removeKey(protocolKey + "uri.amqp");
+                                       }
+                                       if (!(*it)->getUriTunnel().empty()) {
+                                               removeKey(protocolKey + "uri.tunnel");
+                                       }
                                        if (!(*it)->getTlsCert().empty()) {
                                                removeKey(protocolKey + "tls.cert");
                                        }
@@ -312,38 +323,41 @@ void CPersistenceNamespaceDb::remove(
        }
 }
 
-string CPersistenceNamespaceDb::getCmdPath() {
-//     CAF_CM_STATIC_FUNC("CPersistenceNamespaceDb", "getCmdPath");
-//     "/usr/sbin/vmware-namespace-cmd";
-       string cmdPath = "/usr/sbin";
+void CPersistenceNamespaceDb::setCmd() {
+       CAF_CM_FUNCNAME("setCmd");
+
+       std::string nsdbCmdDir;
+       std::string nsdbCmdFile;
 #ifdef WIN32
-//            "C:/Program Files/VMware/VMware Tools/VMwareNamespaceCmd.exe";
-//  bin_dir=C:/Program Files/VMware/VMware Tools/VMware CAF/pme//bin
-       cmdPath = AppConfigUtils::getRequiredString("globals", "bin_dir");
+       //  "C:/Program Files/VMware/VMware Tools/VMwareNamespaceCmd.exe";
+       //  bin_dir=C:/Program Files/VMware/VMware Tools/VMware CAF/pme//bin
+       nsdbCmdDir = AppConfigUtils::getRequiredString("globals", "bin_dir");
+
        //Back up two levels
-       cmdPath = FileSystemUtils::getDirname(cmdPath);
-       cmdPath = FileSystemUtils::getDirname(cmdPath); 
+       nsdbCmdDir = FileSystemUtils::getDirname(nsdbCmdDir);
+       nsdbCmdDir = FileSystemUtils::getDirname(nsdbCmdDir);
+
+       nsdbCmdFile = "VMwareNamespaceCmd.exe";
+#else
+       nsdbCmdDir = "/usr/sbin";
+       nsdbCmdFile = "vmware-namespace-cmd";
 #endif
-       return cmdPath;
-}
 
-void CPersistenceNamespaceDb::setCmd() {
-       CAF_CM_FUNCNAME("setCmd");
-       _namespaceDbCmd = FileSystemUtils::buildPath(getCmdPath(), _NAMESPACE_DB_CMD_FILE);
-       CAF_CM_LOG_DEBUG_VA1("_namespaceDbCmd: %s", _namespaceDbCmd.c_str());
-       if (!FileSystemUtils::doesFileExist(_namespaceDbCmd)) {
+       _nsdbCmdPath = FileSystemUtils::buildPath(nsdbCmdDir, nsdbCmdFile);
+       CAF_CM_LOG_DEBUG_VA1("_nsdbCmdPath: %s", _nsdbCmdPath.c_str());
+       if (!FileSystemUtils::doesFileExist(_nsdbCmdPath)) {
                CAF_CM_EXCEPTIONEX_VA1(FileNotFoundException, ERROR_FILE_NOT_FOUND,
-                               "Namespace DB command not found - %s", _namespaceDbCmd.c_str());
+                               "Namespace DB command not found - %s", _nsdbCmdPath.c_str());
        }
 }
 
-string CPersistenceNamespaceDb::getValue(const std::string& key) {
+std::string CPersistenceNamespaceDb::getValue(const std::string& key) {
        CAF_CM_FUNCNAME("getValue");
        CAF_CM_VALIDATE_STRING(key);
 
-       string value;
-       string stdoutContent;
-       string stderrContent;
+       std::string value;
+       std::string stdoutContent;
+       std::string stderrContent;
        try {
                value = getValueRaw(key, stdoutContent, stderrContent);
        }
@@ -358,7 +372,9 @@ string CPersistenceNamespaceDb::getValue(const std::string& key) {
        return value;
 }
        
-void CPersistenceNamespaceDb::setValue(const std::string& key, const std::string& value) {
+void CPersistenceNamespaceDb::setValue(
+               const std::string& key,
+               const std::string& value) {
        CAF_CM_FUNCNAME("setValue");
        CAF_CM_VALIDATE_STRING(key);
 
@@ -366,10 +382,10 @@ void CPersistenceNamespaceDb::setValue(const std::string& key, const std::string
                return;
        }
 
-       string stdoutContent;
-       string stderrContent;
+       std::string stdoutContent;
+       std::string stderrContent;
        Cdeqstr argv;
-       string tmpFile;
+       std::string tmpFile;
 
        try {
                //TODO: generate hash of value
@@ -377,9 +393,9 @@ void CPersistenceNamespaceDb::setValue(const std::string& key, const std::string
 
                tmpFile = FileSystemUtils::saveTempTextFile("caf_nsdb_XXXXXX", value);
                CAF_CM_LOG_DEBUG_VA2("Setting %s to %s", key.c_str(), value.c_str());
-               argv.push_back(_namespaceDbCmd);
+               argv.push_back(_nsdbCmdPath);
                argv.push_back("set-key");
-               argv.push_back(_NAMESPACE);
+               argv.push_back(_nsdbNamespace);
                argv.push_back("-k");
                argv.push_back(key);
                argv.push_back("-f");
@@ -387,7 +403,7 @@ void CPersistenceNamespaceDb::setValue(const std::string& key, const std::string
                                
                ProcessUtils::runSync(argv, stdoutContent, stderrContent);
                //Add to key+hash _cache
-               //TODO: generate a hash of the value string
+               //TODO: generate a hash of the value std::string
                _cache[key] = value; //As a temporary hack use the entire value as the "hash"
        }
        catch(ProcessFailedException* ex){
@@ -407,14 +423,14 @@ void CPersistenceNamespaceDb::removeKey(const std::string& key) {
        CAF_CM_FUNCNAME("removeKey");   
        CAF_CM_VALIDATE_STRING(key);
 
-       string stdoutContent;
-       string stderrContent;
+       std::string stdoutContent;
+       std::string stderrContent;
        Cdeqstr argv;
 
        try {
-               argv.push_back(_namespaceDbCmd);
+               argv.push_back(_nsdbCmdPath);
                argv.push_back("delete-key");
-               argv.push_back(_NAMESPACE);
+               argv.push_back(_nsdbNamespace);
                argv.push_back("-k");
                argv.push_back(key);
 
@@ -441,8 +457,8 @@ bool CPersistenceNamespaceDb::isReady() {
 
        bool rc = true;
        if (! _isReady) {
-               string stdoutContent;
-               string stderrContent;
+               std::string stdoutContent;
+               std::string stderrContent;
                try {
                        (void) getValueRaw("updates", stdoutContent, stderrContent);
                        _isReady = true;
@@ -466,22 +482,22 @@ bool CPersistenceNamespaceDb::isReady() {
        return rc;
 }
 
-string CPersistenceNamespaceDb::getValueRaw(
+std::string CPersistenceNamespaceDb::getValueRaw(
                const std::string& key,
-               string& stdoutContent,
-               string& stderrContent) {
+               std::string& stdoutContent,
+               std::string& stderrContent) {
        CAF_CM_FUNCNAME_VALIDATE("getValueRaw");
        CAF_CM_VALIDATE_STRING(key);
 
        Cdeqstr argv;
-       argv.push_back(_namespaceDbCmd);
+       argv.push_back(_nsdbCmdPath);
        argv.push_back("get-value");
-       argv.push_back(_NAMESPACE);
+       argv.push_back(_nsdbNamespace);
        argv.push_back("-k");
        argv.push_back(key);
 
        ProcessUtils::runSync(argv, stdoutContent, stderrContent);
-       string value = stdoutContent;
+       std::string value = stdoutContent;
 
        //strip spaces
        value = CStringUtils::trim(value);
@@ -494,7 +510,7 @@ string CPersistenceNamespaceDb::getValueRaw(
                        value.erase(value.length()-1,1);
        }
        //TODO: parse hash from nsdb value
-       string hash = value; //As a temporary hack, use the entire value as the "hash"
+       std::string hash = value; //As a temporary hack, use the entire value as the "hash"
        //if hash has not changed, return empty
        if (_cache[key] == hash) {
                CAF_CM_LOG_DEBUG_VA1("Value for %s has not changed", key.c_str());
index 0228fdb1d3245ad78aee2745557ff8b271fb04fc..f650297a8caa7ad5fcf48e606a1beec0eb676f54 100644 (file)
@@ -47,12 +47,19 @@ public: // IPersistence
                        const SmartPtrCPersistenceDoc& persistence);
                        
 private:
-       static std::string getCmdPath();
        void setCmd();
-       std::string getValue(const std::string& key);
-       void setValue(const std::string& key, const std::string& value);
+
+       std::string getValue(
+                       const std::string& key);
+
+       void setValue(
+                       const std::string& key,
+                       const std::string& value);
+
        void removeKey(const std::string& key);
+
        bool isReady();
+
        std::string getValueRaw(
                        const std::string& key,
                        std::string& stdoutContent,
@@ -61,10 +68,11 @@ private:
 private:
        bool _isInitialized;
        bool _isReady;
-       static const std::string _NAMESPACE_DB_CMD_FILE;
-       static const std::string _NAMESPACE;
-       std::string _namespaceDbCmd;
+
+       std::string _nsdbCmdPath;
+       std::string _nsdbNamespace;
        Cmapstrstr _cache;
+
        SmartPtrCPersistenceDoc _persistenceUpdate;
        SmartPtrCPersistenceDoc _persistenceRemove;
 
index 04a0bd4e7feeed34306218c3a4cd566ed97cf8ec..e1474d1d73bc7b5b3ad516d731f3500a1df24a0f 100644 (file)
@@ -128,6 +128,7 @@ SmartPtrIPersistence CPersistenceOutboundChannelAdapterInstance::createPersisten
                CAF_CM_LOG_WARN_VA2("initialize failed - ref: %s, msg: %s",
                                removeRefStr.c_str(), (CAF_CM_EXCEPTION_GET_FULLMSG).c_str());
                rc = SmartPtrIPersistence();
+               CAF_CM_CLEAREXCEPTION;
        }
 
        return rc;
index 50f6cf33e57f51f0873a6bdf05ca4c5d4993bae2..d0abbfa2a6b6359e77d087dc2ae1a5d8c93680f2 100644 (file)
@@ -165,10 +165,7 @@ void CProviderCollectSchemaExecutor::setupSchemaCacheDir(
        }
 
        FileSystemUtils::createDirectory(providerSchemaCacheDir);
-
-       if (AppConfigUtils::getRequiredBoolean("managementAgent", "remap_logging_location")) {
-               loggingSetter->initialize(providerSchemaCacheDir);
-       }
+       loggingSetter->initialize(providerSchemaCacheDir);
 }
 
 void CProviderCollectSchemaExecutor::runProvider(
index 7f90b25bf3c6dd25cfe482419ee82cada5b879b1..2e937299ed697f758b020d0a186d3b7fd9b3ca7e 100644 (file)
@@ -15,7 +15,7 @@ CProviderExecutorRequestHandler::CProviderExecutorRequestHandler() :
                _isInitialized(false),
                _isCancelled(false),
                CAF_CM_INIT_LOG("CProviderExecutorRequestHandler") {
-       _taskExecutor = NULL;
+       CAF_CM_INIT_THREADSAFE;
 }
 
 CProviderExecutorRequestHandler::~CProviderExecutorRequestHandler() {
@@ -26,7 +26,7 @@ void CProviderExecutorRequestHandler::initialize(const std::string& providerUri,
                const SmartPtrITransformer endImpersonationTransformer,
                const SmartPtrIErrorHandler errorHandler) {
        CAF_CM_FUNCNAME("initialize");
-
+       CAF_CM_LOCK_UNLOCK;
        CAF_CM_PRECOND_ISNOTINITIALIZED(_isInitialized);
        CAF_CM_VALIDATE_STRING(providerUri);
 
@@ -49,11 +49,6 @@ void CProviderExecutorRequestHandler::initialize(const std::string& providerUri,
                                "Provider path not found - %s", _providerPath.c_str());
        }
 
-       SmartPtrCAutoMutex mutex;
-       mutex.CreateInstance();
-       mutex->initialize();
-       _mutex = mutex;
-
        _beginImpersonationTransformer = beginImpersonationTransformer;
        _endImpersonationTransformer = endImpersonationTransformer;
        _errorHandler = errorHandler;
@@ -61,52 +56,29 @@ void CProviderExecutorRequestHandler::initialize(const std::string& providerUri,
        _isInitialized = true;
 }
 
-void CProviderExecutorRequestHandler::handleRequest(const SmartPtrCProviderExecutorRequest request) {
+void CProviderExecutorRequestHandler::handleRequest(
+               const SmartPtrCProviderExecutorRequest request) {
        CAF_CM_FUNCNAME("handleRequest");
-
+       CAF_CM_LOCK_UNLOCK;
+       CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
        CAF_CM_VALIDATE_SMARTPTR(request);
+
        if (_providerUri.compare(request->getProviderUri()) != 0) {
                CAF_CM_EXCEPTIONEX_VA1(InvalidArgumentException, ERROR_INVALID_PARAMETER,
                                "Provider request not for current provider - %s", _providerUri.c_str());
        }
 
-       CAutoMutexLockUnlock lock(_mutex);
-       if (_isCancelled) {
-               CAF_CM_EXCEPTIONEX_VA1(IllegalStateException, ERROR_INVALID_STATE,
-                               "Provider canceled: %s", _providerUri.c_str());
-       }
-       _pendingRequests.push_back(request);
-
-       if (_taskExecutor == NULL) {
-               SmartPtrCSimpleAsyncTaskExecutor simpleAsyncTaskExecutor;
-               simpleAsyncTaskExecutor.CreateInstance();
-               simpleAsyncTaskExecutor->initialize(this, _errorHandler);
-               _taskExecutor = simpleAsyncTaskExecutor;
-               _taskExecutor->execute(0);
-       }
-}
-
-SmartPtrCProviderExecutorRequest CProviderExecutorRequestHandler::getNextPendingRequest() {
-       CAutoMutexLockUnlock lock(_mutex);
-
-       SmartPtrCProviderExecutorRequest request;
-       if (_isCancelled || _pendingRequests.empty()) {
-               _taskExecutor = NULL;
-               return request;
-       }
-       request = _pendingRequests.front();
-       _pendingRequests.pop_front();
-       return request;
+       executeRequestAsync(request);
 }
 
 void CProviderExecutorRequestHandler::run() {
        CAF_CM_FUNCNAME("run");
-
+       CAF_CM_LOCK_UNLOCK;
        CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
 
        SmartPtrIIntMessage message;
-       SmartPtrCProviderExecutorRequest request = getNextPendingRequest();
-       while (!request.IsNull()) {
+       const SmartPtrCProviderExecutorRequest request = getNextPendingRequest();
+       if (! request.IsNull()) {
                try {
                        processRequest(request);
                }
@@ -121,34 +93,41 @@ void CProviderExecutorRequestHandler::run() {
 
                        CAF_CM_CLEAREXCEPTION;
                }
-
-               request = getNextPendingRequest();
        }
+
        CAF_CM_LOG_DEBUG_VA0("Finished");
 }
 
 void CProviderExecutorRequestHandler::cancel() {
        CAF_CM_FUNCNAME_VALIDATE("cancel");
+       CAF_CM_LOCK_UNLOCK;
        CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
 
        CAF_CM_LOG_DEBUG_VA0("Canceling");
-
-       CAutoMutexLockUnlock lock(_mutex);
        _isCancelled = true;
 }
 
+SmartPtrCProviderExecutorRequest CProviderExecutorRequestHandler::getNextPendingRequest() {
+
+       SmartPtrCProviderExecutorRequest rc;
+       if (! _isCancelled && ! _pendingRequests.empty()) {
+               rc = _pendingRequests.front();
+               _pendingRequests.pop_front();
+       }
+
+       return rc;
+}
+
 void CProviderExecutorRequestHandler::processRequest(
                const SmartPtrCProviderExecutorRequest& request) const {
        CAF_CM_FUNCNAME_VALIDATE("processRequest");
-       CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
        CAF_CM_VALIDATE_SMARTPTR(request);
 
-       const std::string& outputDir = request->getOutputDirectory();
-       if (AppConfigUtils::getRequiredBoolean("managementAgent", "remap_logging_location")) {
-               SmartPtrCLoggingSetter loggingSetter;
-               loggingSetter.CreateInstance();
-               loggingSetter->initialize(outputDir);
-       }
+       const std::string outputDir = request->getOutputDirectory();
+
+       SmartPtrCLoggingSetter loggingSetter;
+       loggingSetter.CreateInstance();
+       loggingSetter->initialize(outputDir);
 
        SmartPtrIIntMessage message = request->getInternalRequest();
 
@@ -188,7 +167,10 @@ void CProviderExecutorRequestHandler::processRequest(
                }
        }
 
-       ProcessUtils::runSyncToFiles(argv, stdoutPath, stderrPath, priority);
+       {
+               CAF_CM_UNLOCK_LOCK;
+               ProcessUtils::runSyncToFiles(argv, stdoutPath, stderrPath, priority);
+       }
 
        // End impersonation
        if (!_endImpersonationTransformer.IsNull()) {
@@ -230,3 +212,35 @@ void CProviderExecutorRequestHandler::processRequest(
        FileSystemUtils::saveByteFile(filePath, payload->getPtr(), payload->getByteCount(),
                        FileSystemUtils::FILE_MODE_REPLACE, ".writing");
 }
+
+void CProviderExecutorRequestHandler::executeRequestAsync(
+               const SmartPtrCProviderExecutorRequest& request) {
+       CAF_CM_FUNCNAME_VALIDATE("executeRequestAsync");
+       CAF_CM_VALIDATE_SMARTPTR(request);
+
+       _pendingRequests.push_back(request);
+
+       _taskExecutors = removeFinishedTaskExecutors(_taskExecutors);
+
+       SmartPtrCSimpleAsyncTaskExecutor simpleAsyncTaskExecutor;
+       simpleAsyncTaskExecutor.CreateInstance();
+       simpleAsyncTaskExecutor->initialize(this, _errorHandler);
+       _taskExecutors.push_back(simpleAsyncTaskExecutor);
+       simpleAsyncTaskExecutor->execute(0);
+}
+
+std::deque<SmartPtrITaskExecutor> CProviderExecutorRequestHandler::removeFinishedTaskExecutors(
+               const std::deque<SmartPtrITaskExecutor> taskExecutors) const {
+
+       std::deque<SmartPtrITaskExecutor> taskExecutorsTmp;
+       for (TConstIterator<std::deque<SmartPtrITaskExecutor> > iter(taskExecutors);
+                       iter; iter++) {
+               const SmartPtrITaskExecutor taskExecutorIter = *iter;
+               if (! ((taskExecutorIter->getState() == ITaskExecutor::ETaskStateFinished)
+                               || (taskExecutorIter->getState() == ITaskExecutor::ETaskStateFailed))) {
+                       taskExecutorsTmp.push_back(taskExecutorIter);
+               }
+       }
+
+       return taskExecutorsTmp;
+}
index e73ee043cca8fe92bd4a4ec3db82982c8d8874f5..a6f9b14a72c1ec804ed6038d6b303193636216df 100644 (file)
@@ -31,14 +31,21 @@ public: // IRunnable
 
 private:
        SmartPtrCProviderExecutorRequest getNextPendingRequest();
+
        void processRequest(const SmartPtrCProviderExecutorRequest& request) const;
 
+       void executeRequestAsync(
+                       const SmartPtrCProviderExecutorRequest& request);
+
+       std::deque<SmartPtrITaskExecutor> removeFinishedTaskExecutors(
+                       const std::deque<SmartPtrITaskExecutor> taskExecutors) const;
+
 private:
        bool _isInitialized;
        bool _isCancelled;
        std::string _providerPath;
        std::string _providerUri;
-       SmartPtrITaskExecutor _taskExecutor;
+       std::deque<SmartPtrITaskExecutor> _taskExecutors;
        SmartPtrCAutoMutex _mutex;
        std::deque<SmartPtrCProviderExecutorRequest> _pendingRequests;
        SmartPtrITransformer _beginImpersonationTransformer;
@@ -48,6 +55,7 @@ private:
 private:
        CAF_CM_CREATE;
        CAF_CM_CREATE_LOG;
+       CAF_CM_CREATE_THREADSAFE;
        CAF_CM_DECLARE_NOCOPY(CProviderExecutorRequestHandler);
 };
 
index 26e0d3e640b65507eaf28fc0bc2a61060a1939b8..2102ac59ea0dbb8291c1d587a0f15f3bf3f6aad3 100644 (file)
@@ -12,7 +12,7 @@ thread_stack_size_kb=0
 schema_namespace_root=http://schemas.vmware.com/caf/schema
 schema_location_root=${input_dir}/schemas/caf
 
-use_single_logging=true
+remap_logging_location=false
 
 [communication_amqp]
 working_dir=${output_dir}/comm-wrk
index 0dad7b09e85eed3a074cbda1c435445f25170fe5..f86f1563497b63af7615440af987e0e5a92bb530 100644 (file)
@@ -14,7 +14,7 @@ thread_stack_size_kb=0
 schema_namespace_root=http://schemas.vmware.com/caf/schema
 schema_location_root=${input_dir}/schemas/caf
 
-use_single_logging=true
+remap_logging_location=false
 
 [security]
 cms_policy=CAF_Encrypted_And_Signed
@@ -23,7 +23,6 @@ cms_policy=CAF_Encrypted_And_Signed
 host_delay_sec=5
 host_integration_timeout_ms=5000
 use_impersonation=false
-remap_logging_location=true
 # Value used to specify the priority that provider sub-process are created at.
 # Valid values are:  NORMAL, LOW, IDLE.  Default value is NORMAL.
 provider_process_priority=NORMAL
index 2ec0726ae53f32fe20b56fc7d8869c2b3d1a5631..94858c318fec0dd70dd4a64d8324953b43847032 100644 (file)
@@ -10,7 +10,7 @@ thread_stack_size_kb=0
 schema_namespace_root=http://schemas.vmware.com/caf/schema
 schema_location_root=${input_dir}/schemas/caf
 
-use_single_logging=true
+remap_logging_location=false
 
 [providerHost]
 install_dir=${config_dir}/../install
index cd3044c1dd6f58cc8a1bc097300779b4e62e5284..c0d6b4532659341172f3cc351d6f2411fc356ee1 100644 (file)
@@ -27,8 +27,11 @@ function enableCaf() {
    validateNotEmpty "$password" "password"
 
    local uriFile="$CAF_INPUT_DIR/persistence/protocol/amqpBroker_default/uri.txt"
+   local uriAmqpFile="$CAF_INPUT_DIR/persistence/protocol/amqpBroker_default/uri_amqp.txt"
    sed -i "s/#amqpUsername#/${username}/g" "$uriFile"
    sed -i "s/#amqpPassword#/${password}/g" "$uriFile"
+   sed -i "s/#amqpUsername#/${username}/g" "$uriAmqpFile"
+   sed -i "s/#amqpPassword#/${password}/g" "$uriAmqpFile"
 }
 
 function setBroker() {
@@ -36,10 +39,13 @@ function setBroker() {
    validateNotEmpty "$brokerAddr" "brokerAddr"
 
    local uriFile="$CAF_INPUT_DIR/persistence/protocol/amqpBroker_default/uri.txt"
+   local uriAmqpFile="$CAF_INPUT_DIR/persistence/protocol/amqpBroker_default/uri_amqp.txt"
    sed -i "s/#brokerAddr#/$brokerAddr/g" "$uriFile"
+   sed -i "s/#brokerAddr#/$brokerAddr/g" "$uriAmqpFile"
 }
 
 function setListenerConfigured() {
+   mkdir -p "$CAF_INPUT_DIR/monitor"
    echo "Manual" > "$CAF_INPUT_DIR/monitor/listenerConfigured.txt"
 }
 
@@ -62,8 +68,8 @@ function prtHelp() {
    echo ""
    echo "  * checkTunnel                              Checks the AMQP Tunnel "
    echo "  * checkCerts                               Checks the certificates"
-   echo "  * checkCertsVerbose                        Checks the certificates"
-   echo "  * checkToolsInstall                        Checks the Tools install"
+   echo "  * prtCerts                                 Prints the certificates"
+   echo "  * checkVmwTools                            Checks VMware Tools"
    echo ""
    echo "  * validateXml                              Validates the XML files against the published schema"
    echo "  * validateInstall                          Validates that the files are in the right locations and have the right permissions"
@@ -90,57 +96,57 @@ function validateXml() {
 }
 
 function checkCerts() {
-   local certDir="$CAF_INPUT_DIR/certs"
+   local localDir="$CAF_INPUT_DIR/persistence/local"
+   local cacertFile="$CAF_INPUT_DIR/persistence/protocol/amqpBroker_default/tlsCertCollection/tlsCert0.pem"
 
-   pushd $certDir > /dev/null
+   prtHeader "Checking private key - $localDir/privateKey.pem"
+   openssl rsa -in "$localDir/privateKey.pem" -check -noout
 
-   prtHeader "Checking certs - $certDir"
+   prtHeader "Checking cert - $localDir/cert.pem"
+   openssl verify -check_ss_sig -x509_strict -CAfile "$cacertFile" "$localDir/cert.pem"
 
-   openssl rsa -in privateKey.pem -check -noout
-   openssl verify -check_ss_sig -x509_strict -CAfile cacert.pem publicKey.pem
-
-   local clientCertMd5=$(openssl x509 -noout -modulus -in publicKey.pem | openssl md5 | cut -d' ' -f2)
-   local clientKeyMd5=$(openssl rsa -noout -modulus -in privateKey.pem | openssl md5 | cut -d' ' -f2)
+   prtHeader "Validating that private key and cert match - $localDir/cert.pem"
+   local clientCertMd5=$(openssl x509 -noout -modulus -in "$localDir/cert.pem" | openssl md5 | cut -d' ' -f2)
+   local clientKeyMd5=$(openssl rsa -noout -modulus -in "$localDir/privateKey.pem" | openssl md5 | cut -d' ' -f2)
    if [ "$clientCertMd5" == "$clientKeyMd5" ]; then
       echo "Public and Private Key md5's match"
    else
       echo "*** Public and Private Key md5's do not match"
       exit 1
    fi
-
-   popd > /dev/null
 }
 
-function checkCertsVerbose() {
-   local certDir="$CAF_INPUT_DIR/certs"
-
-   pushd $certDir > /dev/null
+function prtCerts() {
+   local localDir="$CAF_INPUT_DIR/persistence/local"
+   local cacertFile="$CAF_INPUT_DIR/persistence/protocol/amqpBroker_default/tlsCertCollection/tlsCert0.pem"
 
-   prtHeader "Checking $certDir/cacert.pem"
-   openssl x509 -in cacert.pem -text -noout
+   prtHeader "Printing - $cacertFile"
+   openssl x509 -in "$cacertFile" -text -noout
 
-   prtHeader "Checking $certDir/publicKey.pem"
-   openssl x509 -in publicKey.pem -text -noout
-
-   prtHeader "Checking /etc/vmware-tools/GuestProxyData/server/cert.pem"
-   openssl x509 -in /etc/vmware-tools/GuestProxyData/server/cert.pem -text -noout
-
-   popd > /dev/null
+   prtHeader "Printing - $localDir/cert.pem"
+   openssl x509 -in "$localDir/cert.pem" -text -noout
 }
 
 function checkTunnel() {
-   local certDir="$CAF_INPUT_DIR/certs"
-
-   pushd $certDir > /dev/null
+   local localDir="$CAF_INPUT_DIR/persistence/local"
+   local cacertFile="$CAF_INPUT_DIR/persistence/protocol/amqpBroker_default/tlsCertCollection/tlsCert0.pem"
 
    prtHeader "Connecting to tunnel"
-   openssl s_client -connect localhost:6672 -key privateKey.pem -cert publicKey.pem -CAfile cacert.pem -verify 10
-
-   popd > /dev/null
+   openssl s_client -connect localhost:6672 -key "$localDir/privateKey.pem" -cert "$localDir/cert.pem" -CAfile "$cacertFile" -verify 10
 }
 
-function checkToolsInstall() {
-   systemctl status vmware-tools.service
+function checkVmwTools() {
+   local isToolboxCmd=$(which vmware-toolbox-cmd 2>/dev/null)
+   if [ "$isToolboxCmd" != "" ]; then
+      vmware-toolbox-cmd --version
+   else
+      echo "It doesn't appear as though VMware Tools is installed"
+   fi
+
+   local isSystemctl=$(which systemctl 2>/dev/null)
+   if [ "$isSystemctl" != "" ]; then
+      systemctl status vmware-tools.service
+   fi
 }
 
 function validateInstall() {
@@ -211,7 +217,6 @@ function checkFileExistsConfig() {
    checkFileExists "$CAF_CONFIG_DIR/ma-log4cpp_config"
    checkFileExists "$CAF_CONFIG_DIR/providerFx-appconfig"
    checkFileExists "$CAF_CONFIG_DIR/providerFx-log4cpp_config"
-   checkFileExists "$CAF_CONFIG_DIR/persistence-appconfig"
 }
 
 function checkFileExistsScripts() {
@@ -317,9 +322,11 @@ function clearCaches() {
       $CAF_OUTPUT_DIR/providerHost/* \
       $CAF_OUTPUT_DIR/responses/* \
       $CAF_OUTPUT_DIR/requests/* \
+      $CAF_OUTPUT_DIR/split-requests/* \
       $CAF_OUTPUT_DIR/request_state/* \
       $CAF_OUTPUT_DIR/events/* \
-      $CAF_OUTPUT_DIR/errorResponse.xml \
+      $CAF_OUTPUT_DIR/tmp/* \
+      $CAF_OUTPUT_DIR/att/* \
       $CAF_LOG_DIR/* \
       $CAF_BIN_DIR/*.log
 }
@@ -388,7 +395,6 @@ function checkFileExistsConfig() {
    checkFileExists "$CAF_CONFIG_DIR/CommAmqpListener-appconfig"
    checkFileExists "$CAF_CONFIG_DIR/providerFx-log4cpp_config"
    checkFileExists "$CAF_CONFIG_DIR/cafenv-appconfig"
-   checkFileExists "$CAF_CONFIG_DIR/persistence-appconfig"
 }
 
 function checkFileExistsScripts() {
@@ -482,14 +488,14 @@ case "$cmd" in
    "checkCerts")
       checkCerts "$certDir"
    ;;
-   "checkCertsVerbose")
-      checkCertsVerbose "$certDir"
+   "prtCerts")
+      prtCerts "$certDir"
    ;;
    "checkTunnel")
       checkTunnel "$certDir"
    ;;
-   "checkToolsInstall")
-      checkToolsInstall
+   "checkVmwTools")
+      checkVmwTools
    ;;
    "getAmqpQueueName")
       getAmqpQueueName
index 0a2f1e27772056800039a59dde87e30849e527eb..b0d175692771b1adaaa23a6552613e5280732f31 100644 (file)
@@ -104,11 +104,7 @@ outputDir="${D}/$baseOutputDir/$stdQuals/data/output"
 
 providersDir="$inputDir/providers"
 invokersDir="$inputDir/invokers"
-persistenceDir="$inputDir/persistence"
-protocolDir="$persistenceDir/protocol"
-localDir="$persistenceDir/local"
-amqpBrokerDir="$protocolDir/amqpBroker_default"
-tlsCertCollectionDir="$amqpBrokerDir/tlsCertCollection"
+amqpBrokerDir="$inputDir/persistence/protocol/amqpBroker_default"
 
 logDir="${D}/var/log/$stdQuals"
 
@@ -117,37 +113,9 @@ configDir="$baseEtcDir/config"
 installDir="$baseEtcDir/install"
 scriptDir="$baseEtcDir/scripts"
 
-#Ensure directories exist
-mkdir -p "$outputDir"
-mkdir -p "$persistenceDir"
-mkdir -p "$protocolDir"
 mkdir -p "$amqpBrokerDir"
-mkdir -p "$tlsCertCollectionDir"
-mkdir -p "$localDir"
-mkdir -p "$invokersDir"
-mkdir -p "$providersDir"
-mkdir -p "$logDir"
-
-if [ -f "/etc/vmware-tools/GuestProxyData/server/cert.pem" ]; then
-       cp -f "/etc/vmware-tools/GuestProxyData/server/cert.pem" "$tlsCertCollectionDir/cacert.pem"
-fi
-
-vcidPath="/etc/vmware-tools/GuestProxyData/VmVcUuid/vm.vc.uuid"
-if [ -f "$vcidPath" ]; then
-       reactiveRequestAmqpQueueId=$(cat "$vcidPath")-agentId1
-else
-       reactiveRequestAmqpQueueId=`uuidgen`
-fi
-
-tunnelPort=$(netstat -ldn | egrep ":6672 ")
-if [ -f "$vcidPath" -a "$tunnelPort" != "" ]; then
-       brokerUri="tunnel:agentId1:bogus@localhost:6672/${reactiveRequestAmqpQueueId}"
-else
-       brokerUri="amqp:#amqpUsername#:#amqpPassword#@${brokerAddr}:5672/${reactiveRequestAmqpQueueId}"
-fi
-
-echo -n "$brokerUri" > "$amqpBrokerDir/uri.txt"
-echo -n "$reactiveRequestAmqpQueueId" > "$localDir/localId.txt"
+echo -n "amqp:#amqpUsername#:#amqpPassword#@${brokerAddr}:5672/reactiveRequestAmqpQueueId" > "$amqpBrokerDir/uri_amqp.txt"
+echo -n "tunnel:agentId1:bogus@localhost:6672/reactiveRequestAmqpQueueId" > "$amqpBrokerDir/uri_tunnel.txt"
 
 #Substitute values into config files
 setupCafConfig '@installDir@' "$installDir" "$configDir"
index 61ecdbc07853b612239c47cb85befe216fc6ef41..9db49f7cd2105eba12d7ae0fa24c37d73f0ee6a7 100644 (file)
@@ -40,7 +40,7 @@ startCafProcess() {
                        $processPath -n
                ;;
                "valgrindMemChecks")
-                       G_SLICE=always-malloc G_DEBUG=gc-friendly  valgrind -v --tool=memcheck --leak-check=full --num-callers=40 --track-origins=yes --log-file=${processPath}-valgrind-memchecks.log $processPath -n
+                       G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind -v --tool=memcheck --leak-check=full --num-callers=40 --track-origins=yes --leak-resolution=med --track-fds=yes --log-file=${processPath}-valgrind-memchecks.log $processPath -n
                ;;
                "valgrindProfiling")
                        valgrind --tool=callgrind --log-file=${processPath}-valgrind-profiling.log $processPath -n
@@ -81,7 +81,7 @@ startVgAuthProcess() {
                        $processPath -d
                ;;
                "valgrindMemChecks")
-                       G_SLICE=always-malloc G_DEBUG=gc-friendly  valgrind -v --tool=memcheck --leak-check=full --num-callers=40 --log-file=${processPath}-valgrind.log $processPath -d
+                       G_SLICE=always-malloc G_DEBUG=gc-friendly  valgrind -v --tool=memcheck --leak-check=full --show-leak-kinds=all --num-callers=40 --log-file=${processPath}-valgrind.log $processPath -d
                ;;
                "valgrindProfiling")
                        valgrind --tool=callgrind $processPath -d