(file) Return to ProviderManagerService.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2 / Attic

Diff for /pegasus/src/Pegasus/ProviderManager2/Attic/ProviderManagerService.cpp between version 1.43 and 1.54

version 1.43, 2004/06/03 21:57:03 version 1.54, 2004/06/29 23:42:54
Line 46 
Line 46 
 #include <Pegasus/Common/Tracer.h> #include <Pegasus/Common/Tracer.h>
 #include <Pegasus/Common/Logger.h> #include <Pegasus/Common/Logger.h>
 #include <Pegasus/Common/AutoPtr.h> #include <Pegasus/Common/AutoPtr.h>
   #include <Pegasus/Common/Constants.h>
  
 #include <Pegasus/Config/ConfigManager.h> #include <Pegasus/Config/ConfigManager.h>
  
 #include <Pegasus/ProviderManager2/BasicProviderManagerRouter.h> #include <Pegasus/ProviderManager2/BasicProviderManagerRouter.h>
   #include <Pegasus/ProviderManager2/OOPProviderManagerRouter.h>
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 static const Uint16 _MODULE_OK       = 2;  
 static const Uint16 _MODULE_STOPPING = 9;  
 static const Uint16 _MODULE_STOPPED  = 10;  
   
 inline Boolean _isSupportedRequestType(const Message * message) inline Boolean _isSupportedRequestType(const Message * message)
 { {
     // ATTN: needs implementation     // ATTN: needs implementation
Line 93 
Line 91 
     _repository=repository;     _repository=repository;
  
     _providerRegistrationManager = providerRegistrationManager;     _providerRegistrationManager = providerRegistrationManager;
   
       _unloadIdleProvidersBusy = 0;
   
       // Determine whether Out-of-Process Provider support is enabled
       ConfigManager* configManager = ConfigManager::getInstance();
       if (String::equal(
           configManager->getCurrentValue("enableProviderProcesses"), "true"))
       {
           _providerManagerRouter =
               new OOPProviderManagerRouter(indicationCallback);
       }
       else
       {
     _providerManagerRouter =     _providerManagerRouter =
         new BasicProviderManagerRouter(indicationCallback);         new BasicProviderManagerRouter(indicationCallback);
 } }
   }
  
 ProviderManagerService::~ProviderManagerService(void) ProviderManagerService::~ProviderManagerService(void)
 { {
Line 245 
Line 257 
             if (msg != 0)             if (msg != 0)
             {             {
                 AcceptLanguages* langs =                 AcceptLanguages* langs =
                     new AcceptLanguages(msg->acceptLanguages);                      new AcceptLanguages(((AcceptLanguageListContainer)msg->operationContext.get
                                                                                           (AcceptLanguageListContainer::NAME)).getLanguages());
                 Thread::setLanguages(langs);                 Thread::setLanguages(langs);
             }             }
             else             else
Line 283 
Line 296 
     Message * response = 0;     Message * response = 0;
  
     if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) ||     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 and CIMExportIndicationRequestMessage          // Handle CIMOperationRequestMessage, CIMExportIndicationRequestMessage,
                 // The provider ID container is already added to operationcontext in CIMOperationRequestDispacther          // CIMIndicationRequestMessage, and CIMInitializeProviderRequestMessage.
                 // for all instance, method , association and indication providers under PEP135 , so no need to add it again .          // (These should be blocked when the provider module is disabled.)
                 // So add it only for ExportIndicationRequestMessage  
           //
           // Get the provider module instance to check for a disabled module
           //
           CIMInstance providerModule;
  
                 if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE)                 if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE)
                 {                 {
                     ProviderIdContainer pidc = _getProviderIdContainer(request);              // Get a ProviderIdContainer for ExportIndicationRequestMessage.
             request->operationContext.insert(pidc);              // Note: This can be removed when the CIMExportRequestDispatcher
               // is updated to add the ProviderIdContainer to the message.
               CIMInstance provider;
               const CIMExportIndicationRequestMessage* expRequest =
                   dynamic_cast<const CIMExportIndicationRequestMessage*>(request);
               _providerRegistrationManager->lookupIndicationConsumer(
                   expRequest->destinationPath, provider, providerModule);
               request->operationContext.insert(
                   ProviderIdContainer(providerModule, provider));
           }
           else
           {
               // The provider ID container is added to the OperationContext
               // by the CIMOperationRequestDispatcher for all CIM operation
               // requests to providers, so it does not need to be added again.
               // CIMInitializeProviderRequestMessage also has a provider ID
               // container.
               ProviderIdContainer pidc =
                   request->operationContext.get(ProviderIdContainer::NAME);
               providerModule = pidc.getModule();
                 }                 }
  
           //
           // 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;
               }
           }
   
           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
Line 319 
Line 394 
             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)
