version 1.24.6.5, 2004/04/05 08:55:51
|
version 1.69, 2005/07/19 19:05:35
|
|
|
//%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 |
|
|
// Karl Schopmeyer(k.schopmeyer@opengroup.org) - Fix associators. | // Karl Schopmeyer(k.schopmeyer@opengroup.org) - Fix associators. |
// Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com) | // Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com) |
// Adrian Schuur, IBM (schuur@de.ibm.com) | // Adrian Schuur, IBM (schuur@de.ibm.com) |
|
// Amit K Arora (amita@in.ibm.com) for PEP-101 |
|
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
|
// 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/Tracer.h> | #include <Pegasus/Common/Tracer.h> |
#include <Pegasus/Common/Logger.h> | #include <Pegasus/Common/Logger.h> |
#include <Pegasus/Common/Destroyer.h> |
#include <Pegasus/Common/AutoPtr.h> |
#include <Pegasus/ProviderManager2/OperationResponseHandler.h> |
#include <Pegasus/Common/Constants.h> |
| |
#include <Pegasus/Config/ConfigManager.h> | #include <Pegasus/Config/ConfigManager.h> |
| |
#include <Pegasus/ProviderManager2/ProviderManagerModule.h> |
#include <Pegasus/ProviderManager2/BasicProviderManagerRouter.h> |
#include <Pegasus/ProviderManager2/ProviderManager.h> |
#include <Pegasus/ProviderManager2/OOPProviderManagerRouter.h> |
|
#include <Pegasus/ProviderManager2/OperationResponseHandler.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
// BEGIN TEMP SECTION |
|
class ProviderManagerContainer |
|
{ |
|
public: |
|
ProviderManagerContainer(void) : _manager(0) |
|
{ |
|
} |
|
|
|
ProviderManagerContainer(const ProviderManagerContainer & container) : _manager(0) |
|
{ |
|
*this = container; |
|
} |
|
|
|
ProviderManagerContainer(const String & physicalName, const String & logicalName, const String & interfaceName) : _manager(0) |
|
{ |
|
_physicalName=ProviderManager::_resolvePhysicalName(physicalName); |
|
|
|
_logicalName = logicalName; |
|
|
|
_interfaceName = interfaceName; |
|
|
|
_module = ProviderManagerModule(_physicalName); |
|
|
|
_module.load(); |
|
|
|
_manager = _module.getProviderManager(_logicalName); |
|
|
|
PEGASUS_ASSERT(_manager != 0); |
|
} |
|
|
|
~ProviderManagerContainer(void) |
|
{ |
|
_module.unload(); |
|
} |
|
|
|
ProviderManagerContainer & operator=(const ProviderManagerContainer & container) |
|
{ |
|
if(this == &container) |
|
{ |
|
return(*this); |
|
} |
|
|
|
_logicalName = container._logicalName; |
|
_physicalName = container._physicalName; |
|
_interfaceName = container._interfaceName; |
|
|
|
_module = container._module; |
|
_manager = container._manager; |
|
|
|
return(*this); |
|
} |
|
|
|
ProviderManager *getProviderManager(void) |
|
{ |
|
return _manager; |
|
} |
|
|
|
const String & getPhysicalName(void) const |
|
{ |
|
return(_physicalName); |
|
} |
|
|
|
const String & getLogicalName(void) const |
|
{ |
|
return(_logicalName); |
|
} |
|
|
|
const String & getInterfaceName(void) const |
|
{ |
|
return(_interfaceName); |
|
} |
|
|
|
private: |
|
String _physicalName; |
|
String _logicalName; |
|
String _interfaceName; |
|
|
|
ProviderManagerModule _module; |
|
ProviderManager * _manager; |
|
|
|
}; |
|
|
|
static Array<ProviderManagerContainer*> _providerManagers; |
|
// END TEMP SECTION |
|
|
|
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; |
| |
ProviderManagerService::ProviderManagerService(void) | ProviderManagerService::ProviderManagerService(void) |
: MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP) | : MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP) |
|
|
providerManagerService=this; | providerManagerService=this; |
_repository=repository; | _repository=repository; |
| |
SetProviderRegistrationManager(providerRegistrationManager); |
_providerRegistrationManager = providerRegistrationManager; |
| |
// ATTN: this section is a temporary solution to populate the list of enabled |
_unloadIdleProvidersBusy = 0; |
// provider managers for a given distribution. it includes another temporary |
|
// solution for converting a generic file name into a file name useable by |
_basicProviderManagerRouter = 0; |
// each platform. |
_oopProviderManagerRouter = 0; |
|
|
// BEGIN TEMP SECTION |
|
//#if defined(PEGASUS_OS_OS400) |
|
//_providerManagers.append(ProviderManagerContainer("QSYS/??????????", "INTERNAL", "INTERNAL")); |
|
//#else |
|
//_providerManager.append(ProviderManagerContainer("InternalProviderManager", "DEFAULT", "INTERNAL")); |
|
//#endif |
|
|
|
#if defined(ENABLE_DEFAULT_PROVIDER_MANAGER) |
|
#if defined(PEGASUS_OS_OS400) |
|
_providerManagers.append( |
|
new ProviderManagerContainer("QSYS/QYCMDFTPVM", "DEFAULT", "C++Default")); |
|
#else |
|
_providerManagers.append( |
|
new ProviderManagerContainer("DefaultProviderManager", "DEFAULT", "C++Default")); |
|
#endif |
|
#endif |
|
| |
#if defined(ENABLE_CMPI_PROVIDER_MANAGER) |
// Determine which ProviderManagerRouter(s) to use |
#if defined(PEGASUS_OS_OS400) |
|
_providerManagers.append( |
ConfigManager* configManager = ConfigManager::getInstance(); |
new ProviderManagerContainer("QSYS/QYCMCMPIPM", "CMPI", "CMPI")); |
Boolean forceProviderProcesses = String::equal( |
|
configManager->getCurrentValue("forceProviderProcesses"), "true"); |
|
|
|
#ifdef PEGASUS_DISABLE_PROV_USERCTXT |
|
if (forceProviderProcesses) |
|
{ |
|
_oopProviderManagerRouter = |
|
new OOPProviderManagerRouter(indicationCallback); |
|
} |
|
else |
|
{ |
|
_basicProviderManagerRouter = |
|
new BasicProviderManagerRouter(indicationCallback); |
|
} |
#else | #else |
_providerManagers.append( |
_oopProviderManagerRouter = |
new ProviderManagerContainer("CMPIProviderManager", "CMPI", "CMPI")); |
new OOPProviderManagerRouter(indicationCallback); |
#endif |
|
|
if (!forceProviderProcesses) |
|
{ |
|
_basicProviderManagerRouter = |
|
new BasicProviderManagerRouter(indicationCallback); |
|
} |
#endif | #endif |
// END TEMP SECTION |
|
} | } |
| |
ProviderManagerService::~ProviderManagerService(void) | ProviderManagerService::~ProviderManagerService(void) |
{ | { |
|
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 |
PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL ProviderManagerService::handleCimOperation(void * arg) throw() |
// entry point, and any exceptions thrown are ignored. |
|
PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL |
|
ProviderManagerService::handleCimOperation(void* arg) |
{ | { |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderManagerService::handleCimOperation"); |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
|
"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 = reinterpret_cast<ProviderManagerService *>(arg); |
ProviderManagerService* service = |
|
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 op node in queue" ); |
"ProviderManagerService::handleCimOperation() called with no " |
|
"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)); |
} | } |
| |
|
|
| |
if((op == 0) || (op->_request.count() == 0)) | if((op == 0) || (op->_request.count() == 0)) |
{ | { |
|
// ATTN: This may dereference a null pointer! |
MessageQueue * queue = MessageQueue::lookup(op->_source_queue); | MessageQueue * queue = MessageQueue::lookup(op->_source_queue); |
| |
PEGASUS_ASSERT(queue != 0); | PEGASUS_ASSERT(queue != 0); |
|
|
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) || (request->getType() != async_messages::ASYNC_LEGACY_OP_START)) |
if ((request == 0) || |
|
(request->getType() != async_messages::ASYNC_LEGACY_OP_START)) |
{ | { |
// reply with NAK | // reply with NAK |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
|
|
return(PEGASUS_THREAD_RETURN(0)); | return(PEGASUS_THREAD_RETURN(0)); |
} | } |
| |
try |
Message* legacy = |
{ |
static_cast<AsyncLegacyOperationStart *>(request)->get_action(); |
Message * legacy = static_cast<AsyncLegacyOperationStart *>(request)->get_action(); |
|
| |
if(_isSupportedRequestType(legacy)) | if(_isSupportedRequestType(legacy)) |
{ | { |
Destroyer<Message> xmessage(legacy); |
AutoPtr<Message> xmessage(legacy); |
| |
// Set the client's requested language into this service thread. | // Set the client's requested language into this service thread. |
// This will allow functions in this service to return messages | // This will allow functions in this service to return messages |
|
|
| |
if(msg != 0) | if(msg != 0) |
{ | { |
AcceptLanguages * langs = new AcceptLanguages(msg->acceptLanguages); |
AcceptLanguages* langs = new 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(); |
|
|
return(PEGASUS_THREAD_RETURN(0)); | return(PEGASUS_THREAD_RETURN(0)); |
} | } |
| |
void ProviderManagerService::handleCimRequest(AsyncOpNode * op, const Message * message) |
void ProviderManagerService::handleCimRequest( |
|
AsyncOpNode * op, |
|
Message * message) |
{ | { |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderManagerService::handleCimRequest"); |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
|
"ProviderManagerService::handleCimRequest"); |
| |
// ATTN: ensure message is a request??? |
CIMRequestMessage * request = dynamic_cast<CIMRequestMessage *>(message); |
CIMMessage * request = dynamic_cast<CIMMessage *>(const_cast<Message *>(message)); |
PEGASUS_ASSERT(request != 0); |
| |
// get request from op node | // get request from op node |
AsyncRequest * async = static_cast<AsyncRequest *>(op->_request.next(0)); | AsyncRequest * async = static_cast<AsyncRequest *>(op->_request.next(0)); |
|
PEGASUS_ASSERT(async != 0); |
PEGASUS_ASSERT((request != 0) && (async != 0)); |
|
| |
Message * response = 0; | Message * response = 0; |
String ifc; |
Boolean consumerLookupFailed = false; |
| |
// get the responsible provider Manager |
if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) |
ProviderManager * pm = locateProviderManager(message,ifc); |
{ |
if (pm) { |
// |
response = pm->processMessage(request); |
// Get a ProviderIdContainer for ExportIndicationRequestMessage. |
} |
// Note: This can be removed when the CIMExportRequestDispatcher |
|
// is updated to add the ProviderIdContainer to the message. |
else for (Uint32 i = 0, n = _providerManagers.size(); i < n; i++) { |
// |
ProviderManagerContainer *pmc=_providerManagers[i]; |
CIMInstance providerModule; |
switch (message->getType()) { |
CIMInstance provider; |
case CIM_ENABLE_MODULE_REQUEST_MESSAGE: { |
const CIMExportIndicationRequestMessage* expRequest = |
CIMEnableModuleRequestMessage * request = |
dynamic_cast<const CIMExportIndicationRequestMessage*>(request); |
dynamic_cast<CIMEnableModuleRequestMessage*>(const_cast<Message*>(message)); |
if (_providerRegistrationManager->lookupIndicationConsumer( |
if (request->providerModule.getProperty(request->providerModule.findProperty |
expRequest->destinationPath, provider, providerModule)) |
("InterfaceType")).getValue().toString()==pmc->getInterfaceName()) |
{ |
response=pmc->getProviderManager()->processMessage(request); |
request->operationContext.insert( |
|
ProviderIdContainer(providerModule, provider)); |
} | } |
break; |
else |
case CIM_DISABLE_MODULE_REQUEST_MESSAGE: { |
{ |
CIMDisableModuleRequestMessage * request = |
consumerLookupFailed = true; |
dynamic_cast<CIMDisableModuleRequestMessage*>(const_cast<Message*>(message)); |
|
if (request->providerModule.getProperty(request->providerModule.findProperty |
|
("InterfaceType")).getValue().toString()==pmc->getInterfaceName()) |
|
response=pmc->getProviderManager()->processMessage(request); |
|
} | } |
|
} |
|
|
|
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_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; |
|
|
|
// 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(); |
|
|
|
// |
|
// Check if the target provider is disabled |
|
// |
|
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; | break; |
case CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE: { |
|
Message *resp=pmc->getProviderManager()->processMessage(request); |
|
if (resp) response=resp; } |
|
break; |
|
default: |
|
CIMRequestMessage * req = |
|
dynamic_cast<CIMRequestMessage *>(const_cast<Message *>(message)); |
|
CIMResponseMessage *resp=new CIMResponseMessage(0,req->messageId,CIMException(), |
|
req->queueIds.copyAndPop()); |
|
response=resp; |
|
resp->synch_response(req); |
|
OperationResponseHandler handler(req, resp); |
|
handler.setStatus(CIM_ERR_FAILED, "Unknown messagetype."); |
|
} | } |
} | } |
| |
// preserve message key |
if (moduleDisabled) |
response->setKey(request->getKey()); |
{ |
|
// |
|
// 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 = _processMessage(request); |
|
} |
|
} |
|
else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE) |
|
{ |
|
// Handle CIMEnableModuleRequestMessage |
|
CIMEnableModuleRequestMessage * emReq = |
|
dynamic_cast<CIMEnableModuleRequestMessage*>(request); |
|
|
|
CIMInstance providerModule = emReq->providerModule; |
| |
// set HTTP method in response from request |
try |
response->setHttpMethod(request->getHttpMethod()); |
{ |
|
// Forward the request to the ProviderManager |
|
response = _processMessage(request); |
|
|
|
// If successful, update provider module status to OK |
|
// ATTN: Use CIMEnableModuleResponseMessage operationalStatus? |
|
CIMEnableModuleResponseMessage * emResp = |
|
dynamic_cast<CIMEnableModuleResponseMessage*>(response); |
|
if (emResp->cimException.getCode() == CIM_ERR_SUCCESS) |
|
{ |
|
_updateProviderModuleStatus( |
|
providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPED, |
|
CIM_MSE_OPSTATUS_VALUE_OK); |
|
} |
|
} |
|
catch (Exception& e) |
|
{ |
|
// Get the OperationalStatus property from the provider module |
|
Array<Uint16> operationalStatus; |
|
CIMValue itValue = emReq->providerModule.getProperty( |
|
emReq->providerModule.findProperty("OperationalStatus")) |
|
.getValue(); |
|
itValue.get(operationalStatus); |
|
|
|
if (response != 0) |
|
{ |
|
delete response; |
|
} |
|
|
|
response = new CIMEnableModuleResponseMessage( |
|
request->messageId, |
|
CIMException(CIM_ERR_FAILED, e.getMessage()), |
|
request->queueIds.copyAndPop(), |
|
operationalStatus); |
|
} |
|
} |
|
else if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE) |
|
{ |
|
// Handle CIMDisableModuleRequestMessage |
|
CIMDisableModuleRequestMessage * dmReq = |
|
dynamic_cast<CIMDisableModuleRequestMessage*>(request); |
|
|
|
CIMInstance providerModule = dmReq->providerModule; |
|
Boolean updateModuleStatus = !dmReq->disableProviderOnly; |
|
|
|
try |
|
{ |
|
// Change module status from OK to STOPPING |
|
if (updateModuleStatus) |
|
{ |
|
_updateProviderModuleStatus( |
|
providerModule, CIM_MSE_OPSTATUS_VALUE_OK, |
|
CIM_MSE_OPSTATUS_VALUE_STOPPING); |
|
} |
|
|
|
// Forward the request to the ProviderManager |
|
response = _processMessage(request); |
|
|
|
// Update provider module status based on success or failure |
|
if (updateModuleStatus) |
|
{ |
|
CIMDisableModuleResponseMessage * dmResp = |
|
dynamic_cast<CIMDisableModuleResponseMessage*>(response); |
|
if (dmResp->cimException.getCode() != CIM_ERR_SUCCESS) |
|
{ |
|
// Disable operation failed. Module not stopped. |
|
_updateProviderModuleStatus( |
|
providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPING, |
|
CIM_MSE_OPSTATUS_VALUE_OK); |
|
} |
|
else |
|
{ |
|
// Disable may or may not have been successful, |
|
// depending on whether there are outstanding requests. |
|
// Use last operationalStatus entry. |
|
_updateProviderModuleStatus( |
|
providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPING, |
|
dmResp->operationalStatus[ |
|
dmResp->operationalStatus.size()-1]); |
|
} |
|
} |
|
} |
|
catch (Exception& e) |
|
{ |
|
// Get the OperationalStatus property from the provider module |
|
Array<Uint16> operationalStatus; |
|
CIMValue itValue = dmReq->providerModule.getProperty( |
|
dmReq->providerModule.findProperty("OperationalStatus")) |
|
.getValue(); |
|
itValue.get(operationalStatus); |
|
|
|
if (response != 0) |
|
{ |
|
delete response; |
|
} |
|
|
|
response = new CIMDisableModuleResponseMessage( |
|
request->messageId, |
|
CIMException(CIM_ERR_FAILED, e.getMessage()), |
|
request->queueIds.copyAndPop(), |
|
operationalStatus); |
|
} |
|
} |
|
else |
|
{ |
|
response = _processMessage(request); |
|
} |
| |
AsyncLegacyOperationResult * async_result = | AsyncLegacyOperationResult * async_result = |
new AsyncLegacyOperationResult( | new AsyncLegacyOperationResult( |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
ProviderManager* ProviderManagerService::locateProviderManager(const Message *message, |
void |
String & it) |
ProviderManagerService::handleCimResponse(CIMRequestMessage &request, |
|
CIMResponseMessage &response) |
{ | { |
CIMNamespaceName nameSpace; |
CIMStatusCode code = CIM_ERR_SUCCESS; |
CIMName className; |
String message; |
CIMName method; |
|
| |
const CIMOperationRequestMessage * p = |
try |
dynamic_cast<const CIMOperationRequestMessage *>(message); |
{ |
|
// only incomplete messages are processed because the caller ends up |
|
// sending the complete() stage |
|
PEGASUS_ASSERT(response.isComplete() == false); |
|
|
|
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); |
|
|
|
// set the destination |
|
op->_op_dest = op->_callback_response_q; |
|
|
|
MessageQueueService *service = |
|
dynamic_cast<MessageQueueService *>(op->_callback_response_q); |
| |
if (p) { |
PEGASUS_ASSERT(service); |
nameSpace=p->nameSpace; |
|
| |
if (p->providerType==ProviderType::ASSOCIATION) |
// the last chunk MUST be sent last, so use execute the callback |
className=((CIMAssociatorsRequestMessage*)p)->assocClass; |
// not all chunks are going through the dispatcher's chunk |
else className=p->className; |
// 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(CIMException &e) |
|
{ |
|
code = e.getCode(); |
|
message = e.getMessage(); |
|
} |
|
catch(Exception &e) |
|
{ |
|
code = CIM_ERR_FAILED; |
|
message = e.getMessage(); |
|
} |
|
catch(...) |
|
{ |
|
code = CIM_ERR_FAILED; |
|
message = cimStatusCodeToString(code); |
|
} |
| |
if (p->providerType==ProviderType::METHOD) |
if (code != CIM_ERR_SUCCESS) |
method=((CIMInvokeMethodRequestMessage*)p)->methodName; |
response.cimException = PEGASUS_CIM_EXCEPTION(code, message); |
|
} |
| |
ProviderName name(nameSpace, |
Message* ProviderManagerService::_processMessage(CIMRequestMessage* request) |
className, |
{ |
p->providerType, |
Message* response = 0; |
method); |
|
| |
// find provider manager |
if ((request->getType() == CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE) || |
name = ProviderRegistrar().findProvider(name,false); |
(request->getType() == |
it=name.getInterfaceName(); |
CIM_SUBSCRIPTION_INIT_COMPLETE_REQUEST_MESSAGE) || |
|
(request->getType() == CIM_NOTIFY_CONFIG_CHANGE_REQUEST_MESSAGE)) |
|
{ |
|
if (_basicProviderManagerRouter) |
|
{ |
|
response = _basicProviderManagerRouter->processMessage(request); |
} | } |
| |
else { |
if (_oopProviderManagerRouter) |
const CIMIndicationRequestMessage * p = |
{ |
dynamic_cast<const CIMIndicationRequestMessage *>(message); |
// Note: These responses do not contain interesting data, so just |
if (p) { |
// use the last one. |
CIMIndicationRequestMessage *m=(CIMIndicationRequestMessage*)message; |
if (response) |
it=m->providerModule.getProperty (m->providerModule.findProperty |
{ |
("InterfaceType")).getValue ().toString (); |
delete response; |
} | } |
| |
else switch (message->getType()) { |
response = _oopProviderManagerRouter->processMessage(request); |
case CIM_DISABLE_MODULE_REQUEST_MESSAGE: |
|
case CIM_ENABLE_MODULE_REQUEST_MESSAGE: |
|
case CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE: |
|
return NULL; |
|
default: |
|
it="C++Default"; |
|
} | } |
} | } |
|
else |
|
{ |
|
CIMInstance providerModule; |
| |
// find provider manager for provider interface |
if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE) |
for(Uint32 i = 0, n = _providerManagers.size(); i < n; i++) |
{ |
|
CIMEnableModuleRequestMessage* emReq = |
|
dynamic_cast<CIMEnableModuleRequestMessage*>(request); |
|
providerModule = emReq->providerModule; |
|
} |
|
else if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE) |
{ | { |
if (String::equalNoCase(it,_providerManagers[i]->getInterfaceName())) { |
CIMDisableModuleRequestMessage* dmReq = |
ProviderManagerContainer *pmc=_providerManagers[i]; |
dynamic_cast<CIMDisableModuleRequestMessage*>(request); |
return pmc->getProviderManager(); |
providerModule = dmReq->providerModule; |
} | } |
|
else |
|
{ |
|
ProviderIdContainer pidc = |
|
request->operationContext.get(ProviderIdContainer::NAME); |
|
providerModule = pidc.getModule(); |
} | } |
ProviderManagerContainer *pmc=_providerManagers[0]; |
|
return pmc->getProviderManager(); |
Uint16 userContext = 0; |
|
Uint32 pos = providerModule.findProperty( |
|
PEGASUS_PROPERTYNAME_MODULE_USERCONTEXT); |
|
if (pos != PEG_NOT_FOUND) |
|
{ |
|
providerModule.getProperty(pos).getValue().get(userContext); |
} | } |
| |
void ProviderManagerService::unload_idle_providers(void) |
// 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 |
|
) |
{ | { |
for(Uint32 i = 0, n = _providerManagers.size(); i < n; i++) |
response = _oopProviderManagerRouter->processMessage(request); |
|
} |
|
else |
{ | { |
ProviderManagerContainer *pmc=_providerManagers[i]; |
response = _basicProviderManagerRouter->processMessage(request); |
pmc->getProviderManager()->unload_idle_providers(); |
|
} | } |
} | } |
| |
PEGASUS_NAMESPACE_END |
return response; |
|
} |
| |
|
void ProviderManagerService::unloadIdleProviders() |
|
{ |
|
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
|
"ProviderManagerService::unloadIdleProviders"); |
|
ThreadStatus rtn = PEGASUS_THREAD_OK; |
|
// Ensure that only one _unloadIdleProvidersHandler thread runs at a time |
|
_unloadIdleProvidersBusy++; |
|
if ((_unloadIdleProvidersBusy.value() == 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."); |
|
|
|
Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
|
"Could not allocate thread for %s to unload idle providers.", |
|
getQueueName()); |
|
} |
|
PEG_METHOD_EXIT(); |
|
} |
|
|
|
PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL |
|
ProviderManagerService::_unloadIdleProvidersHandler(void* arg) throw() |
|
{ |
|
try |
|
{ |
|
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
|
"ProviderManagerService::unloadIdleProvidersHandler"); |
|
|
|
ProviderManagerService* myself = |
|
reinterpret_cast<ProviderManagerService*>(arg); |
|
|
|
if (myself->_basicProviderManagerRouter) |
|
{ |
|
try |
|
{ |
|
myself->_basicProviderManagerRouter->unloadIdleProviders(); |
|
} |
|
catch (...) |
|
{ |
|
// Ignore errors |
|
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
|
"Unexpected exception from " |
|
"BasicProviderManagerRouter::_unloadIdleProviders"); |
|
} |
|
} |
|
|
|
if (myself->_oopProviderManagerRouter) |
|
{ |
|
try |
|
{ |
|
myself->_oopProviderManagerRouter->unloadIdleProviders(); |
|
} |
|
catch (...) |
|
{ |
|
// Ignore errors |
|
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
|
"Unexpected exception from " |
|
"OOPProviderManagerRouter::_unloadIdleProviders"); |
|
} |
|
} |
|
|
|
myself->_unloadIdleProvidersBusy--; |
|
PEG_METHOD_EXIT(); |
|
} |
|
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 |
|
void ProviderManagerService::_updateProviderModuleStatus( |
|
CIMInstance& providerModule, |
|
Uint16 fromStatus, |
|
Uint16 toStatus) |
|
{ |
|
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
|
"ProviderManagerService::_updateProviderModuleStatus"); |
|
|
|
Array<Uint16> operationalStatus; |
|
String providerModuleName; |
|
|
|
Uint32 pos = providerModule.findProperty(CIMName("Name")); |
|
PEGASUS_ASSERT(pos != PEG_NOT_FOUND); |
|
providerModule.getProperty(pos).getValue().get(providerModuleName); |
|
|
|
// |
|
// get operational status |
|
// |
|
pos = providerModule.findProperty(CIMName("OperationalStatus")); |
|
PEGASUS_ASSERT(pos != PEG_NOT_FOUND); |
|
CIMProperty operationalStatusProperty = providerModule.getProperty(pos); |
|
CIMValue operationalStatusValue = operationalStatusProperty.getValue(); |
|
|
|
if (!operationalStatusValue.isNull()) |
|
{ |
|
operationalStatusValue.get(operationalStatus); |
|
} |
|
|
|
// |
|
// update module status |
|
// |
|
for (Uint32 i = operationalStatus.size(); i > 0; i--) |
|
{ |
|
if (operationalStatus[i-1] == fromStatus) |
|
{ |
|
operationalStatus.remove(i-1); |
|
} |
|
} |
|
|
|
operationalStatus.append(toStatus); |
|
|
|
if (_providerRegistrationManager->setProviderModuleStatus( |
|
providerModuleName, operationalStatus) == false) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION_L( |
|
CIM_ERR_FAILED, |
|
MessageLoaderParms( |
|
"ProviderManager.ProviderManagerService." |
|
"SET_MODULE_STATUS_FAILED", |
|
"set module status failed.")); |
|
} |
|
|
|
operationalStatusProperty.setValue(CIMValue(operationalStatus)); |
|
|
|
PEG_METHOD_EXIT(); |
|
} |
|
|
|
void ProviderManagerService::indicationCallback( |
|
CIMProcessIndicationRequestMessage* request) |
|
{ |
|
try |
|
{ |
|
AcceptLanguageListContainer cntr = request->operationContext.get(AcceptLanguageListContainer::NAME); |
|
}catch(const Exception &) |
|
{ |
|
request->operationContext.insert(AcceptLanguageListContainer(AcceptLanguages::EMPTY)); |
|
} |
|
|
|
if (_indicationServiceQueueId == PEG_NOT_FOUND) |
|
{ |
|
Array<Uint32> serviceIds; |
|
|
|
providerManagerService->find_services( |
|
PEGASUS_QUEUENAME_INDICATIONSERVICE, 0, 0, &serviceIds); |
|
PEGASUS_ASSERT(serviceIds.size() != 0); |
|
|
|
_indicationServiceQueueId = serviceIds[0]; |
|
} |
|
|
|
request->queueIds = QueueIdStack( |
|
_indicationServiceQueueId, providerManagerService->getQueueId()); |
|
|
|
AsyncLegacyOperationStart * asyncRequest = |
|
new AsyncLegacyOperationStart( |
|
providerManagerService->get_next_xid(), |
|
0, |
|
_indicationServiceQueueId, |
|
request, |
|
_indicationServiceQueueId); |
|
|
|
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 |