⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 providerregistrationmanager.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 5 页
字号:
//%2006//////////////////////////////////////////////////////////////////////////// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation, The Open Group.// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; Symantec Corporation; The Open Group.//// Permission is hereby granted, free of charge, to any person obtaining a copy// of this software and associated documentation files (the "Software"), to// deal in the Software without restriction, including without limitation the// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or// sell copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions://// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.////==============================================================================////%/////////////////////////////////////////////////////////////////////////////#include "ProviderRegistrationManager.h"#include <Pegasus/Common/ArrayInternal.h>#include <Pegasus/Common/CIMDateTime.h>#include <Pegasus/Common/HashTable.h>#include <Pegasus/Common/Tracer.h>#include <Pegasus/Common/CIMMessage.h>#include <Pegasus/Common/XmlWriter.h>#include <Pegasus/Common/CIMProperty.h>#include <Pegasus/Common/Logger.h>#include <Pegasus/Common/Constants.h>#include <Pegasus/Common/PegasusVersion.h>#include <Pegasus/Common/OperationContextInternal.h>#include <Pegasus/Common/AutoPtr.h>#include <Pegasus/Common/AuditLogger.h>#include "ProviderRegistrationTable.h"#include <Pegasus/Repository/CIMRepository.h>// l10n#include <Pegasus/Common/MessageLoader.h>PEGASUS_NAMESPACE_BEGIN/**    ProviderRegistration table is used to keep track of provider registration    data.    This table contains following entries:    1) An entry consists of an instance of the PG_ProviderModule. The key is       generated by concatenating the provider module name of the provider       module instance and const string "Module".    2) An entry consists of an instance of the PG_Provider. The key is       generated by concatenating the provider module name of the provider       instance and provider name of the provider instance.    3) An entry consists of an instance of the PG_ConsumerCapabilities. The       key is generated by concatenating the indicationDestination name of       the consumerCapabilities instance and the provider type value.    4) An entry consists of an instance of the PG_ProviderCapabilities. If a       provider is an instance provider or an association provider, the key       is generated by concatenating the namespace name of the provider       capabilities instance, the className of the provider capabilities       instance, and the provider type value.       If a provider is a method provider, the key is generated by       concatenating the namespace name of the provider capabilities instance,       the className of the provider capabilities instance, the supported       method name of the provider capabilities instance, and the provider       type value.    5) An entry consists of an array of instances of the PG_ProviderCapabilities       if a provider is an indication provider. The key is generated by       concatenating the namespace name of the provider capabilities instance,       the className of the provider capabilities instance, and the provider       type value.    Entries are inserted into the table when a provider is registered or    when a provider is initialized.    Entries are removed from the table when a provider is unregistered or    registration data are modified.    The lookupInstanceProvider function, the lookupMethodProvider function,    the lookupAssociationProvider function, the getIndicationProviders    function, and the lookupIndicationConsumer function look up the provider    information in the table.    The isIndicationProvider function iterates through the table to determine    whether specified provider is an indication provider.    The getInstance function iterates through the table by using a specified    CIMObjectPath (ref) to retrieve an instance of PG_ProviderModule, or an    instance of PG_Provider, or an instance of PG_ProviderCapabilities, or an    instance of PG_ConsumerCapabilities.*/typedef HashTable<String,    ProviderRegistrationTable*, EqualFunc<String>,HashFunc<String> > Table;static Boolean supportWildCardNamespaceNames=false;struct RegistrationTable{    Table table;};Boolean containsCIMInstance (    const Array <CIMInstance> & instanceArray,    const CIMInstance & instance){    Uint32 size = instanceArray.size ();    for (Uint32 i = 0; i < size; i++)    {        if (instanceArray [i].identical (instance))        {            return true;        }    }    return false;}/**   Registered instance provider*/static const char INS_PROVIDER [] = "Instance";/**   Registered consumer provider*/static const char CON_PROVIDER [] = "Consumer";/**   Registered Association provider*/static const char ASSO_PROVIDER [] = "Association";/**   Registered Indication provider*/static const char IND_PROVIDER [] = "Indication";/**   Registered Method provider*/static const char INSTANCE_QUERY_PROVIDER [] = "InstanceQuery";/**   Registered Method provider*/static const char MET_PROVIDER [] = "Method";/**   Registered module*/static const char MODULE_KEY [] = "Module";static const char MODULE_NOT_FOUND [] = " Can not find the provider module.";static const char MODULE_NOT_FOUND_KEY [] = "Server.ProviderRegistrationManager.ProviderRegistrationManager.MODULE_NOT_FOUND";static const char PROVIDER_NOT_FOUND [] = " Can not find the provider.";static const char PROVIDER_NOT_FOUND_KEY [] = "Server.ProviderRegistrationManager.ProviderRegistrationManager.PROVIDER_NOT_FOUND";static const char CAPABILITY_NOT_REGISTERED [] = " Provider capability has not been registered yet.";static const char CAPABILITY_NOT_REGISTERED_KEY [] = "Server.ProviderRegistrationManager.ProviderRegistrationManager.CAPABILITY_NOT_REGISTERED";//L10N TODO DONEstatic const char CONSUMER_NOT_REGISTERED [] = " Consumer capability has not been registered yet.";static const char CONSUMER_NOT_REGISTERED_KEY [] = "Server.ProviderRegistrationManager.ProviderRegistrationManager.CONSUMER_CAPABILITY_NOT_YET_REGISTERED";static const char PROVIDER_CANNOT_BE_LOAD [] =" Can not initialize and load the provider.";static const char PROVIDER_CANNOT_BE_LOAD_KEY [] ="Server.ProviderRegistrationManager.ProviderRegistrationManager.PROVIDER_CANNOT_BE_LOAD";static const char MODULE_NAME_NOT_FOUND_KEY[] = "Server.ProviderRegistrationManager.ProviderRegistrationManager.MISSING_MODULENAME";static const char MODULE_NAME_NOT_FOUND[] = "Missing ProviderModuleName which is key in PG_ProviderCapabilities class.";static const char PROVIDER_NAME_NOT_FOUND_KEY[] = "Server.ProviderRegistrationManager.ProviderRegistrationManager.MISSING_PROVIDERNAME";static const char PROVIDER_NAME_NOT_FOUND[] = "Missing ProviderName which is key in PG_ProviderCapabilities class.";/**   Provider status*/static const Uint16 _PROVIDER_OK        = 2;static const Uint16 _PROVIDER_STOPPING   = 9;static const Uint16 _PROVIDER_STOPPED   = 10;/**   Module status*/static const Uint16 _MODULE_ERROR        = 6;ProviderRegistrationManager::ProviderRegistrationManager(CIMRepository* repository)    : _repository(repository){#ifdef PEGASUS_ENABLE_REMOTE_CMPI    supportWildCardNamespaceNames=true;#else    supportWildCardNamespaceNames=false;#endif    _registrationTable = new RegistrationTable;    WriteLock lock(_registrationTableLock);    //    // get all registered providers from repository and add them to the table    //    _initialRegistrationTable();}ProviderRegistrationManager::~ProviderRegistrationManager(void){    if (_registrationTable)    {        for (Table::Iterator i = _registrationTable->table.start(); i; i++)            delete i.value();        delete _registrationTable;    }}void ProviderRegistrationManager::initializeProviders(void){    PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,        "ProviderRegistrationManager::initializeProviders");// Note: The PG_Provider AutoStart property is not yet supported#if 0    Array<CIMInstance> instances;    ReadLock lock(_registrationTableLock);    try    {        for (Table::Iterator i=_registrationTable->table.start(); i; i++)        {            instances = i.value()->getInstances();            for (Uint32 j = 0; j < instances.size(); j++)            {                Uint32 pos = instances[j].findProperty(_PROPERTY_AUTOSTART);                if (pos != PEG_NOT_FOUND)                {                    Boolean autoStart;                    instances[j].getProperty(pos).getValue().get(autoStart);                    // if autoStart is true, send message to Provider                    // Manager Service to load and initialize provider                    if (autoStart)                    {                        Uint32 pos2 = instances[j].findProperty(                            _PROPERTY_PROVIDERMODULENAME);                        if (pos2 != PEG_NOT_FOUND)                        {                            // get provider module name                            String module;                            instances[j].getProperty(pos2).getValue().get(module);                            // Use provider module name to generate a key                            String _moduleKey = _generateKey(module, MODULE_KEY);                            // get provider module instance from the table                            ProviderRegistrationTable* _providerModule = 0;                            if (!_registrationTable->table.lookup(_moduleKey,                                _providerModule))                            {                                Logger::put_l (Logger::STANDARD_LOG,                                               System::CIMSERVER,                                               Logger::WARNING,                                               MODULE_NOT_FOUND_KEY,                                               MODULE_NOT_FOUND, module);                            }                            else                            {                                Array<CIMInstance> providerModuleInstances =                                    _providerModule->getInstances();                                _sendInitializeProviderMessage(                                    instances[j], providerModuleInstances[0]);                            }                        }                    }                }            }        }    }    catch(CIMException & e)    {        PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,            "CIMException: " + e.getMessage());    }    catch(Exception & e)    {        PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,            "Exception: " + e.getMessage());    }    catch(...)    {        PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,            "Exception: Unknown");    }#endif    PEG_METHOD_EXIT();}void ProviderRegistrationManager::initializeProviders(    const CIMInstance & providerModule){    PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,                     "ProviderRegistrationManager::initializeProviders");// Note: The PG_Provider AutoStart property is not yet supported#if 0    // get provider module name    String providerModuleName;    providerModule.getProperty(providerModule.findProperty        (_PROPERTY_PROVIDERMODULE_NAME)).getValue().get(providerModuleName);    Array<CIMInstance> instances;    ReadLock lock(_registrationTableLock);    try    {        for (Table::Iterator i=_registrationTable->table.start(); i; i++)        {            instances = i.value()->getInstances();            for (Uint32 j = 0; j < instances.size(); j++)            {                Uint32 pos = instances[j].findProperty(_PROPERTY_AUTOSTART);                if (pos != PEG_NOT_FOUND)                {                    // get provider module name                    String moduleName;                    instances[j].getProperty(instances[j].findProperty(                        _PROPERTY_PROVIDERMODULENAME)).getValue().get(moduleName);                    // if the moduleName is same as providerModuleName and                    // autoStart is true send message to Provider Manager Service                    // to load and initialize providers in the module                    if (String::equalNoCase(providerModuleName, moduleName))                    {                        Boolean autoStart;                        instances[j].getProperty(pos).getValue().get(autoStart);                        if (autoStart)                        {                            _sendInitializeProviderMessage(instances[j],                                providerModule);                        }                    }                }            }        }    }    catch(const CIMException & e)    {        PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,            "CIMException: " + e.getMessage());        PEG_METHOD_EXIT();        throw;    }    catch(const Exception & e)    {        PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,            "Exception: " + e.getMessage());        PEG_METHOD_EXIT();        throw;    }    catch(...)    {        PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,            "Exception: Unknown");        PEG_METHOD_EXIT();        throw;    }#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -