version 1.2, 2003/08/18 04:39:22
|
version 1.39, 2004/05/18 23:58:41
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2003//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000 - 2003 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development |
// 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.; |
|
// IBM Corp.; EMC 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 |
|
|
// Mike Day, IBM (mdday@us.ibm.com) | // Mike Day, IBM (mdday@us.ibm.com) |
// 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) |
|
// Amit K Arora (amita@in.ibm.com) for PEP-101 |
|
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.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/AutoPtr.h> |
|
|
|
#include <Pegasus/Config/ConfigManager.h> |
| |
#include <Pegasus/Common/Destroyer.h> |
#include <Pegasus/ProviderManager2/BasicProviderManagerRouter.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
ProviderManagerService::ProviderManagerService(void) |
static const Uint16 _MODULE_OK = 2; |
: MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP) |
static const Uint16 _MODULE_STOPPING = 9; |
{ |
static const Uint16 _MODULE_STOPPED = 10; |
} |
|
| |
ProviderManagerService::ProviderManagerService(ProviderRegistrationManager * providerRegistrationManager) |
inline Boolean _isSupportedRequestType(const Message * message) |
: MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP) |
|
{ |
|
try |
|
{ | { |
ProviderManagerModule module("DefaultProviderManager"); |
// ATTN: needs implementation |
| |
// ATTN: ensure module loaded |
// for now, assume all requests are valid |
module.load(); |
|
| |
// ATTN: ensure entry point returned valid response |
return(true); |
ProviderManager * manager = module.getProviderManager("Default"); |
|
|
|
// ATTN: only set the hacked/cached provider registration manager pointer after the module |
|
// has loaded. |
|
manager->setProviderRegistrationManager(providerRegistrationManager); |
|
|
|
_providerManagers.append(Pair<ProviderManager *, ProviderManagerModule>(manager, module)); |
|
} |
|
catch(...) |
|
{ |
|
} | } |
| |
try |
inline Boolean _isSupportedResponseType(const Message * message) |
{ | { |
ProviderManagerModule module("CMPIProviderManager"); |
// ATTN: needs implementation |
| |
// ATTN: ensure module loaded |
// for now, assume all responses are invalid |
module.load(); |
|
| |
// ATTN: ensure entry point returned valid response |
return(false); |
ProviderManager * manager = module.getProviderManager("CMPI"); |
} |
| |
// ATTN: only set the hacked/cached provider registration manager pointer after the module |
ProviderManagerService* ProviderManagerService::providerManagerService=NULL; |
// has loaded. |
CIMRepository* ProviderManagerService::_repository=NULL; |
// manager->setProviderRegistrationManager(providerRegistrationManager); |
Uint32 ProviderManagerService::_indicationServiceQueueId = PEG_NOT_FOUND; |
| |
_providerManagers.append(Pair<ProviderManager *, ProviderManagerModule>(manager, module)); |
ProviderManagerService::ProviderManagerService(void) |
} |
: MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP) |
catch(...) |
|
{ | { |
|
providerManagerService=this; |
} | } |
|
|
|
ProviderManagerService::ProviderManagerService( |
|
ProviderRegistrationManager * providerRegistrationManager, |
|
CIMRepository * repository) |
|
: MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP) |
|
{ |
|
providerManagerService=this; |
|
_repository=repository; |
|
|
|
_providerRegistrationManager = providerRegistrationManager; |
|
_providerManagerRouter = |
|
new BasicProviderManagerRouter(indicationCallback); |
} | } |
| |
ProviderManagerService::~ProviderManagerService(void) | ProviderManagerService::~ProviderManagerService(void) |
{ | { |
|
delete _providerManagerRouter; |
|
providerManagerService=NULL; |
} | } |
| |
Boolean ProviderManagerService::messageOK(const Message * message) | Boolean ProviderManagerService::messageOK(const Message * message) |
{ | { |
PEGASUS_ASSERT(message != 0); | PEGASUS_ASSERT(message != 0); |
| |
/* |
if(_isSupportedRequestType(message)) |
Boolean rc = false; |
|
|
|
switch(message->getType()) |
|
{ | { |
case CIM_GET_INSTANCE_REQUEST_MESSAGE: |
return(MessageQueueService::messageOK(message)); |
case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE: |
|
case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE: |
|
case CIM_CREATE_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_DELETE_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_GET_PROPERTY_REQUEST_MESSAGE: |
|
case CIM_SET_PROPERTY_REQUEST_MESSAGE: |
|
case CIM_INVOKE_METHOD_REQUEST_MESSAGE: |
|
case CIM_ENABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE: |
|
case CIM_MODIFY_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE: |
|
case CIM_DISABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE: |
|
rc = true; |
|
|
|
break; |
|
default: |
|
rc = false; |
|
|
|
break; |
|
} | } |
| |
return(rc); |
return(false); |
*/ |
|
|
|
return(MessageQueueService::messageOK(message)); |
|
} | } |
| |
void ProviderManagerService::handleEnqueue(void) | void ProviderManagerService::handleEnqueue(void) |
|
|
{ | { |
PEGASUS_ASSERT(message != 0); | PEGASUS_ASSERT(message != 0); |
| |
//*FIXME* Markus |
|
// catch response messages that should never appear here |
|
|
|
// if (message->getType() == CIM_ENUMERATE_INSTANCE_NAMES_RESPONSE_MESSAGE) |
|
// abort(); // handle double provider callback ! |
|
|
|
AsyncLegacyOperationStart * asyncRequest; | AsyncLegacyOperationStart * asyncRequest; |
| |
if(message->_async != NULL) | if(message->_async != NULL) |
|
|
| |
_incomingQueue.enqueue(request->op); | _incomingQueue.enqueue(request->op); |
| |
_thread_pool->allocate_and_awaken((void *)this, ProviderManagerService::handleCimOperation); |
while (!_thread_pool->allocate_and_awaken( |
|
(void *)this, ProviderManagerService::handleCimOperation)) |
|
{ |
|
pegasus_yield(); |
|
} |
} | } |
else | else |
{ | { |
|
|
return; | return; |
} | } |
| |
/* |
PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL |
PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL ProviderManagerService::handleServiceOperation(void * arg) throw() |
ProviderManagerService::handleCimOperation(void * arg) throw() |
{ | { |
// get the service from argument |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
ProviderManagerService * service = reinterpret_cast<ProviderManagerService *>(arg); |
"ProviderManagerService::handleCimOperation"); |
|
|
PEGASUS_ASSERT(service != 0); |
|
| |
// get message from service queue |
if(arg == 0) |
Message * message = service->_incomingQueue.dequeue(); |
{ |
|
// thread started with invalid argument. |
|
return(PEGASUS_THREAD_RETURN(1)); |
|
} |
| |
PEGASUS_ASSERT(message != 0); |
// get the service from argument |
|
ProviderManagerService * service = |
|
reinterpret_cast<ProviderManagerService *>(arg); |
| |
if(service->_incomingQueue.size() == 0) | if(service->_incomingQueue.size() == 0) |
{ | { |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, | PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
"ProviderManagerService::handleCimOperation() called with no op node in queue" ); |
"ProviderManagerService::handleCimOperation() called with no " |
|
"op node in queue"); |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
| |
|
|
| |
AsyncOpNode * op = service->_incomingQueue.dequeue(); | AsyncOpNode * op = service->_incomingQueue.dequeue(); |
| |
PEGASUS_ASSERT(op != 0 ); |
if((op == 0) || (op->_request.count() == 0)) |
|
|
if(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)); |
} | } |
| |
return(0); |
AsyncRequest * request = static_cast<AsyncRequest *>(op->_request.next(0)); |
|
|
|
if ((request == 0) || |
|
(request->getType() != async_messages::ASYNC_LEGACY_OP_START)) |
|
{ |
|
// reply with NAK |
|
PEG_METHOD_EXIT(); |
|
return(PEGASUS_THREAD_RETURN(0)); |
} | } |
*/ |
|
| |
PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL ProviderManagerService::handleCimOperation(void * arg) throw() |
try |
{ | { |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderManagerService::handleCimOperation"); |
Message* legacy = |
|
static_cast<AsyncLegacyOperationStart *>(request)->get_action(); |
| |
// get the service from argument |
if(_isSupportedRequestType(legacy)) |
ProviderManagerService * service = reinterpret_cast<ProviderManagerService *>(arg); |
{ |
|
AutoPtr<Message> xmessage(legacy); |
| |
PEGASUS_ASSERT(service != 0); |
// Set the client's requested language into this service thread. |
|
// This will allow functions in this service to return messages |
|
// in the correct language. |
|
CIMMessage* msg = dynamic_cast<CIMMessage *>(legacy); |
| |
if(service->_incomingQueue.size() == 0) |
if (msg != 0) |
{ | { |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
AcceptLanguages* langs = |
"ProviderManagerService::handleCimOperation() called with no op node in queue" ); |
new AcceptLanguages(msg->acceptLanguages); |
|
Thread::setLanguages(langs); |
|
} |
|
else |
|
{ |
|
Thread::clearLanguages(); |
|
} |
|
|
|
service->handleCimRequest(op, legacy); |
|
} |
|
} |
|
catch(...) |
|
{ |
|
// ATTN: log error |
|
} |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
| |
// thread started with no message in queue. |
return(PEGASUS_THREAD_RETURN(0)); |
return(PEGASUS_THREAD_RETURN(1)); |
|
} | } |
| |
AsyncOpNode * op = service->_incomingQueue.dequeue(); |
void ProviderManagerService::handleCimRequest( |
|
AsyncOpNode * op, |
|
Message * message) |
|
{ |
|
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
|
"ProviderManagerService::handleCimRequest"); |
| |
PEGASUS_ASSERT(op != 0 ); |
CIMRequestMessage * request = dynamic_cast<CIMRequestMessage *>(message); |
|
PEGASUS_ASSERT(request != 0); |
| |
if(op->_request.count() == 0) |
// get request from op node |
{ |
AsyncRequest * async = static_cast<AsyncRequest *>(op->_request.next(0)); |
MessageQueue * queue = MessageQueue::lookup(op->_source_queue); |
PEGASUS_ASSERT(async != 0); |
| |
PEGASUS_ASSERT(queue != 0); |
Message * response = 0; |
| |
PEG_METHOD_EXIT(); |
if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) || |
|
(request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE)) |
|
{ |
|
// Handle CIMOperationRequestMessage and |
|
// CIMExportIndicationRequestMessage |
| |
// no request in op node |
// Add provider information to OperationContext for the ProviderManager |
return(PEGASUS_THREAD_RETURN(1)); |
ProviderIdContainer pidc = _getProviderIdContainer(request); |
|
request->operationContext.insert(pidc); |
|
|
|
response = _providerManagerRouter->processMessage(request); |
} | } |
|
else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE) |
|
{ |
|
// Handle CIMEnableModuleRequestMessage |
|
CIMEnableModuleRequestMessage * emReq = |
|
dynamic_cast<CIMEnableModuleRequestMessage*>(request); |
| |
AsyncRequest * request = static_cast<AsyncRequest *>(op->_request.next(0)); |
CIMInstance providerModule = emReq->providerModule; |
| |
PEGASUS_ASSERT(request != 0); |
try |
|
{ |
|
// Forward the request to the ProviderManager |
|
response = _providerManagerRouter->processMessage(request); |
| |
if(request->getType() != async_messages::ASYNC_LEGACY_OP_START) |
// 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) |
{ | { |
// reply with NAK |
_updateProviderModuleStatus( |
|
providerModule, _MODULE_STOPPED, _MODULE_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); |
| |
PEG_METHOD_EXIT(); |
if (response != 0) |
|
{ |
|
delete response; |
|
} |
| |
return(PEGASUS_THREAD_RETURN(0)); |
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); |
| |
Message * legacy = static_cast<AsyncLegacyOperationStart *>(request)->get_action(); |
CIMInstance providerModule = dmReq->providerModule; |
|
Boolean updateModuleStatus = !dmReq->disableProviderOnly; |
| |
if(legacy != 0) |
try |
{ | { |
Destroyer<Message> xmessage(legacy); |
// Change module status from OK to STOPPING |
|
if (updateModuleStatus) |
|
{ |
|
_updateProviderModuleStatus( |
|
providerModule, _MODULE_OK, _MODULE_STOPPING); |
|
} |
| |
// Set the client's requested language into this service thread. |
// Forward the request to the ProviderManager |
// This will allow functions in this service to return messages |
response = _providerManagerRouter->processMessage(request); |
// in the correct language. |
|
CIMMessage * msg = dynamic_cast<CIMMessage *>(legacy); |
|
| |
if(msg != 0) |
// Update provider module status based on success or failure |
|
if (updateModuleStatus) |
|
{ |
|
CIMDisableModuleResponseMessage * dmResp = |
|
dynamic_cast<CIMDisableModuleResponseMessage*>(response); |
|
if (dmResp->cimException.getCode() != CIM_ERR_SUCCESS) |
{ | { |
AcceptLanguages * langs = new AcceptLanguages(msg->acceptLanguages); |
// Disable operation failed. Module not stopped. |
|
_updateProviderModuleStatus( |
|
providerModule, _MODULE_STOPPING, _MODULE_OK); |
|
} |
|
else |
|
{ |
|
// Disable may or may not have been successful, |
|
// depending on whether there are outstanding requests. |
|
// Use last operationalStatus entry. |
|
_updateProviderModuleStatus( |
|
providerModule, _MODULE_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); |
| |
Thread::setLanguages(langs); |
if (response != 0) |
|
{ |
|
delete response; |
|
} |
|
|
|
response = new CIMDisableModuleResponseMessage( |
|
request->messageId, |
|
CIMException(CIM_ERR_FAILED, e.getMessage()), |
|
request->queueIds.copyAndPop(), |
|
operationalStatus); |
|
} |
} | } |
else | else |
{ | { |
Thread::clearLanguages(); |
response = _providerManagerRouter->processMessage(request); |
} | } |
| |
// only pass valid message types to provider managers |
AsyncLegacyOperationResult * async_result = |
switch(legacy->getType()) |
new AsyncLegacyOperationResult( |
|
async->getKey(), |
|
async->getRouting(), |
|
op, |
|
response); |
|
|
|
_complete_op_node(op, ASYNC_OPSTATE_COMPLETE, 0, 0); |
|
|
|
PEG_METHOD_EXIT(); |
|
} |
|
|
|
void ProviderManagerService::unload_idle_providers(void) |
|
{ |
|
_providerManagerRouter->unload_idle_providers(); |
|
} |
|
|
|
ProviderIdContainer ProviderManagerService::_getProviderIdContainer( |
|
const CIMRequestMessage* message) |
|
{ |
|
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
|
"ProviderManagerService::_getProviderIdContainer"); |
|
|
|
CIMInstance providerModule; |
|
CIMInstance provider; |
|
|
|
switch (message->getType()) |
{ | { |
|
case CIM_GET_CLASS_REQUEST_MESSAGE: |
|
case CIM_DELETE_CLASS_REQUEST_MESSAGE: |
|
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_GET_INSTANCE_REQUEST_MESSAGE: |
case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE: |
case CIM_DELETE_INSTANCE_REQUEST_MESSAGE: |
case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE: |
|
case CIM_CREATE_INSTANCE_REQUEST_MESSAGE: | case CIM_CREATE_INSTANCE_REQUEST_MESSAGE: |
case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE: | case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE: |
case CIM_DELETE_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; |
|
} |
|
|
case CIM_EXEC_QUERY_REQUEST_MESSAGE: | case CIM_EXEC_QUERY_REQUEST_MESSAGE: |
|
{ |
|
// Look up instance query provider |
|
const CIMOperationRequestMessage* request = |
|
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: | case CIM_ASSOCIATORS_REQUEST_MESSAGE: |
|
{ |
|
// 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: | case CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE: |
|
{ |
|
// Look up association provider |
|
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: | case CIM_REFERENCES_REQUEST_MESSAGE: |
|
{ |
|
// Look up association provider |
|
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: | case CIM_REFERENCE_NAMES_REQUEST_MESSAGE: |
case CIM_GET_PROPERTY_REQUEST_MESSAGE: |
{ |
case CIM_SET_PROPERTY_REQUEST_MESSAGE: |
// 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: | case CIM_INVOKE_METHOD_REQUEST_MESSAGE: |
|
{ |
|
// Look up method provider |
|
const CIMInvokeMethodRequestMessage* request = |
|
dynamic_cast<const CIMInvokeMethodRequestMessage*>(message); |
|
_providerRegistrationManager->lookupMethodProvider( |
|
request->nameSpace, request->className, request->methodName, |
|
provider, providerModule); |
|
break; |
|
} |
|
|
|
case CIM_EXPORT_INDICATION_REQUEST_MESSAGE: |
|
{ |
|
const CIMExportIndicationRequestMessage* request = |
|
dynamic_cast<const CIMExportIndicationRequestMessage*>(message); |
|
_providerRegistrationManager->lookupIndicationConsumer( |
|
request->destinationPath, provider, providerModule); |
|
break; |
|
} |
|
|
|
case CIM_ENABLE_INDICATIONS_REQUEST_MESSAGE: |
|
case CIM_DISABLE_INDICATIONS_REQUEST_MESSAGE: |
case CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE: | case CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE: |
case CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE: | case CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE: |
case CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE: | case CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE: |
case CIM_ENABLE_INDICATIONS_REQUEST_MESSAGE: |
{ |
case CIM_DISABLE_INDICATIONS_REQUEST_MESSAGE: |
// 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: |
|
case CIM_MODIFY_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE: |
|
case CIM_DISABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE: |
|
case CIM_PROCESS_INDICATION_REQUEST_MESSAGE: |
|
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_DISABLE_MODULE_REQUEST_MESSAGE: |
case CIM_ENABLE_MODULE_REQUEST_MESSAGE: | case CIM_ENABLE_MODULE_REQUEST_MESSAGE: |
case CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE: | case CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE: |
case CIM_CONSUME_INDICATION_REQUEST_MESSAGE: |
// These messages are handled specially by the ProviderManagerService |
service->handleCimRequest(op, legacy); |
PEGASUS_ASSERT(0); |
break; |
|
|
|
default: |
|
// unsupported messages are ignored |
|
break; | break; |
} | } |
} |
|
| |
PEG_METHOD_EXIT(); |
PEGASUS_ASSERT(!providerModule.isUninitialized()); |
|
PEGASUS_ASSERT(!provider.isUninitialized()); |
| |
return(PEGASUS_THREAD_RETURN(0)); |
PEG_METHOD_EXIT(); |
|
return ProviderIdContainer(providerModule, provider); |
} | } |
| |
void ProviderManagerService::handleCimRequest(AsyncOpNode * op, const Message * message) throw() |
// Updates the providerModule instance and the ProviderRegistrationManager |
|
void ProviderManagerService::_updateProviderModuleStatus( |
|
CIMInstance& providerModule, |
|
Uint16 fromStatus, |
|
Uint16 toStatus) |
{ | { |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderManagerService::handleCimRequest"); |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
|
"ProviderManagerService::_updateProviderModuleStatus"); |
// ATTN: ensure message is a request??? |
|
CIMMessage * request = dynamic_cast<CIMMessage *>(const_cast<Message *>(message)); |
|
|
|
// get request from op node |
|
AsyncRequest * async = static_cast<AsyncRequest *>(op->_request.next(0)); |
|
| |
PEGASUS_ASSERT((request != 0) && (async != 0)); |
Array<Uint16> operationalStatus; |
|
String providerModuleName; |
| |
Message * response = 0; |
Uint32 pos = providerModule.findProperty(CIMName("Name")); |
|
PEGASUS_ASSERT(pos != PEG_NOT_FOUND); |
|
providerModule.getProperty(pos).getValue().get(providerModuleName); |
| |
// find provider manager |
// |
// ATTN: implement efficient lookup |
// get operational status |
ProviderManager * manager = _providerManagers[0].first; |
// |
|
pos = providerModule.findProperty(CIMName("OperationalStatus")); |
|
PEGASUS_ASSERT(pos != PEG_NOT_FOUND); |
|
CIMProperty operationalStatusProperty = providerModule.getProperty(pos); |
|
CIMValue operationalStatusValue = operationalStatusProperty.getValue(); |
| |
try |
if (!operationalStatusValue.isNull()) |
{ | { |
// forward request |
operationalStatusValue.get(operationalStatus); |
response = manager->processMessage(request); |
|
} | } |
catch(...) |
|
|
// |
|
// update module status |
|
// |
|
for (Uint32 i = operationalStatus.size(); i > 0; i--) |
|
{ |
|
if (operationalStatus[i-1] == fromStatus) |
{ | { |
// ATTN: create response with error message |
operationalStatus.remove(i-1); |
|
} |
} | } |
| |
// preserve message key |
operationalStatus.append(toStatus); |
response->setKey(request->getKey()); |
|
|
|
// set HTTP method in response from request |
|
response->setHttpMethod(request->getHttpMethod()); |
|
| |
AsyncLegacyOperationResult * async_result = |
if (_providerRegistrationManager->setProviderModuleStatus( |
new AsyncLegacyOperationResult( |
providerModuleName, operationalStatus) == false) |
async->getKey(), |
{ |
async->getRouting(), |
throw PEGASUS_CIM_EXCEPTION_L( |
op, |
CIM_ERR_FAILED, |
response); |
MessageLoaderParms( |
|
"ProviderManager.ProviderManagerService." |
|
"SET_MODULE_STATUS_FAILED", |
|
"set module status failed.")); |
|
} |
| |
_complete_op_node(op, ASYNC_OPSTATE_COMPLETE, 0, 0); |
operationalStatusProperty.setValue(CIMValue(operationalStatus)); |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
void ProviderManagerService::unload_idle_providers(void) |
void ProviderManagerService::indicationCallback( |
|
CIMProcessIndicationRequestMessage* request) |
{ | { |
|
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); |
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |