version 1.39, 2004/05/18 23:58:41
|
version 1.45, 2004/06/14 20:00:29
|
|
|
// Adrian Schuur, IBM (schuur@de.ibm.com) | // Adrian Schuur, IBM (schuur@de.ibm.com) |
// Amit K Arora (amita@in.ibm.com) for PEP-101 | // Amit K Arora (amita@in.ibm.com) for PEP-101 |
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) | // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
|
// Seema Gupta (gseema@in.ibm.com for PEP135) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
} | } |
| |
ProviderManagerService* ProviderManagerService::providerManagerService=NULL; | ProviderManagerService* ProviderManagerService::providerManagerService=NULL; |
CIMRepository* ProviderManagerService::_repository=NULL; |
|
Uint32 ProviderManagerService::_indicationServiceQueueId = PEG_NOT_FOUND; | Uint32 ProviderManagerService::_indicationServiceQueueId = PEG_NOT_FOUND; |
| |
ProviderManagerService::ProviderManagerService(void) | ProviderManagerService::ProviderManagerService(void) |
|
|
_repository=repository; | _repository=repository; |
| |
_providerRegistrationManager = providerRegistrationManager; | _providerRegistrationManager = providerRegistrationManager; |
|
|
|
_unloadIdleProvidersBusy = 0; |
|
|
_providerManagerRouter = | _providerManagerRouter = |
new BasicProviderManagerRouter(indicationCallback); | new BasicProviderManagerRouter(indicationCallback); |
} | } |
|
|
Message * response = 0; | Message * response = 0; |
| |
if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) || | if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) || |
(request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE)) |
(request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) || |
|
(request->getType() == CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE)) |
{ | { |
// Handle CIMOperationRequestMessage and |
// Handle CIMOperationRequestMessage, CIMExportIndicationRequestMessage, |
// CIMExportIndicationRequestMessage |
// and CIMInitializeProviderRequestMessage |
|
|
|
// Note: 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. |
| |
// Add provider information to OperationContext for the ProviderManager |
// Get a ProviderIdContainer for ExportIndicationRequestMessage |
|
if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) |
|
{ |
ProviderIdContainer pidc = _getProviderIdContainer(request); | ProviderIdContainer pidc = _getProviderIdContainer(request); |
request->operationContext.insert(pidc); | request->operationContext.insert(pidc); |
|
} |
| |
|
// |
|
// Check if the target provider is disabled |
|
// |
|
Boolean moduleDisabled = false; |
|
ProviderIdContainer pidc = |
|
request->operationContext.get(ProviderIdContainer::NAME); |
|
const CIMInstance providerModule = pidc.getModule(); |
|
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] == _MODULE_STOPPED) || |
|
(operationalStatus[i] == _MODULE_STOPPING)) |
|
{ |
|
moduleDisabled = true; |
|
break; |
|
} |
|
} |
|
|
|
if (moduleDisabled) |
|
{ |
|
// |
|
// Send a "provider blocked" response |
|
// |
|
CIMResponseMessage* cimResponse = request->buildResponse(); |
|
cimResponse->cimException = PEGASUS_CIM_EXCEPTION_L( |
|
CIM_ERR_ACCESS_DENIED, |
|
MessageLoaderParms( |
|
"ProviderManager.ProviderManagerService.PROVIDER_BLOCKED", |
|
"provider blocked.")); |
|
response = cimResponse; |
|
} |
|
else |
|
{ |
|
// |
|
// Forward the request to the appropriate ProviderManagerRouter |
|
// |
response = _providerManagerRouter->processMessage(request); | response = _providerManagerRouter->processMessage(request); |
} | } |
|
} |
else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE) | else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE) |
{ | { |
// Handle CIMEnableModuleRequestMessage | // Handle CIMEnableModuleRequestMessage |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
void ProviderManagerService::unload_idle_providers(void) |
void ProviderManagerService::unloadIdleProviders() |
|
{ |
|
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
|
"ProviderManagerService::unloadIdleProviders"); |
|
|
|
// Ensure that only one _unloadIdleProvidersHandler thread runs at a time |
|
_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. |
|
_unloadIdleProvidersBusy--; |
|
} |
|
|
|
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); |
|
|
|
try |
|
{ |
|
myself->_providerManagerRouter->unloadIdleProviders(); |
|
} |
|
catch (...) |
{ | { |
_providerManagerRouter->unload_idle_providers(); |
// Ignore errors |
|
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
|
"Unexpected exception in _unloadIdleProvidersHandler"); |
|
} |
|
|
|
myself->_unloadIdleProvidersBusy--; |
|
PEG_METHOD_EXIT(); |
|
} |
|
catch (...) |
|
{ |
|
// Ignore errors |
|
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
|
"Unexpected exception in _unloadIdleProvidersHandler"); |
|
} |
|
|
|
return(PEGASUS_THREAD_RETURN(0)); |
} | } |
| |
ProviderIdContainer ProviderManagerService::_getProviderIdContainer( | ProviderIdContainer ProviderManagerService::_getProviderIdContainer( |
|
|
// These messages are handled specially by the ProviderManagerService | // These messages are handled specially by the ProviderManagerService |
PEGASUS_ASSERT(0); | PEGASUS_ASSERT(0); |
break; | break; |
|
|
|
case CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE: |
|
{ |
|
// Provider information is already in the message |
|
const CIMInitializeProviderRequestMessage* request = |
|
dynamic_cast<const CIMInitializeProviderRequestMessage*>(message); |
|
|
|
const ProviderIdContainer container = |
|
request->operationContext.get(ProviderIdContainer::NAME); |
|
providerModule = container.getModule(); |
|
provider = container.getProvider(); |
|
break; |
|
} |
|
|
} | } |
| |
PEGASUS_ASSERT(!providerModule.isUninitialized()); | PEGASUS_ASSERT(!providerModule.isUninitialized()); |