Line 358 
Line 434 
             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
Line 373 
Line 450 
                 {                 {
                     // 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
                 {                 {
Line 381 
Line 459 
                     // 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]);
                 }                 }
Line 425 
Line 503 
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
 } }
  
 void ProviderManagerService::unload_idle_providers(void)  void ProviderManagerService::unloadIdleProviders()
 {  
     _providerManagerRouter->unload_idle_providers();  
 }  
   
 ProviderIdContainer ProviderManagerService::_getProviderIdContainer(  
     const CIMRequestMessage* message)  
 { {
     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
         "ProviderManagerService::_getProviderIdContainer");          "ProviderManagerService::unloadIdleProviders");
  
     CIMInstance providerModule;      // Ensure that only one _unloadIdleProvidersHandler thread runs at a time
     CIMInstance provider;      _unloadIdleProvidersBusy++;
       if ((_unloadIdleProvidersBusy.value() == 1) &&
     switch (message->getType())          (_thread_pool->allocate_and_awaken(
                (void*)this, ProviderManagerService::_unloadIdleProvidersHandler)))
     {     {
     case CIM_GET_CLASS_REQUEST_MESSAGE:          // _unloadIdleProvidersBusy is decremented in
     case CIM_DELETE_CLASS_REQUEST_MESSAGE:          // _unloadIdleProvidersHandler
     case CIM_CREATE_CLASS_REQUEST_MESSAGE:  
     case CIM_MODIFY_CLASS_REQUEST_MESSAGE:  
     case CIM_ENUMERATE_CLASSES_REQUEST_MESSAGE:  
     case CIM_ENUMERATE_CLASS_NAMES_REQUEST_MESSAGE:  
     case CIM_GET_QUALIFIER_REQUEST_MESSAGE:  
     case CIM_SET_QUALIFIER_REQUEST_MESSAGE:  
     case CIM_DELETE_QUALIFIER_REQUEST_MESSAGE:  
     case CIM_ENUMERATE_QUALIFIERS_REQUEST_MESSAGE:  
         // The ProviderManagerService does not support class operations  
         PEGASUS_ASSERT(0);  
         break;  
   
     case CIM_GET_INSTANCE_REQUEST_MESSAGE:  
     case CIM_DELETE_INSTANCE_REQUEST_MESSAGE:  
     case CIM_CREATE_INSTANCE_REQUEST_MESSAGE:  
     case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE:  
     case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE:  
     case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE:  
     case CIM_GET_PROPERTY_REQUEST_MESSAGE:  
     case CIM_SET_PROPERTY_REQUEST_MESSAGE:  
     {  
         // Look up instance provider  
         const CIMOperationRequestMessage* request =  
             dynamic_cast<const CIMOperationRequestMessage*>(message);  
         _providerRegistrationManager->lookupInstanceProvider(  
             request->nameSpace, request->className, provider, providerModule);  
         break;  
     }     }
       else
     case CIM_EXEC_QUERY_REQUEST_MESSAGE:  
     {     {
         // Look up instance query provider          // If we fail to allocate a thread, don't retry now.
         const CIMOperationRequestMessage* request =          _unloadIdleProvidersBusy--;
             dynamic_cast<const CIMOperationRequestMessage*>(message);  
         Boolean hasNoQuery;  
         _providerRegistrationManager->lookupInstanceProvider(  
             request->nameSpace, request->className, provider, providerModule,  
             0, &hasNoQuery);  
         // We shouldn't have gotten this far if this isn't a query provider  
         PEGASUS_ASSERT(!hasNoQuery);  
         break;  
     }     }
  
     case CIM_ASSOCIATORS_REQUEST_MESSAGE:      PEG_METHOD_EXIT();
     {  
         // Look up association provider  
         const CIMAssociatorsRequestMessage* request =  
             dynamic_cast<const CIMAssociatorsRequestMessage*>(message);  
         Array<CIMInstance> providerModules;  
         Array<CIMInstance> providers;  
         _providerRegistrationManager->lookupAssociationProvider(  
             request->nameSpace, request->assocClass,  
             providers, providerModules);  
         providerModule = providerModules[0];  
         provider = providers[0];  
         break;  
     }     }
  
     case CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE:  PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL
   ProviderManagerService::_unloadIdleProvidersHandler(void* arg) throw()
     {     {
         // Look up association provider      try
         const CIMAssociatorNamesRequestMessage* request =  
             dynamic_cast<const CIMAssociatorNamesRequestMessage*>(message);  
         Array<CIMInstance> providerModules;  
         Array<CIMInstance> providers;  
         _providerRegistrationManager->lookupAssociationProvider(  
             request->nameSpace, request->assocClass,  
             providers, providerModules);  
         providerModule = providerModules[0];  
         provider = providers[0];  
         break;  
     }  
   
     case CIM_REFERENCES_REQUEST_MESSAGE:  
     {     {
         // Look up association provider          PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
         const CIMReferencesRequestMessage* request =              "ProviderManagerService::unloadIdleProvidersHandler");
             dynamic_cast<const CIMReferencesRequestMessage*>(message);  
         Array<CIMInstance> providerModules;  
         Array<CIMInstance> providers;  
         _providerRegistrationManager->lookupAssociationProvider(  
             request->nameSpace, request->resultClass,  
             providers, providerModules);  
         providerModule = providerModules[0];  
         provider = providers[0];  
         break;  
     }  
  
     case CIM_REFERENCE_NAMES_REQUEST_MESSAGE:          ProviderManagerService* myself =
     {              reinterpret_cast<ProviderManagerService*>(arg);
         // Look up association provider  
         const CIMReferenceNamesRequestMessage* request =  
             dynamic_cast<const CIMReferenceNamesRequestMessage*>(message);  
         Array<CIMInstance> providerModules;  
         Array<CIMInstance> providers;  
         _providerRegistrationManager->lookupAssociationProvider(  
             request->nameSpace, request->resultClass,  
             providers, providerModules);  
         providerModule = providerModules[0];  
         provider = providers[0];  
         break;  
     }  
  
     case CIM_INVOKE_METHOD_REQUEST_MESSAGE:          try
     {     {
         // Look up method provider              myself->_providerManagerRouter->unloadIdleProviders();
         const CIMInvokeMethodRequestMessage* request =  
             dynamic_cast<const CIMInvokeMethodRequestMessage*>(message);  
         _providerRegistrationManager->lookupMethodProvider(  
             request->nameSpace, request->className, request->methodName,  
             provider, providerModule);  
         break;  
     }     }
           catch (...)
     case CIM_EXPORT_INDICATION_REQUEST_MESSAGE:  
     {     {
         const CIMExportIndicationRequestMessage* request =              // Ignore errors
             dynamic_cast<const CIMExportIndicationRequestMessage*>(message);              PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
         _providerRegistrationManager->lookupIndicationConsumer(                  "Unexpected exception in _unloadIdleProvidersHandler");
             request->destinationPath, provider, providerModule);  
         break;  
     }     }
  
     case CIM_ENABLE_INDICATIONS_REQUEST_MESSAGE:          myself->_unloadIdleProvidersBusy--;
     case CIM_DISABLE_INDICATIONS_REQUEST_MESSAGE:          PEG_METHOD_EXIT();
     case CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE:  
     case CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE:  
     case CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE:  
     {  
         // Provider information is already in the message  
         const CIMIndicationRequestMessage* request =  
             dynamic_cast<const CIMIndicationRequestMessage*>(message);  
         providerModule = request->providerModule;  
         provider = request->provider;  
         break;  
     }     }
       catch (...)
     case CIM_ENABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE:  
     case CIM_MODIFY_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE:  
     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_ENABLE_MODULE_REQUEST_MESSAGE:  
     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:  
     {     {
         // Provider information is already in the message          // Ignore errors
         const CIMInitializeProviderRequestMessage* request =          PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
             dynamic_cast<const CIMInitializeProviderRequestMessage*>(message);              "Unexpected exception in _unloadIdleProvidersHandler");
   
         const ProviderIdContainer container =  
             request->operationContext.get(ProviderIdContainer::NAME);  
         providerModule = container.getModule();  
         provider = container.getProvider();  
         break;  
     }  
   
     }     }
  
     PEGASUS_ASSERT(!providerModule.isUninitialized());      return(PEGASUS_THREAD_RETURN(0));
     PEGASUS_ASSERT(!provider.isUninitialized());  
   
     PEG_METHOD_EXIT();  
     return ProviderIdContainer(providerModule, provider);  
 } }
  
 // Updates the providerModule instance and the ProviderRegistrationManager // Updates the providerModule instance and the ProviderRegistrationManager
Line 681 
Line 622 
 void ProviderManagerService::indicationCallback( void ProviderManagerService::indicationCallback(
     CIMProcessIndicationRequestMessage* request)     CIMProcessIndicationRequestMessage* request)
 { {
           try
           {
                   AcceptLanguageListContainer cntr = request->operationContext.get(AcceptLanguageListContainer::NAME);
           }catch(Exception &e)
           {
                   request->operationContext.insert(AcceptLanguageListContainer(AcceptLanguages::EMPTY));
           }
   
     if (_indicationServiceQueueId == PEG_NOT_FOUND)     if (_indicationServiceQueueId == PEG_NOT_FOUND)
     {     {
         Array<Uint32> serviceIds;         Array<Uint32> serviceIds;


Legend:
Removed from v.1.43  
changed lines
  Added in v.1.54

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2