version 1.39, 2004/05/18 23:58:41
|
version 1.56, 2004/07/28 11:31:23
|
|
|
// Adrian Schuur, IBM (schuur@de.ibm.com) | // Adrian Schuur, IBM (schuur@de.ibm.com) |
// Amit K Arora (amita@in.ibm.com) for PEP-101 | // Amit K Arora (amita@in.ibm.com) for PEP-101 |
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) | // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
|
// Seema Gupta (gseema@in.ibm.com for PEP135) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
#include <Pegasus/Common/Tracer.h> | #include <Pegasus/Common/Tracer.h> |
#include <Pegasus/Common/Logger.h> | #include <Pegasus/Common/Logger.h> |
#include <Pegasus/Common/AutoPtr.h> | #include <Pegasus/Common/AutoPtr.h> |
|
#include <Pegasus/Common/Constants.h> |
| |
#include <Pegasus/Config/ConfigManager.h> | #include <Pegasus/Config/ConfigManager.h> |
| |
#include <Pegasus/ProviderManager2/BasicProviderManagerRouter.h> | #include <Pegasus/ProviderManager2/BasicProviderManagerRouter.h> |
|
#include <Pegasus/ProviderManager2/OOPProviderManagerRouter.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
static const Uint16 _MODULE_OK = 2; |
|
static const Uint16 _MODULE_STOPPING = 9; |
|
static const Uint16 _MODULE_STOPPED = 10; |
|
|
|
inline Boolean _isSupportedRequestType(const Message * message) | inline Boolean _isSupportedRequestType(const Message * message) |
{ | { |
// ATTN: needs implementation | // ATTN: needs implementation |
|
|
} | } |
| |
ProviderManagerService* ProviderManagerService::providerManagerService=NULL; | ProviderManagerService* ProviderManagerService::providerManagerService=NULL; |
CIMRepository* ProviderManagerService::_repository=NULL; |
|
Uint32 ProviderManagerService::_indicationServiceQueueId = PEG_NOT_FOUND; | Uint32 ProviderManagerService::_indicationServiceQueueId = PEG_NOT_FOUND; |
| |
ProviderManagerService::ProviderManagerService(void) | ProviderManagerService::ProviderManagerService(void) |
|
|
_repository=repository; | _repository=repository; |
| |
_providerRegistrationManager = providerRegistrationManager; | _providerRegistrationManager = providerRegistrationManager; |
|
|
|
_unloadIdleProvidersBusy = 0; |
|
|
|
// Determine whether Out-of-Process Provider support is enabled |
|
ConfigManager* configManager = ConfigManager::getInstance(); |
|
if (String::equal( |
|
configManager->getCurrentValue("enableProviderProcesses"), "true")) |
|
{ |
|
_providerManagerRouter = |
|
new OOPProviderManagerRouter(indicationCallback); |
|
} |
|
else |
|
{ |
_providerManagerRouter = | _providerManagerRouter = |
new BasicProviderManagerRouter(indicationCallback); | new BasicProviderManagerRouter(indicationCallback); |
} | } |
|
} |
| |
ProviderManagerService::~ProviderManagerService(void) | ProviderManagerService::~ProviderManagerService(void) |
{ | { |
|
|
return; | return; |
} | } |
| |
|
/* The following method shouldn't throw an exception as this runs on its own thread and the exceptions thrown by it |
|
don't go anywhere and get lost. |
|
*/ |
PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL | PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL |
ProviderManagerService::handleCimOperation(void * arg) throw() |
ProviderManagerService::handleCimOperation(void * arg) |
{ | { |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, | PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
"ProviderManagerService::handleCimOperation"); | "ProviderManagerService::handleCimOperation"); |
|
|
if (msg != 0) | if (msg != 0) |
{ | { |
AcceptLanguages* langs = | AcceptLanguages* langs = |
new AcceptLanguages(msg->acceptLanguages); |
new AcceptLanguages(((AcceptLanguageListContainer)msg->operationContext.get |
|
(AcceptLanguageListContainer::NAME)).getLanguages()); |
Thread::setLanguages(langs); | Thread::setLanguages(langs); |
} | } |
else | else |
|
|
Message * response = 0; | Message * response = 0; |
| |
if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) || | if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) || |
(request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE)) |
(dynamic_cast<CIMIndicationRequestMessage*>(request) != 0) || |
|
(request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) || |
|
(request->getType() == CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE)) |
|
{ |
|
// Handle CIMOperationRequestMessage, CIMExportIndicationRequestMessage, |
|
// CIMIndicationRequestMessage, and CIMInitializeProviderRequestMessage. |
|
// (These should be blocked when the provider module is disabled.) |
|
|
|
// |
|
// Get the provider module instance to check for a disabled module |
|
// |
|
CIMInstance providerModule; |
|
|
|
if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) |
{ | { |
// Handle CIMOperationRequestMessage and |
// Get a ProviderIdContainer for ExportIndicationRequestMessage. |
// CIMExportIndicationRequestMessage |
// Note: This can be removed when the CIMExportRequestDispatcher |
|
// is updated to add the ProviderIdContainer to the message. |
|
CIMInstance provider; |
|
const CIMExportIndicationRequestMessage* expRequest = |
|
dynamic_cast<const CIMExportIndicationRequestMessage*>(request); |
|
_providerRegistrationManager->lookupIndicationConsumer( |
|
expRequest->destinationPath, provider, providerModule); |
|
request->operationContext.insert( |
|
ProviderIdContainer(providerModule, provider)); |
|
} |
|
else |
|
{ |
|
// The provider ID container is added to the OperationContext |
|
// by the CIMOperationRequestDispatcher for all CIM operation |
|
// requests to providers, so it does not need to be added again. |
|
// CIMInitializeProviderRequestMessage also has a provider ID |
|
// container. |
|
ProviderIdContainer pidc = |
|
request->operationContext.get(ProviderIdContainer::NAME); |
|
providerModule = pidc.getModule(); |
|
} |
| |
// Add provider information to OperationContext for the ProviderManager |
// |
ProviderIdContainer pidc = _getProviderIdContainer(request); |
// Check if the target provider is disabled |
request->operationContext.insert(pidc); |
// |
|
Boolean moduleDisabled = false; |
|
Uint32 pos = providerModule.findProperty(CIMName("OperationalStatus")); |
|
PEGASUS_ASSERT(pos != PEG_NOT_FOUND); |
|
Array<Uint16> operationalStatus; |
|
providerModule.getProperty(pos).getValue().get(operationalStatus); |
| |
|
for(Uint32 i = 0; i < operationalStatus.size(); i++) |
|
{ |
|
if ((operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED) || |
|
(operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING)) |
|
{ |
|
moduleDisabled = true; |
|
break; |
|
} |
|
} |
|
|
|
if (moduleDisabled) |
|
{ |
|
// |
|
// Send a "provider blocked" response |
|
// |
|
CIMResponseMessage* cimResponse = request->buildResponse(); |
|
cimResponse->cimException = PEGASUS_CIM_EXCEPTION_L( |
|
CIM_ERR_ACCESS_DENIED, |
|
MessageLoaderParms( |
|
"ProviderManager.ProviderManagerService.PROVIDER_BLOCKED", |
|
"provider blocked.")); |
|
response = cimResponse; |
|
} |
|
else |
|
{ |
|
// |
|
// Forward the request to the appropriate ProviderManagerRouter |
|
// |
response = _providerManagerRouter->processMessage(request); | response = _providerManagerRouter->processMessage(request); |
} | } |
|
} |
else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE) | else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE) |
{ | { |
// Handle CIMEnableModuleRequestMessage | // Handle CIMEnableModuleRequestMessage |
|
|
if (emResp->cimException.getCode() == CIM_ERR_SUCCESS) | if (emResp->cimException.getCode() == CIM_ERR_SUCCESS) |
{ | { |
_updateProviderModuleStatus( | _updateProviderModuleStatus( |
providerModule, _MODULE_STOPPED, _MODULE_OK); |
providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPED, |
|
CIM_MSE_OPSTATUS_VALUE_OK); |
} | } |
} | } |
catch (Exception& e) | catch (Exception& e) |
|
|
if (updateModuleStatus) | if (updateModuleStatus) |
{ | { |
_updateProviderModuleStatus( | _updateProviderModuleStatus( |
providerModule, _MODULE_OK, _MODULE_STOPPING); |
providerModule, CIM_MSE_OPSTATUS_VALUE_OK, |
|
CIM_MSE_OPSTATUS_VALUE_STOPPING); |
} | } |
| |
// Forward the request to the ProviderManager | // Forward the request to the ProviderManager |
|
|
{ | { |
// Disable operation failed. Module not stopped. | // Disable operation failed. Module not stopped. |
_updateProviderModuleStatus( | _updateProviderModuleStatus( |
providerModule, _MODULE_STOPPING, _MODULE_OK); |
providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPING, |
|
CIM_MSE_OPSTATUS_VALUE_OK); |
} | } |
else | else |
{ | { |
|
|
// depending on whether there are outstanding requests. | // depending on whether there are outstanding requests. |
// Use last operationalStatus entry. | // Use last operationalStatus entry. |
_updateProviderModuleStatus( | _updateProviderModuleStatus( |
providerModule, _MODULE_STOPPING, |
providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPING, |
dmResp->operationalStatus[ | dmResp->operationalStatus[ |
dmResp->operationalStatus.size()-1]); | dmResp->operationalStatus.size()-1]); |
} | } |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
void ProviderManagerService::unload_idle_providers(void) |
void ProviderManagerService::unloadIdleProviders() |
{ |
|
_providerManagerRouter->unload_idle_providers(); |
|
} |
|
|
|
ProviderIdContainer ProviderManagerService::_getProviderIdContainer( |
|
const CIMRequestMessage* message) |
|
{ | { |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, | PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
"ProviderManagerService::_getProviderIdContainer"); |
"ProviderManagerService::unloadIdleProviders"); |
|
|
CIMInstance providerModule; |
|
CIMInstance provider; |
|
| |
switch (message->getType()) |
// Ensure that only one _unloadIdleProvidersHandler thread runs at a time |
|
_unloadIdleProvidersBusy++; |
|
if ((_unloadIdleProvidersBusy.value() == 1) && |
|
(_thread_pool->allocate_and_awaken( |
|
(void*)this, ProviderManagerService::_unloadIdleProvidersHandler))) |
{ | { |
case CIM_GET_CLASS_REQUEST_MESSAGE: |
// _unloadIdleProvidersBusy is decremented in |
case CIM_DELETE_CLASS_REQUEST_MESSAGE: |
// _unloadIdleProvidersHandler |
case CIM_CREATE_CLASS_REQUEST_MESSAGE: |
|
case CIM_MODIFY_CLASS_REQUEST_MESSAGE: |
|
case CIM_ENUMERATE_CLASSES_REQUEST_MESSAGE: |
|
case CIM_ENUMERATE_CLASS_NAMES_REQUEST_MESSAGE: |
|
case CIM_GET_QUALIFIER_REQUEST_MESSAGE: |
|
case CIM_SET_QUALIFIER_REQUEST_MESSAGE: |
|
case CIM_DELETE_QUALIFIER_REQUEST_MESSAGE: |
|
case CIM_ENUMERATE_QUALIFIERS_REQUEST_MESSAGE: |
|
// The ProviderManagerService does not support class operations |
|
PEGASUS_ASSERT(0); |
|
break; |
|
|
|
case CIM_GET_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_DELETE_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_CREATE_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE: |
|
case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE: |
|
case CIM_GET_PROPERTY_REQUEST_MESSAGE: |
|
case CIM_SET_PROPERTY_REQUEST_MESSAGE: |
|
{ |
|
// Look up instance provider |
|
const CIMOperationRequestMessage* request = |
|
dynamic_cast<const CIMOperationRequestMessage*>(message); |
|
_providerRegistrationManager->lookupInstanceProvider( |
|
request->nameSpace, request->className, provider, providerModule); |
|
break; |
|
} | } |
|
else |
case CIM_EXEC_QUERY_REQUEST_MESSAGE: |
|
{ | { |
// Look up instance query provider |
// If we fail to allocate a thread, don't retry now. |
const CIMOperationRequestMessage* request = |
_unloadIdleProvidersBusy--; |
dynamic_cast<const CIMOperationRequestMessage*>(message); |
|
Boolean hasNoQuery; |
|
_providerRegistrationManager->lookupInstanceProvider( |
|
request->nameSpace, request->className, provider, providerModule, |
|
0, &hasNoQuery); |
|
// We shouldn't have gotten this far if this isn't a query provider |
|
PEGASUS_ASSERT(!hasNoQuery); |
|
break; |
|
} | } |
| |
case CIM_ASSOCIATORS_REQUEST_MESSAGE: |
PEG_METHOD_EXIT(); |
{ |
|
// Look up association provider |
|
const CIMAssociatorsRequestMessage* request = |
|
dynamic_cast<const CIMAssociatorsRequestMessage*>(message); |
|
Array<CIMInstance> providerModules; |
|
Array<CIMInstance> providers; |
|
_providerRegistrationManager->lookupAssociationProvider( |
|
request->nameSpace, request->assocClass, |
|
providers, providerModules); |
|
providerModule = providerModules[0]; |
|
provider = providers[0]; |
|
break; |
|
} | } |
| |
case CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE: |
PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL |
|
ProviderManagerService::_unloadIdleProvidersHandler(void* arg) throw() |
{ | { |
// Look up association provider |
try |
const CIMAssociatorNamesRequestMessage* request = |
|
dynamic_cast<const CIMAssociatorNamesRequestMessage*>(message); |
|
Array<CIMInstance> providerModules; |
|
Array<CIMInstance> providers; |
|
_providerRegistrationManager->lookupAssociationProvider( |
|
request->nameSpace, request->assocClass, |
|
providers, providerModules); |
|
providerModule = providerModules[0]; |
|
provider = providers[0]; |
|
break; |
|
} |
|
|
|
case CIM_REFERENCES_REQUEST_MESSAGE: |
|
{ | { |
// Look up association provider |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
const CIMReferencesRequestMessage* request = |
"ProviderManagerService::unloadIdleProvidersHandler"); |
dynamic_cast<const CIMReferencesRequestMessage*>(message); |
|
Array<CIMInstance> providerModules; |
|
Array<CIMInstance> providers; |
|
_providerRegistrationManager->lookupAssociationProvider( |
|
request->nameSpace, request->resultClass, |
|
providers, providerModules); |
|
providerModule = providerModules[0]; |
|
provider = providers[0]; |
|
break; |
|
} |
|
| |
case CIM_REFERENCE_NAMES_REQUEST_MESSAGE: |
ProviderManagerService* myself = |
{ |
reinterpret_cast<ProviderManagerService*>(arg); |
// Look up association provider |
|
const CIMReferenceNamesRequestMessage* request = |
|
dynamic_cast<const CIMReferenceNamesRequestMessage*>(message); |
|
Array<CIMInstance> providerModules; |
|
Array<CIMInstance> providers; |
|
_providerRegistrationManager->lookupAssociationProvider( |
|
request->nameSpace, request->resultClass, |
|
providers, providerModules); |
|
providerModule = providerModules[0]; |
|
provider = providers[0]; |
|
break; |
|
} |
|
| |
case CIM_INVOKE_METHOD_REQUEST_MESSAGE: |
try |
{ | { |
// Look up method provider |
myself->_providerManagerRouter->unloadIdleProviders(); |
const CIMInvokeMethodRequestMessage* request = |
|
dynamic_cast<const CIMInvokeMethodRequestMessage*>(message); |
|
_providerRegistrationManager->lookupMethodProvider( |
|
request->nameSpace, request->className, request->methodName, |
|
provider, providerModule); |
|
break; |
|
} | } |
|
catch (...) |
case CIM_EXPORT_INDICATION_REQUEST_MESSAGE: |
|
{ | { |
const CIMExportIndicationRequestMessage* request = |
// Ignore errors |
dynamic_cast<const CIMExportIndicationRequestMessage*>(message); |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
_providerRegistrationManager->lookupIndicationConsumer( |
"Unexpected exception in _unloadIdleProvidersHandler"); |
request->destinationPath, provider, providerModule); |
|
break; |
|
} | } |
| |
case CIM_ENABLE_INDICATIONS_REQUEST_MESSAGE: |
myself->_unloadIdleProvidersBusy--; |
case CIM_DISABLE_INDICATIONS_REQUEST_MESSAGE: |
PEG_METHOD_EXIT(); |
case CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE: |
|
case CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE: |
|
case CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE: |
|
{ |
|
// Provider information is already in the message |
|
const CIMIndicationRequestMessage* request = |
|
dynamic_cast<const CIMIndicationRequestMessage*>(message); |
|
providerModule = request->providerModule; |
|
provider = request->provider; |
|
break; |
|
} | } |
|
catch (...) |
case CIM_ENABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE: |
{ |
case CIM_MODIFY_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE: |
// Ignore errors |
case CIM_DISABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE: |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
case CIM_PROCESS_INDICATION_REQUEST_MESSAGE: |
"Unexpected exception in _unloadIdleProvidersHandler"); |
case CIM_HANDLE_INDICATION_REQUEST_MESSAGE: |
|
case CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE: |
|
case CIM_NOTIFY_PROVIDER_TERMINATION_REQUEST_MESSAGE: |
|
// These messages are not handled by the ProviderManagerService |
|
PEGASUS_ASSERT(0); |
|
break; |
|
|
|
case CIM_DISABLE_MODULE_REQUEST_MESSAGE: |
|
case CIM_ENABLE_MODULE_REQUEST_MESSAGE: |
|
case CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE: |
|
// These messages are handled specially by the ProviderManagerService |
|
PEGASUS_ASSERT(0); |
|
break; |
|
} | } |
| |
PEGASUS_ASSERT(!providerModule.isUninitialized()); |
return(PEGASUS_THREAD_RETURN(0)); |
PEGASUS_ASSERT(!provider.isUninitialized()); |
|
|
|
PEG_METHOD_EXIT(); |
|
return ProviderIdContainer(providerModule, provider); |
|
} | } |
| |
// Updates the providerModule instance and the ProviderRegistrationManager | // Updates the providerModule instance and the ProviderRegistrationManager |
|
|
void ProviderManagerService::indicationCallback( | void ProviderManagerService::indicationCallback( |
CIMProcessIndicationRequestMessage* request) | CIMProcessIndicationRequestMessage* request) |
{ | { |
|
try |
|
{ |
|
AcceptLanguageListContainer cntr = request->operationContext.get(AcceptLanguageListContainer::NAME); |
|
}catch(const Exception &) |
|
{ |
|
request->operationContext.insert(AcceptLanguageListContainer(AcceptLanguages::EMPTY)); |
|
} |
|
|
if (_indicationServiceQueueId == PEG_NOT_FOUND) | if (_indicationServiceQueueId == PEG_NOT_FOUND) |
{ | { |
Array<Uint32> serviceIds; | Array<Uint32> serviceIds; |