📄 providerregistrationmanager.cpp
字号:
Array<CIMInstance> instances; Array<Uint16> providerType; ReadLock lock(_registrationTableLock); // Retrieve required registration data from registration hash table // instead of repository. This significantly decrease the time required // for the cimprovider for (Table::Iterator i=_registrationTable->table.start(); i; i++) { instances = i.value()->getInstances(); for (Uint32 j = 0; j < instances.size(); j++) { String module; String provider; Array<Uint16> providerType; Uint32 pos1 = instances[j].findProperty(_PROPERTY_PROVIDERMODULENAME); Uint32 pos2 = instances[j].findProperty(_PROPERTY_PROVIDERNAME); Uint32 pos3 = instances[j].findProperty(_PROPERTY_PROVIDERTYPE); if (pos1 != PEG_NOT_FOUND && pos2 != PEG_NOT_FOUND && pos3 != PEG_NOT_FOUND) { // get provider module name instances[j].getProperty(pos1).getValue().get(module); // get provider name instances[j].getProperty(pos2).getValue().get(provider); // get provider type instances[j].getProperty(pos3).getValue().get(providerType); if (String::equalNoCase(module, moduleName) && String::equalNoCase(provider, providerName)) { if (Contains(providerType, _INDICATION_PROVIDER)) { PEG_METHOD_EXIT(); return true; } } } } } PEG_METHOD_EXIT(); return (false);}// Iterate registration table to get module instance, or// provider instance, or capability instance, or consumer// instanceCIMInstance ProviderRegistrationManager::getInstance( const CIMObjectPath & instanceReference, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList & propertyList){ PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderRegistrationManager::getInstance"); // get class name CIMName className = instanceReference.getClassName(); Array<CIMKeyBinding> keys = instanceReference.getKeyBindings(); ReadLock lock(_registrationTableLock); // // get provider module instance from the table // if (className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE)) { // get keys String _moduleName; for (Uint32 m=0; m < keys.size(); m++) { if(keys[m].getName().equal(_PROPERTY_PROVIDERMODULE_NAME)) { _moduleName = keys[m].getValue(); } } // Retrieve required registration data from registration hash table // instead of repository. This significantly decrease the time required // for the cimprovider for (Table::Iterator i=_registrationTable->table.start(); i; i++) { Array<CIMInstance> instances; instances = i.value()->getInstances(); for (Uint32 j = 0; j < instances.size(); j++) { String module; Uint32 pos = instances[j].findProperty( _PROPERTY_PROVIDERMODULE_NAME); if (pos != PEG_NOT_FOUND) { // get provider module name instances[j].getProperty(pos).getValue().get(module); if (String::equalNoCase(_moduleName, module)) { /** if the names of ProviderModule and Provider are the same, here we need to check whether we are actually returning the providerModule. see Bug #5940 */ if(instances[j].getClassName().equal(PEGASUS_CLASSNAME_PROVIDERMODULE)) { PEG_METHOD_EXIT(); return (instances[j]); } } } } } PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_FOUND, MessageLoaderParms(MODULE_NOT_FOUND_KEY, MODULE_NOT_FOUND)); } // // get provider instance from the table // else if (className.equal (PEGASUS_CLASSNAME_PROVIDER)) { // get keys String _moduleName; String _providerName; for (Uint32 m=0; m < keys.size(); m++) { if(keys[m].getName().equal(_PROPERTY_PROVIDERMODULENAME)) { _moduleName = keys[m].getValue(); } if(keys[m].getName().equal(_PROPERTY_PROVIDER_NAME)) { _providerName = keys[m].getValue(); } } for (Table::Iterator i=_registrationTable->table.start(); i; i++) { Array<CIMInstance> instances; instances = i.value()->getInstances(); for (Uint32 j = 0; j < instances.size(); j++) { String module; String provider; Uint32 pos1 = instances[j].findProperty( _PROPERTY_PROVIDERMODULENAME); Uint32 pos2 = instances[j].findProperty( _PROPERTY_PROVIDER_NAME); if (pos1 != PEG_NOT_FOUND && pos2 != PEG_NOT_FOUND) { // get provider module name instances[j].getProperty(pos1).getValue().get(module); // get provider name instances[j].getProperty(pos2).getValue().get(provider); if (String::equalNoCase(_moduleName, module) && String::equalNoCase( _providerName, provider)) { PEG_METHOD_EXIT(); return (instances[j]); } } } } PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_FOUND, MessageLoaderParms(PROVIDER_NOT_FOUND_KEY, PROVIDER_NOT_FOUND)); } // // get provider capabilty instance or consumer instance // from the table // else if (className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) || className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES)) { // get keys String _moduleName; String _providerName; String _capabilityID; for (Uint32 m=0; m < keys.size(); m++) { if(keys[m].getName().equal(_PROPERTY_PROVIDERMODULENAME)) { _moduleName = keys[m].getValue(); } if(keys[m].getName().equal(_PROPERTY_PROVIDERNAME)) { _providerName = keys[m].getValue(); } if(keys[m].getName().equal(_PROPERTY_CAPABILITIESID)) { _capabilityID = keys[m].getValue(); } } for (Table::Iterator i=_registrationTable->table.start(); i; i++) { Array<CIMInstance> instances; instances = i.value()->getInstances(); for (Uint32 j = 0; j < instances.size(); j++) { String module; String provider; String capabilityID; Uint32 pos1 = instances[j].findProperty( _PROPERTY_PROVIDERMODULENAME); Uint32 pos2 = instances[j].findProperty( _PROPERTY_PROVIDERNAME); Uint32 pos3 = instances[j].findProperty( _PROPERTY_CAPABILITIESID); if (pos1 != PEG_NOT_FOUND && pos2 != PEG_NOT_FOUND && pos3 != PEG_NOT_FOUND) { // get provider module name instances[j].getProperty(pos1).getValue().get(module); // get provider name instances[j].getProperty(pos2).getValue().get(provider); // get capabilityID instances[j].getProperty(pos3).getValue().get(capabilityID); if (String::equalNoCase(_moduleName, module) && String::equalNoCase( _providerName, provider) && String::equalNoCase(_capabilityID, capabilityID)) { PEG_METHOD_EXIT(); return (instances[j]); } } } } PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_FOUND, MessageLoaderParms(CAPABILITY_NOT_REGISTERED_KEY, CAPABILITY_NOT_REGISTERED)); } // Note: We should never be asked for an instance of any other class PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, className.getString());}// get all registered providersArray<CIMInstance> ProviderRegistrationManager::enumerateInstancesForClass( const CIMObjectPath & ref, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList & propertyList){ PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderRegistrationManager::enumerateInstancesForClass"); Array<CIMInstance> enumInstances; try { enumInstances = _repository->enumerateInstancesForClass( PEGASUS_NAMESPACENAME_INTEROP, ref.getClassName(), false, includeQualifiers, includeClassOrigin, propertyList); } catch (...) { PEG_METHOD_EXIT(); throw; } PEG_METHOD_EXIT(); return (enumInstances);}// get all registered provider namesArray<CIMObjectPath> ProviderRegistrationManager::enumerateInstanceNamesForClass( const CIMObjectPath & ref){ PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderRegistrationManager::enumerateInstanceNamesForClass"); Array<CIMObjectPath> enumInstanceNames; try { // get all instance names from repository enumInstanceNames = _repository->enumerateInstanceNamesForClass( PEGASUS_NAMESPACENAME_INTEROP, ref.getClassName()); } catch (...) { PEG_METHOD_EXIT(); throw; } PEG_METHOD_EXIT(); return (enumInstanceNames);}// register a providerCIMObjectPath ProviderRegistrationManager::createInstance( const CIMObjectPath & ref, const CIMInstance & instance){ WriteLock lock(_registrationTableLock); CIMObjectPath cimRef; try { cimRef = _createInstance(ref, instance, OP_CREATE); Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, "ProviderRegistrationManager::createInstance - Create instance object path: $0", cimRef.toString()); return (cimRef); } catch (const CIMException &) { throw; } catch (const Exception &) { throw; }}// Unregister a providervoid ProviderRegistrationManager::deleteInstance( const CIMObjectPath & instanceReference){ WriteLock lock(_registrationTableLock); try { _deleteInstance(instanceReference, OP_DELETE); Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, "ProviderRegistrationManager::deleteInstance - delete instance object path: $0", instanceReference.toString()); } catch (const CIMException &) { throw; } catch (const Exception &) { throw; }}// modify a registered providervoid ProviderRegistrationManager::modifyInstance( const CIMObjectPath & ref, const CIMInstance & cimInstance, const Boolean includeQualifiers, const Array<CIMName> & propertyList){ PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderRegistrationManager::modifyInstance"); WriteLock lock(_registrationTableLock); CIMObjectPath newInstanceRef("", CIMNamespaceName (), ref.getClassName(), ref.getKeyBindings());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -