version 1.45, 2004/06/14 20:00:29
|
version 1.70.6.1, 2005/10/21 17:34:42
|
|
|
//%2003//////////////////////////////////////////////////////////////////////// |
//%2005//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Company, L. P., IBM Corp., The Open Group, Tivoli Systems. |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; | // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; |
// IBM Corp.; EMC Corporation, The Open Group. | // 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. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// 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) | // Seema Gupta (gseema@in.ibm.com for PEP135) |
|
// Jim Wunderlich (Jim_Wunderlich@prodigy.net) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include "ProviderManagerService.h" | #include "ProviderManagerService.h" |
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
|
#include <Pegasus/Common/PegasusVersion.h> |
#include <Pegasus/Common/Constants.h> | #include <Pegasus/Common/Constants.h> |
#include <Pegasus/Common/CIMMessage.h> | #include <Pegasus/Common/CIMMessage.h> |
#include <Pegasus/Common/Thread.h> | #include <Pegasus/Common/Thread.h> |
#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> |
|
#include <Pegasus/ProviderManager2/OperationResponseHandler.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 |
|
|
| |
_unloadIdleProvidersBusy = 0; | _unloadIdleProvidersBusy = 0; |
| |
_providerManagerRouter = |
_basicProviderManagerRouter = 0; |
|
_oopProviderManagerRouter = 0; |
|
|
|
// Determine which ProviderManagerRouter(s) to use |
|
|
|
ConfigManager* configManager = ConfigManager::getInstance(); |
|
Boolean forceProviderProcesses = String::equal( |
|
configManager->getCurrentValue("forceProviderProcesses"), "true"); |
|
|
|
#ifdef PEGASUS_DISABLE_PROV_USERCTXT |
|
if (forceProviderProcesses) |
|
{ |
|
_oopProviderManagerRouter = |
|
new OOPProviderManagerRouter(indicationCallback); |
|
} |
|
else |
|
{ |
|
_basicProviderManagerRouter = |
new BasicProviderManagerRouter(indicationCallback); | new BasicProviderManagerRouter(indicationCallback); |
} | } |
|
#else |
|
_oopProviderManagerRouter = |
|
new OOPProviderManagerRouter(indicationCallback); |
|
|
|
if (!forceProviderProcesses) |
|
{ |
|
_basicProviderManagerRouter = |
|
new BasicProviderManagerRouter(indicationCallback); |
|
} |
|
#endif |
|
} |
| |
ProviderManagerService::~ProviderManagerService(void) | ProviderManagerService::~ProviderManagerService(void) |
{ | { |
delete _providerManagerRouter; |
delete _basicProviderManagerRouter; |
|
delete _oopProviderManagerRouter; |
providerManagerService=NULL; | providerManagerService=NULL; |
} | } |
| |
|
|
request->op->processing(); | request->op->processing(); |
| |
_incomingQueue.enqueue(request->op); | _incomingQueue.enqueue(request->op); |
|
ThreadStatus rtn = PEGASUS_THREAD_OK; |
while (!_thread_pool->allocate_and_awaken( |
while (( rtn =_thread_pool->allocate_and_awaken( |
(void *)this, ProviderManagerService::handleCimOperation)) |
(void *)this, ProviderManagerService::handleCimOperation)) != PEGASUS_THREAD_OK) |
{ | { |
|
if (rtn==PEGASUS_THREAD_INSUFFICIENT_RESOURCES) |
pegasus_yield(); | pegasus_yield(); |
|
else |
|
{ |
|
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, |
|
"Not enough threads to service provider manager." ); |
|
|
|
Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
|
"Could not allocate thread for %s.", |
|
getQueueName()); |
|
} |
} | } |
} | } |
else | else |
|
|
return; | return; |
} | } |
| |
|
// Note: This method should not throw an exception. It is used as a thread |
|
// entry point, and any exceptions thrown are ignored. |
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(arg == 0) |
PEGASUS_ASSERT(arg != 0); |
{ |
|
// thread started with invalid argument. |
|
return(PEGASUS_THREAD_RETURN(1)); |
|
} |
|
| |
// get the service from argument | // get the service from argument |
ProviderManagerService * service = | ProviderManagerService * service = |
reinterpret_cast<ProviderManagerService *>(arg); | reinterpret_cast<ProviderManagerService *>(arg); |
|
PEGASUS_ASSERT(service != 0); |
| |
|
try |
|
{ |
if(service->_incomingQueue.size() == 0) | if(service->_incomingQueue.size() == 0) |
{ | { |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
"ProviderManagerService::handleCimOperation() called with no " | "ProviderManagerService::handleCimOperation() called with no " |
"op node in queue"); | "op node in queue"); |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
|
|
// thread started with no message in queue. |
|
return(PEGASUS_THREAD_RETURN(1)); | return(PEGASUS_THREAD_RETURN(1)); |
} | } |
| |
|
|
return(PEGASUS_THREAD_RETURN(1)); | return(PEGASUS_THREAD_RETURN(1)); |
} | } |
| |
AsyncRequest * request = static_cast<AsyncRequest *>(op->_request.next(0)); |
AsyncRequest* request = |
|
static_cast<AsyncRequest*>(op->_request.next(0)); |
| |
if ((request == 0) || | if ((request == 0) || |
(request->getType() != async_messages::ASYNC_LEGACY_OP_START)) | (request->getType() != async_messages::ASYNC_LEGACY_OP_START)) |
|
|
return(PEGASUS_THREAD_RETURN(0)); | return(PEGASUS_THREAD_RETURN(0)); |
} | } |
| |
try |
|
{ |
|
Message* legacy = | Message* legacy = |
static_cast<AsyncLegacyOperationStart *>(request)->get_action(); | static_cast<AsyncLegacyOperationStart *>(request)->get_action(); |
| |
|
|
| |
if (msg != 0) | if (msg != 0) |
{ | { |
AcceptLanguages* langs = |
AcceptLanguages* langs = new AcceptLanguages( |
new AcceptLanguages(msg->acceptLanguages); |
((AcceptLanguageListContainer)msg->operationContext.get( |
|
AcceptLanguageListContainer::NAME)).getLanguages()); |
Thread::setLanguages(langs); | Thread::setLanguages(langs); |
} | } |
else | else |
|
|
service->handleCimRequest(op, legacy); | service->handleCimRequest(op, legacy); |
} | } |
} | } |
|
catch (const Exception& e) |
|
{ |
|
PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2, |
|
"Unexpected exception in handleCimOperation: " + e.getMessage()); |
|
} |
catch(...) | catch(...) |
{ | { |
// ATTN: log error |
PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2, |
|
"Unexpected exception in handleCimOperation."); |
} | } |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
|
|
PEGASUS_ASSERT(async != 0); | PEGASUS_ASSERT(async != 0); |
| |
Message * response = 0; | Message * response = 0; |
|
Boolean consumerLookupFailed = false; |
| |
if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) || |
if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) |
|
{ |
|
// |
|
// Get a ProviderIdContainer for ExportIndicationRequestMessage. |
|
// Note: This can be removed when the CIMExportRequestDispatcher |
|
// is updated to add the ProviderIdContainer to the message. |
|
// |
|
CIMInstance providerModule; |
|
CIMInstance provider; |
|
const CIMExportIndicationRequestMessage* expRequest = |
|
dynamic_cast<const CIMExportIndicationRequestMessage*>(request); |
|
if (_providerRegistrationManager->lookupIndicationConsumer( |
|
expRequest->destinationPath, provider, providerModule)) |
|
{ |
|
request->operationContext.insert( |
|
ProviderIdContainer(providerModule, provider)); |
|
} |
|
else |
|
{ |
|
consumerLookupFailed = true; |
|
} |
|
} |
|
|
|
if (consumerLookupFailed) |
|
{ |
|
CIMResponseMessage* cimResponse = request->buildResponse(); |
|
cimResponse->cimException = PEGASUS_CIM_EXCEPTION( |
|
CIM_ERR_NOT_SUPPORTED, String::EMPTY); |
|
response = cimResponse; |
|
} |
|
else if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) || |
|
(dynamic_cast<CIMIndicationRequestMessage*>(request) != 0) || |
(request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) || | (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) || |
(request->getType() == CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE)) | (request->getType() == CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE)) |
{ | { |
// Handle CIMOperationRequestMessage, CIMExportIndicationRequestMessage, | // Handle CIMOperationRequestMessage, CIMExportIndicationRequestMessage, |
// and CIMInitializeProviderRequestMessage |
// 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; |
| |
// Note: The provider ID container is added to the OperationContext |
// The provider ID container is added to the OperationContext |
// by the CIMOperationRequestDispatcher for all CIM operation | // by the CIMOperationRequestDispatcher for all CIM operation |
// requests to providers, so it does not need to be added again. | // requests to providers, so it does not need to be added again. |
|
// CIMInitializeProviderRequestMessage also has a provider ID |
// Get a ProviderIdContainer for ExportIndicationRequestMessage |
// container. |
if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) |
ProviderIdContainer pidc = |
{ |
request->operationContext.get(ProviderIdContainer::NAME); |
ProviderIdContainer pidc = _getProviderIdContainer(request); |
providerModule = pidc.getModule(); |
request->operationContext.insert(pidc); |
|
} |
|
| |
// | // |
// Check if the target provider is disabled | // Check if the target provider is disabled |
// | // |
Boolean moduleDisabled = false; | Boolean moduleDisabled = false; |
ProviderIdContainer pidc = |
|
request->operationContext.get(ProviderIdContainer::NAME); |
|
const CIMInstance providerModule = pidc.getModule(); |
|
Uint32 pos = providerModule.findProperty(CIMName("OperationalStatus")); | Uint32 pos = providerModule.findProperty(CIMName("OperationalStatus")); |
PEGASUS_ASSERT(pos != PEG_NOT_FOUND); | PEGASUS_ASSERT(pos != PEG_NOT_FOUND); |
Array<Uint16> operationalStatus; | Array<Uint16> operationalStatus; |
|
|
| |
for(Uint32 i = 0; i < operationalStatus.size(); i++) | for(Uint32 i = 0; i < operationalStatus.size(); i++) |
{ | { |
if ((operationalStatus[i] == _MODULE_STOPPED) || |
if ((operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED) || |
(operationalStatus[i] == _MODULE_STOPPING)) |
(operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING)) |
{ | { |
moduleDisabled = true; | moduleDisabled = true; |
break; | break; |
|
|
"ProviderManager.ProviderManagerService.PROVIDER_BLOCKED", | "ProviderManager.ProviderManagerService.PROVIDER_BLOCKED", |
"provider blocked.")); | "provider blocked.")); |
response = cimResponse; | response = cimResponse; |
|
|
|
STAT_COPYDISPATCHER |
} | } |
else | else |
{ | { |
// | // |
// Forward the request to the appropriate ProviderManagerRouter | // Forward the request to the appropriate ProviderManagerRouter |
// | // |
response = _providerManagerRouter->processMessage(request); |
response = _processMessage(request); |
} | } |
} | } |
else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE) | else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE) |
|
|
try | try |
{ | { |
// Forward the request to the ProviderManager | // Forward the request to the ProviderManager |
response = _providerManagerRouter->processMessage(request); |
response = _processMessage(request); |
| |
// If successful, update provider module status to OK | // If successful, update provider module status to OK |
// ATTN: Use CIMEnableModuleResponseMessage operationalStatus? | // ATTN: Use CIMEnableModuleResponseMessage operationalStatus? |
|
|
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 |
response = _providerManagerRouter->processMessage(request); |
response = _processMessage(request); |
| |
// Update provider module status based on success or failure | // Update provider module status based on success or failure |
if (updateModuleStatus) | if (updateModuleStatus) |
|
|
{ | { |
// 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]); |
} | } |
|
|
} | } |
else | else |
{ | { |
response = _providerManagerRouter->processMessage(request); |
response = _processMessage(request); |
} | } |
| |
AsyncLegacyOperationResult * async_result = | AsyncLegacyOperationResult * async_result = |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
void ProviderManagerService::unloadIdleProviders() |
void |
|
ProviderManagerService::handleCimResponse(CIMRequestMessage &request, |
|
CIMResponseMessage &response) |
{ | { |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
CIMStatusCode code = CIM_ERR_SUCCESS; |
"ProviderManagerService::unloadIdleProviders"); |
String message; |
| |
// Ensure that only one _unloadIdleProvidersHandler thread runs at a time |
try |
_unloadIdleProvidersBusy++; |
|
if ((_unloadIdleProvidersBusy.value() == 1) && |
|
(_thread_pool->allocate_and_awaken( |
|
(void*)this, ProviderManagerService::_unloadIdleProvidersHandler))) |
|
{ |
|
// _unloadIdleProvidersBusy is decremented in |
|
// _unloadIdleProvidersHandler |
|
} |
|
else |
|
{ | { |
// If we fail to allocate a thread, don't retry now. |
// only incomplete messages are processed because the caller ends up |
_unloadIdleProvidersBusy--; |
// sending the complete() stage |
} |
PEGASUS_ASSERT(response.isComplete() == false); |
| |
PEG_METHOD_EXIT(); |
AsyncLegacyOperationStart *requestAsync = |
} |
dynamic_cast<AsyncLegacyOperationStart *>(request._async); |
|
PEGASUS_ASSERT(requestAsync); |
|
AsyncOpNode *op = requestAsync->op; |
|
PEGASUS_ASSERT(op); |
|
PEGASUS_ASSERT(! response._async); |
|
response._async = new AsyncLegacyOperationResult |
|
(requestAsync->getKey(), requestAsync->getRouting(), op, &response); |
| |
PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL |
// set the destination |
ProviderManagerService::_unloadIdleProvidersHandler(void* arg) throw() |
op->_op_dest = op->_callback_response_q; |
{ |
|
try |
|
{ |
|
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
|
"ProviderManagerService::unloadIdleProvidersHandler"); |
|
| |
ProviderManagerService* myself = |
MessageQueueService *service = |
reinterpret_cast<ProviderManagerService*>(arg); |
dynamic_cast<MessageQueueService *>(op->_callback_response_q); |
| |
try |
PEGASUS_ASSERT(service); |
{ |
|
myself->_providerManagerRouter->unloadIdleProviders(); |
// the last chunk MUST be sent last, so use execute the callback |
|
// not all chunks are going through the dispatcher's chunk |
|
// resequencer, so this must be a synchronous call here |
|
// After the call is done, response and asyncResponse are now invalid |
|
// as they have been sent and deleted externally |
|
|
|
op->_async_callback(op, service, op->_callback_ptr); |
} | } |
catch (...) |
|
|
catch(CIMException &e) |
{ | { |
// Ignore errors |
code = e.getCode(); |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
message = e.getMessage(); |
"Unexpected exception in _unloadIdleProvidersHandler"); |
|
} | } |
|
catch(Exception &e) |
myself->_unloadIdleProvidersBusy--; |
{ |
PEG_METHOD_EXIT(); |
code = CIM_ERR_FAILED; |
|
message = e.getMessage(); |
} | } |
catch (...) | catch (...) |
{ | { |
// Ignore errors |
code = CIM_ERR_FAILED; |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
message = cimStatusCodeToString(code); |
"Unexpected exception in _unloadIdleProvidersHandler"); |
|
} | } |
| |
return(PEGASUS_THREAD_RETURN(0)); |
if (code != CIM_ERR_SUCCESS) |
|
response.cimException = PEGASUS_CIM_EXCEPTION(code, message); |
} | } |
| |
ProviderIdContainer ProviderManagerService::_getProviderIdContainer( |
Message* ProviderManagerService::_processMessage(CIMRequestMessage* request) |
const CIMRequestMessage* message) |
|
{ | { |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
Message* response = 0; |
"ProviderManagerService::_getProviderIdContainer"); |
|
| |
CIMInstance providerModule; |
if ((request->getType() == CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE) || |
CIMInstance provider; |
(request->getType() == |
|
CIM_SUBSCRIPTION_INIT_COMPLETE_REQUEST_MESSAGE) || |
|
(request->getType() == CIM_NOTIFY_CONFIG_CHANGE_REQUEST_MESSAGE)) |
|
{ |
|
if (_basicProviderManagerRouter) |
|
{ |
|
response = _basicProviderManagerRouter->processMessage(request); |
|
} |
| |
switch (message->getType()) |
if (_oopProviderManagerRouter) |
{ | { |
case CIM_GET_CLASS_REQUEST_MESSAGE: |
// Note: These responses do not contain interesting data, so just |
case CIM_DELETE_CLASS_REQUEST_MESSAGE: |
// use the last one. |
case CIM_CREATE_CLASS_REQUEST_MESSAGE: |
if (response) |
case CIM_MODIFY_CLASS_REQUEST_MESSAGE: |
{ |
case CIM_ENUMERATE_CLASSES_REQUEST_MESSAGE: |
delete response; |
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: |
response = _oopProviderManagerRouter->processMessage(request); |
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 |
|
{ |
|
CIMInstance providerModule; |
| |
case CIM_EXEC_QUERY_REQUEST_MESSAGE: |
if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE) |
{ | { |
// Look up instance query provider |
CIMEnableModuleRequestMessage* emReq = |
const CIMOperationRequestMessage* request = |
dynamic_cast<CIMEnableModuleRequestMessage*>(request); |
dynamic_cast<const CIMOperationRequestMessage*>(message); |
providerModule = emReq->providerModule; |
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; |
|
} | } |
|
else if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE) |
case CIM_ASSOCIATORS_REQUEST_MESSAGE: |
|
{ | { |
// Look up association provider |
CIMDisableModuleRequestMessage* dmReq = |
const CIMAssociatorsRequestMessage* request = |
dynamic_cast<CIMDisableModuleRequestMessage*>(request); |
dynamic_cast<const CIMAssociatorsRequestMessage*>(message); |
providerModule = dmReq->providerModule; |
Array<CIMInstance> providerModules; |
|
Array<CIMInstance> providers; |
|
_providerRegistrationManager->lookupAssociationProvider( |
|
request->nameSpace, request->assocClass, |
|
providers, providerModules); |
|
providerModule = providerModules[0]; |
|
provider = providers[0]; |
|
break; |
|
} | } |
|
else |
case CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE: |
|
{ | { |
// Look up association provider |
ProviderIdContainer pidc = |
const CIMAssociatorNamesRequestMessage* request = |
request->operationContext.get(ProviderIdContainer::NAME); |
dynamic_cast<const CIMAssociatorNamesRequestMessage*>(message); |
providerModule = pidc.getModule(); |
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: |
Uint16 userContext = 0; |
|
Uint32 pos = providerModule.findProperty( |
|
PEGASUS_PROPERTYNAME_MODULE_USERCONTEXT); |
|
if (pos != PEG_NOT_FOUND) |
{ | { |
// Look up association provider |
providerModule.getProperty(pos).getValue().get(userContext); |
const CIMReferencesRequestMessage* request = |
|
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: |
// Forward the request to the appropriate ProviderManagerRouter, based |
|
// on the CIM Server configuration and the UserContext setting. |
|
|
|
ConfigManager* configManager = ConfigManager::getInstance(); |
|
Boolean forceProviderProcesses = String::equal( |
|
configManager->getCurrentValue("forceProviderProcesses"), "true"); |
|
|
|
if (forceProviderProcesses |
|
#ifndef PEGASUS_DISABLE_PROV_USERCTXT |
|
|| (userContext == PG_PROVMODULE_USERCTXT_REQUESTOR) |
|
|| (userContext == PG_PROVMODULE_USERCTXT_DESIGNATED) |
|
|| ((userContext == PG_PROVMODULE_USERCTXT_PRIVILEGED) && |
|
!System::isPrivilegedUser(System::getEffectiveUserName())) |
|
#endif |
|
) |
{ | { |
// Look up association provider |
response = _oopProviderManagerRouter->processMessage(request); |
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; |
|
} | } |
|
else |
case CIM_INVOKE_METHOD_REQUEST_MESSAGE: |
|
{ | { |
// Look up method provider |
response = _basicProviderManagerRouter->processMessage(request); |
const CIMInvokeMethodRequestMessage* request = |
} |
dynamic_cast<const CIMInvokeMethodRequestMessage*>(message); |
} |
_providerRegistrationManager->lookupMethodProvider( |
|
request->nameSpace, request->className, request->methodName, |
return response; |
provider, providerModule); |
|
break; |
|
} | } |
| |
case CIM_EXPORT_INDICATION_REQUEST_MESSAGE: |
void ProviderManagerService::unloadIdleProviders() |
{ | { |
const CIMExportIndicationRequestMessage* request = |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
dynamic_cast<const CIMExportIndicationRequestMessage*>(message); |
"ProviderManagerService::unloadIdleProviders"); |
_providerRegistrationManager->lookupIndicationConsumer( |
ThreadStatus rtn = PEGASUS_THREAD_OK; |
request->destinationPath, provider, providerModule); |
// Ensure that only one _unloadIdleProvidersHandler thread runs at a time |
break; |
_unloadIdleProvidersBusy++; |
|
if ((_unloadIdleProvidersBusy.get() == 1) && |
|
((rtn = _thread_pool->allocate_and_awaken( |
|
(void*)this, ProviderManagerService::_unloadIdleProvidersHandler))==PEGASUS_THREAD_OK)) |
|
{ |
|
// _unloadIdleProvidersBusy is decremented in |
|
// _unloadIdleProvidersHandler |
|
} |
|
else |
|
{ |
|
// If we fail to allocate a thread, don't retry now. |
|
_unloadIdleProvidersBusy--; |
} | } |
|
if (rtn != PEGASUS_THREAD_OK) |
|
{ |
|
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, |
|
"Not enough threads to unload idle providers."); |
| |
case CIM_ENABLE_INDICATIONS_REQUEST_MESSAGE: |
Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
case CIM_DISABLE_INDICATIONS_REQUEST_MESSAGE: |
"Could not allocate thread for %s to unload idle providers.", |
case CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE: |
getQueueName()); |
case CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE: |
} |
case CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE: |
PEG_METHOD_EXIT(); |
{ |
|
// Provider information is already in the message |
|
const CIMIndicationRequestMessage* request = |
|
dynamic_cast<const CIMIndicationRequestMessage*>(message); |
|
providerModule = request->providerModule; |
|
provider = request->provider; |
|
break; |
|
} | } |
| |
case CIM_ENABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE: |
PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL |
case CIM_MODIFY_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE: |
ProviderManagerService::_unloadIdleProvidersHandler(void* arg) throw() |
case CIM_DISABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE: |
{ |
case CIM_PROCESS_INDICATION_REQUEST_MESSAGE: |
try |
case CIM_HANDLE_INDICATION_REQUEST_MESSAGE: |
{ |
case CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE: |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
case CIM_NOTIFY_PROVIDER_TERMINATION_REQUEST_MESSAGE: |
"ProviderManagerService::unloadIdleProvidersHandler"); |
// These messages are not handled by the ProviderManagerService |
|
PEGASUS_ASSERT(0); |
|
break; |
|
| |
case CIM_DISABLE_MODULE_REQUEST_MESSAGE: |
ProviderManagerService* myself = |
case CIM_ENABLE_MODULE_REQUEST_MESSAGE: |
reinterpret_cast<ProviderManagerService*>(arg); |
case CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE: |
|
// These messages are handled specially by the ProviderManagerService |
|
PEGASUS_ASSERT(0); |
|
break; |
|
| |
case CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE: |
if (myself->_basicProviderManagerRouter) |
{ | { |
// Provider information is already in the message |
try |
const CIMInitializeProviderRequestMessage* request = |
{ |
dynamic_cast<const CIMInitializeProviderRequestMessage*>(message); |
myself->_basicProviderManagerRouter->unloadIdleProviders(); |
|
} |
const ProviderIdContainer container = |
catch (...) |
request->operationContext.get(ProviderIdContainer::NAME); |
{ |
providerModule = container.getModule(); |
// Ignore errors |
provider = container.getProvider(); |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
break; |
"Unexpected exception from " |
|
"BasicProviderManagerRouter::_unloadIdleProviders"); |
} | } |
|
|
} | } |
| |
PEGASUS_ASSERT(!providerModule.isUninitialized()); |
if (myself->_oopProviderManagerRouter) |
PEGASUS_ASSERT(!provider.isUninitialized()); |
{ |
|
try |
|
{ |
|
myself->_oopProviderManagerRouter->unloadIdleProviders(); |
|
} |
|
catch (...) |
|
{ |
|
// Ignore errors |
|
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
|
"Unexpected exception from " |
|
"OOPProviderManagerRouter::_unloadIdleProviders"); |
|
} |
|
} |
| |
|
myself->_unloadIdleProvidersBusy--; |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return ProviderIdContainer(providerModule, provider); |
} |
|
catch (...) |
|
{ |
|
// Ignore errors |
|
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
|
"Unexpected exception in _unloadIdleProvidersHandler"); |
|
} |
|
|
|
return(PEGASUS_THREAD_RETURN(0)); |
} | } |
| |
// 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; |
|
|
_indicationServiceQueueId); | _indicationServiceQueueId); |
| |
providerManagerService->SendForget(asyncRequest); | providerManagerService->SendForget(asyncRequest); |
|
|
|
|
|
|
|
|
|
#ifdef PEGASUS_INDICATIONS_Q_THRESHOLD |
|
|
|
// See Comments in config.mak asociated with |
|
// PEGASUS_INDICATIONS_Q_THRESHOLD |
|
// |
|
// if INDICATIONS_Q_STALL THRESHOLD is gt 0 |
|
// then if there are over INDICATIONS_Q_STALL_THRESHOLD |
|
// indications in the queue |
|
// then force this provider to sleep until the queue count |
|
// is lower than INDICATIONS_Q_RESUME_THRESHOLD |
|
|
|
static Mutex indicationThresholdReportedLock; |
|
static Boolean indicationThresholdReported = false; |
|
|
|
#define INDICATIONS_Q_STALL_THRESHOLD PEGASUS_INDICATIONS_Q_THRESHOLD |
|
#define INDICATIONS_Q_RESUME_THRESHOLD (int)(PEGASUS_INDICATIONS_Q_THRESHOLD*.90) |
|
#define INDICATIONS_Q_STALL_DURATION 250 // milli-seconds |
|
|
|
MessageQueue * indicationsQueue = MessageQueue::lookup(_indicationServiceQueueId); |
|
|
|
if (((MessageQueueService *)indicationsQueue)->getIncomingCount() > INDICATIONS_Q_STALL_THRESHOLD) |
|
{ |
|
AutoMutex indicationThresholdReportedAutoMutex(indicationThresholdReportedLock); |
|
if (!indicationThresholdReported) |
|
{ |
|
indicationThresholdReported = true; |
|
indicationThresholdReportedAutoMutex.unlock(); |
|
|
|
// make log entry to record que max exceeded |
|
|
|
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
|
"Indication generation stalled: maximum queue count ($0) exceeded.", |
|
INDICATIONS_Q_STALL_THRESHOLD); |
|
} |
|
else |
|
{ |
|
indicationThresholdReportedAutoMutex.unlock(); |
|
} |
|
|
|
while (((MessageQueueService *)indicationsQueue)->getIncomingCount() > INDICATIONS_Q_RESUME_THRESHOLD) |
|
{ |
|
pegasus_sleep(INDICATIONS_Q_STALL_DURATION); |
|
} |
|
|
|
AutoMutex indicationThresholdReportedAutoMutex1(indicationThresholdReportedLock); |
|
// indicationThresholdReportedLock.lock(pegasus_thread_self()); |
|
if(indicationThresholdReported) |
|
{ |
|
indicationThresholdReported = false; |
|
indicationThresholdReportedAutoMutex1.unlock(); |
|
|
|
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
|
"Indication generation resumed: current queue count = $0", |
|
((MessageQueueService *)indicationsQueue)->getIncomingCount() ); |
|
|
|
} |
|
else |
|
{ |
|
indicationThresholdReportedAutoMutex1.unlock(); |
|
} |
|
} |
|
#endif /* INDICATIONS_Q_STALL_THRESHOLD */ |
|
|
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |