(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.46 and 1.78

version 1.46, 2004/06/15 18:47:18 version 1.78, 2006/04/18 19:08:44
Line 1 
Line 1 
 //%2003////////////////////////////////////////////////////////////////////////  //%2006////////////////////////////////////////////////////////////////////////
 // //
 // 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.
   // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; Symantec 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
Line 34 
Line 40 
 //              Amit K Arora (amita@in.ibm.com) for PEP-101 //              Amit K Arora (amita@in.ibm.com) for PEP-101
 //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 //              Seema Gupta (gseema@in.ibm.com for PEP135) //              Seema Gupta (gseema@in.ibm.com for PEP135)
   //              Jim Wunderlich (Jim_Wunderlich@prodigy.net)
   //              Aruran, IBM (ashanmug@in.ibm.com)for Bug# 3881
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include "ProviderManagerService.h" #include "ProviderManagerService.h"
  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
   #include <Pegasus/Common/PegasusVersion.h>
 #include <Pegasus/Common/Constants.h> #include <Pegasus/Common/Constants.h>
 #include <Pegasus/Common/CIMMessage.h> #include <Pegasus/Common/CIMMessage.h>
 #include <Pegasus/Common/Thread.h> #include <Pegasus/Common/Thread.h>
 #include <Pegasus/Common/Tracer.h> #include <Pegasus/Common/Tracer.h>
 #include <Pegasus/Common/Logger.h> #include <Pegasus/Common/Logger.h>
 #include <Pegasus/Common/AutoPtr.h> #include <Pegasus/Common/AutoPtr.h>
   #include <Pegasus/Common/Constants.h>
  
 #include <Pegasus/Config/ConfigManager.h> #include <Pegasus/Config/ConfigManager.h>
  
 #include <Pegasus/ProviderManager2/BasicProviderManagerRouter.h> #include <Pegasus/ProviderManager2/BasicProviderManagerRouter.h>
   #include <Pegasus/ProviderManager2/OOPProviderManagerRouter.h>
   #include <Pegasus/ProviderManager2/OperationResponseHandler.h>
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 static const Uint16 _MODULE_OK       = 2;  
 static const Uint16 _MODULE_STOPPING = 9;  
 static const Uint16 _MODULE_STOPPED  = 10;  
   
 inline Boolean _isSupportedRequestType(const Message * message) inline Boolean _isSupportedRequestType(const Message * message)
 { {
     // ATTN: needs implementation     // ATTN: needs implementation
Line 96 
Line 104 
  
     _unloadIdleProvidersBusy = 0;     _unloadIdleProvidersBusy = 0;
  
     _providerManagerRouter =      _basicProviderManagerRouter = 0;
         new BasicProviderManagerRouter(indicationCallback);      _oopProviderManagerRouter = 0;
   
       // Determine which ProviderManagerRouter(s) to use
   
       ConfigManager* configManager = ConfigManager::getInstance();
       Boolean forceProviderProcesses = String::equal(
           configManager->getCurrentValue("forceProviderProcesses"), "true");
   
   #ifdef PEGASUS_DISABLE_PROV_USERCTXT
       if (forceProviderProcesses)
       {
           _oopProviderManagerRouter = new OOPProviderManagerRouter(
               indicationCallback, responseChunkCallback);
       }
       else
       {
           _basicProviderManagerRouter = new BasicProviderManagerRouter(
               indicationCallback, responseChunkCallback);
       }
   #else
       _oopProviderManagerRouter = new OOPProviderManagerRouter(
           indicationCallback, responseChunkCallback);
   
       if (!forceProviderProcesses)
       {
           _basicProviderManagerRouter = new BasicProviderManagerRouter(
               indicationCallback, responseChunkCallback);
       }
   #endif
 } }
  
 ProviderManagerService::~ProviderManagerService(void) ProviderManagerService::~ProviderManagerService(void)
 { {
     delete _providerManagerRouter;      delete _basicProviderManagerRouter;
       delete _oopProviderManagerRouter;
     providerManagerService=NULL;     providerManagerService=NULL;
 } }
  
Line 160 
Line 197 
         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());
                   break;
              }
          }          }
     }     }
     else     else
Line 178 
Line 226 
     return;     return;
 } }
  
   // Note: This method should not throw an exception.  It is used as a thread
   // entry point, and any exceptions thrown are ignored.
 PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL
 ProviderManagerService::handleCimOperation(void * arg) throw()  ProviderManagerService::handleCimOperation(void* arg)
 { {
     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
         "ProviderManagerService::handleCimOperation");         "ProviderManagerService::handleCimOperation");
  
     if(arg == 0)      PEGASUS_ASSERT(arg != 0);
     {  
         // thread started with invalid argument.  
         return(PEGASUS_THREAD_RETURN(1));  
     }  
  
     // get the service from argument     // get the service from argument
     ProviderManagerService * service =     ProviderManagerService * service =
         reinterpret_cast<ProviderManagerService *>(arg);         reinterpret_cast<ProviderManagerService *>(arg);
       PEGASUS_ASSERT(service != 0);
  
       try
       {
     if(service->_incomingQueue.size() == 0)     if(service->_incomingQueue.size() == 0)
     {     {
         PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4,              PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
             "ProviderManagerService::handleCimOperation() called with no "             "ProviderManagerService::handleCimOperation() called with no "
                 "op node in queue");                 "op node in queue");
  
         PEG_METHOD_EXIT();         PEG_METHOD_EXIT();
   
         // thread started with no message in queue.  
         return(PEGASUS_THREAD_RETURN(1));         return(PEGASUS_THREAD_RETURN(1));
     }     }
  
Line 221 
Line 268 
         return(PEGASUS_THREAD_RETURN(1));         return(PEGASUS_THREAD_RETURN(1));
     }     }
  
     AsyncRequest * request = static_cast<AsyncRequest *>(op->_request.next(0));          AsyncRequest* request =
               static_cast<AsyncRequest*>(op->_request.next(0));
  
     if ((request == 0) ||     if ((request == 0) ||
         (request->getType() != async_messages::ASYNC_LEGACY_OP_START))         (request->getType() != async_messages::ASYNC_LEGACY_OP_START))
Line 231 
Line 279 
         return(PEGASUS_THREAD_RETURN(0));         return(PEGASUS_THREAD_RETURN(0));
     }     }
  
     try  
     {  
         Message* legacy =         Message* legacy =
             static_cast<AsyncLegacyOperationStart *>(request)->get_action();             static_cast<AsyncLegacyOperationStart *>(request)->get_action();
  
Line 247 
Line 293 
  
             if (msg != 0)             if (msg != 0)
             {             {
                 AcceptLanguages* langs =                  AcceptLanguageList* langs = new AcceptLanguageList(
                     new AcceptLanguages(msg->acceptLanguages);                      ((AcceptLanguageListContainer)msg->operationContext.get(
                           AcceptLanguageListContainer::NAME)).getLanguages());
                 Thread::setLanguages(langs);                 Thread::setLanguages(langs);
             }             }
             else             else
Line 259 
Line 306 
             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();
Line 284 
Line 337 
     PEGASUS_ASSERT(async != 0);     PEGASUS_ASSERT(async != 0);
  
     Message * response = 0;     Message * response = 0;
       Boolean consumerLookupFailed = false;
   
       if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE)
       {
           //
           // Get a ProviderIdContainer for ExportIndicationRequestMessage.
           // Note: This can be removed when the CIMExportRequestDispatcher
           // is updated to add the ProviderIdContainer to the message.
           //
           CIMInstance providerModule;
           CIMInstance provider;
           const CIMExportIndicationRequestMessage* expRequest =
               dynamic_cast<const CIMExportIndicationRequestMessage*>(request);
           if (_providerRegistrationManager->lookupIndicationConsumer(
                   expRequest->destinationPath, provider, providerModule))
           {
               request->operationContext.insert(
                   ProviderIdContainer(providerModule, provider));
           }
           else
           {
               consumerLookupFailed = true;
           }
       }
  
     if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) ||      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) ||         (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))
Line 299 
Line 383 
         //         //
         CIMInstance providerModule;         CIMInstance providerModule;
  
         CIMIndicationRequestMessage* indRequest =  
             dynamic_cast<CIMIndicationRequestMessage*>(request);  
         if (indRequest != 0)  
         {  
             providerModule = indRequest->providerModule;  
         }  
         else if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE)  
         {  
             // Get a ProviderIdContainer for ExportIndicationRequestMessage  
             ProviderIdContainer pidc = _getProviderIdContainer(request);  
             request->operationContext.insert(pidc);  
   
             providerModule = pidc.getModule();  
         }  
         else  
         {  
             // The provider ID container is added to the OperationContext             // The provider ID container is added to the OperationContext
             // by the CIMOperationRequestDispatcher for all CIM operation             // by the CIMOperationRequestDispatcher for all CIM operation
             // requests to providers, so it does not need to be added again.             // requests to providers, so it does not need to be added again.
Line 323 
Line 391 
             ProviderIdContainer pidc =             ProviderIdContainer pidc =
                 request->operationContext.get(ProviderIdContainer::NAME);                 request->operationContext.get(ProviderIdContainer::NAME);
             providerModule = pidc.getModule();             providerModule = pidc.getModule();
         }  
  
         //         //
         // Check if the target provider is disabled         // Check if the target provider is disabled
Line 336 
Line 403 
  
         for(Uint32 i = 0; i < operationalStatus.size(); i++)         for(Uint32 i = 0; i < operationalStatus.size(); i++)
         {         {
             if ((operationalStatus[i] == _MODULE_STOPPED) ||              if ((operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED) ||
                 (operationalStatus[i] == _MODULE_STOPPING))                  (operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING))
             {             {
                 moduleDisabled = true;                 moduleDisabled = true;
                 break;                 break;
Line 356 
Line 423 
                     "ProviderManager.ProviderManagerService.PROVIDER_BLOCKED",                     "ProviderManager.ProviderManagerService.PROVIDER_BLOCKED",
                     "provider blocked."));                     "provider blocked."));
             response = cimResponse;             response = cimResponse;
   
                STAT_COPYDISPATCHER
         }         }
         else         else
         {         {
             //             //
             // Forward the request to the appropriate ProviderManagerRouter             // Forward the request to the appropriate ProviderManagerRouter
             //             //
             response = _providerManagerRouter->processMessage(request);              response = _processMessage(request);
         }         }
     }     }
     else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE)     else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE)
Line 376 
Line 445 
         try         try
         {         {
             // Forward the request to the ProviderManager             // Forward the request to the ProviderManager
             response = _providerManagerRouter->processMessage(request);              response = _processMessage(request);
  
             // If successful, update provider module status to OK             // If successful, update provider module status to OK
             // ATTN: Use CIMEnableModuleResponseMessage operationalStatus?             // ATTN: Use CIMEnableModuleResponseMessage operationalStatus?
Line 385 
Line 454 
             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 397 
Line 467 
                     .getValue();                     .getValue();
             itValue.get(operationalStatus);             itValue.get(operationalStatus);
  
             if (response != 0)  
             {  
                 delete response;                 delete response;
             }  
  
             response = new CIMEnableModuleResponseMessage(             response = new CIMEnableModuleResponseMessage(
                 request->messageId,                 request->messageId,
Line 424 
Line 491 
             if (updateModuleStatus)             if (updateModuleStatus)
             {             {
                 _updateProviderModuleStatus(                 _updateProviderModuleStatus(
                     providerModule, _MODULE_OK, _MODULE_STOPPING);                      providerModule, CIM_MSE_OPSTATUS_VALUE_OK,
                       CIM_MSE_OPSTATUS_VALUE_STOPPING);
             }             }
  
             // Forward the request to the ProviderManager             // Forward the request to the ProviderManager
             response = _providerManagerRouter->processMessage(request);              response = _processMessage(request);
  
             // Update provider module status based on success or failure             // Update provider module status based on success or failure
             if (updateModuleStatus)             if (updateModuleStatus)
Line 439 
Line 507 
                 {                 {
                     // 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 447 
Line 516 
                     // 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 462 
Line 531 
                     .getValue();                     .getValue();
             itValue.get(operationalStatus);             itValue.get(operationalStatus);
  
             if (response != 0)  
             {  
                 delete response;                 delete response;
             }  
  
             response = new CIMDisableModuleResponseMessage(             response = new CIMDisableModuleResponseMessage(
                 request->messageId,                 request->messageId,
Line 476 
Line 542 
     }     }
     else     else
     {     {
         response = _providerManagerRouter->processMessage(request);          response = _processMessage(request);
     }     }
  
     AsyncLegacyOperationResult * async_result =     AsyncLegacyOperationResult * async_result =
Line 491 
Line 557 
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
 } }
  
 void ProviderManagerService::unloadIdleProviders()  void ProviderManagerService::responseChunkCallback(
       CIMRequestMessage* request,
       CIMResponseMessage* response)
 { {
     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
         "ProviderManagerService::unloadIdleProviders");          "ProviderManagerService::responseChunkCallback");
  
     // Ensure that only one _unloadIdleProvidersHandler thread runs at a time      try
     _unloadIdleProvidersBusy++;  
     if ((_unloadIdleProvidersBusy.value() == 1) &&  
         (_thread_pool->allocate_and_awaken(  
              (void*)this, ProviderManagerService::_unloadIdleProvidersHandler)))  
     {     {
         // _unloadIdleProvidersBusy is decremented in          // only incomplete messages are processed because the caller ends up
         // _unloadIdleProvidersHandler          // 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);
   
           PEGASUS_ASSERT(service);
   
           // the last chunk MUST be sent last, so use execute the callback
           // not all chunks are going through the dispatcher's chunk
           // resequencer, so this must be a synchronous call here
           // After the call is done, response and asyncResponse are now invalid
           // as they have been sent and deleted externally
   
           op->_async_callback(op, service, op->_callback_ptr);
     }     }
     else      catch(Exception &e)
     {     {
         // If we fail to allocate a thread, don't retry now.          PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
         _unloadIdleProvidersBusy--;              "Exception in ProviderManagerService::responseChunkCallback: " +
                   e.getMessage() + ".  Chunk not delivered.");
       }
       catch(...)
       {
           PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
               "Exception in ProviderManagerService::responseChunkCallback.  "
                   "Chunk not delivered.");
     }     }
  
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
 } }
  
 PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL  Message* ProviderManagerService::_processMessage(CIMRequestMessage* request)
 ProviderManagerService::_unloadIdleProvidersHandler(void* arg) throw()  
 {  
     try  
     {     {
         PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,      Message* response = 0;
             "ProviderManagerService::unloadIdleProvidersHandler");  
   
         ProviderManagerService* myself =  
             reinterpret_cast<ProviderManagerService*>(arg);  
  
         try      if ((request->getType() == CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE) ||
           (request->getType() ==
               CIM_SUBSCRIPTION_INIT_COMPLETE_REQUEST_MESSAGE) ||
           (request->getType() == CIM_NOTIFY_CONFIG_CHANGE_REQUEST_MESSAGE))
         {         {
             myself->_providerManagerRouter->unloadIdleProviders();          if (_basicProviderManagerRouter)
         }  
         catch (...)  
         {         {
             // Ignore errors              response = _basicProviderManagerRouter->processMessage(request);
             PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,  
                 "Unexpected exception in _unloadIdleProvidersHandler");  
         }         }
  
         myself->_unloadIdleProvidersBusy--;          if (_oopProviderManagerRouter)
         PEG_METHOD_EXIT();  
     }  
     catch (...)  
     {     {
         // Ignore errors              // Note: These responses do not contain interesting data, so just
         PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,              // use the last one.
             "Unexpected exception in _unloadIdleProvidersHandler");              delete response;
     }  
  
     return(PEGASUS_THREAD_RETURN(0));              response = _oopProviderManagerRouter->processMessage(request);
 } }
       }
 ProviderIdContainer ProviderManagerService::_getProviderIdContainer(      else
     const CIMRequestMessage* message)  
 { {
     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,  
         "ProviderManagerService::_getProviderIdContainer");  
   
     CIMInstance providerModule;     CIMInstance providerModule;
     CIMInstance provider;  
  
     switch (message->getType())          if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE)
     {     {
     case CIM_GET_CLASS_REQUEST_MESSAGE:              CIMEnableModuleRequestMessage* emReq =
     case CIM_DELETE_CLASS_REQUEST_MESSAGE:                  dynamic_cast<CIMEnableModuleRequestMessage*>(request);
     case CIM_CREATE_CLASS_REQUEST_MESSAGE:              providerModule = emReq->providerModule;
     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 if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE)
     case CIM_EXEC_QUERY_REQUEST_MESSAGE:  
     {     {
         // Look up instance query provider              CIMDisableModuleRequestMessage* dmReq =
         const CIMOperationRequestMessage* request =                  dynamic_cast<CIMDisableModuleRequestMessage*>(request);
             dynamic_cast<const CIMOperationRequestMessage*>(message);              providerModule = dmReq->providerModule;
         Boolean hasNoQuery;  
         _providerRegistrationManager->lookupInstanceProvider(  
             request->nameSpace, request->className, provider, providerModule,  
             0, &hasNoQuery);  
         // We shouldn't have gotten this far if this isn't a query provider  
         PEGASUS_ASSERT(!hasNoQuery);  
         break;  
     }     }
           else
     case CIM_ASSOCIATORS_REQUEST_MESSAGE:  
     {     {
         // Look up association provider              ProviderIdContainer pidc =
         const CIMAssociatorsRequestMessage* request =                  request->operationContext.get(ProviderIdContainer::NAME);
             dynamic_cast<const CIMAssociatorsRequestMessage*>(message);              providerModule = pidc.getModule();
         Array<CIMInstance> providerModules;  
         Array<CIMInstance> providers;  
         _providerRegistrationManager->lookupAssociationProvider(  
             request->nameSpace, request->assocClass,  
             providers, providerModules);  
         providerModule = providerModules[0];  
         provider = providers[0];  
         break;  
     }     }
  
     case CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE:          Uint16 userContext = 0;
           Uint32 pos = providerModule.findProperty(
               PEGASUS_PROPERTYNAME_MODULE_USERCONTEXT);
           if (pos != PEG_NOT_FOUND)
           {
               providerModule.getProperty(pos).getValue().get(userContext);
           }
   
           // Forward the request to the appropriate ProviderManagerRouter, based
           // on the CIM Server configuration and the UserContext setting.
   
           ConfigManager* configManager = ConfigManager::getInstance();
           Boolean forceProviderProcesses = String::equal(
               configManager->getCurrentValue("forceProviderProcesses"), "true");
   
           if (forceProviderProcesses
   #ifndef PEGASUS_DISABLE_PROV_USERCTXT
               || (userContext == PG_PROVMODULE_USERCTXT_REQUESTOR)
               || (userContext == PG_PROVMODULE_USERCTXT_DESIGNATED)
               || ((userContext == PG_PROVMODULE_USERCTXT_PRIVILEGED) &&
                   !System::isPrivilegedUser(System::getEffectiveUserName()))
   #endif
              )
     {     {
         // Look up association provider              response = _oopProviderManagerRouter->processMessage(request);
         const 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;  
     }     }
           else
     case CIM_REFERENCES_REQUEST_MESSAGE:  
     {     {
         // Look up association provider              response = _basicProviderManagerRouter->processMessage(request);
         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:      return response;
     {  
         // 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:  void ProviderManagerService::unloadIdleProviders()
     {     {
         // Look up method provider      PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
         const CIMInvokeMethodRequestMessage* request =          "ProviderManagerService::unloadIdleProviders");
             dynamic_cast<const CIMInvokeMethodRequestMessage*>(message);      ThreadStatus rtn = PEGASUS_THREAD_OK;
         _providerRegistrationManager->lookupMethodProvider(      // Ensure that only one _unloadIdleProvidersHandler thread runs at a time
             request->nameSpace, request->className, request->methodName,      _unloadIdleProvidersBusy++;
             provider, providerModule);      if ((_unloadIdleProvidersBusy.get() == 1) &&
         break;          ((rtn = _thread_pool->allocate_and_awaken(
                (void*)this, ProviderManagerService::_unloadIdleProvidersHandler))==PEGASUS_THREAD_OK))
       {
           // _unloadIdleProvidersBusy is decremented in
           // _unloadIdleProvidersHandler
     }     }
       else
     case CIM_EXPORT_INDICATION_REQUEST_MESSAGE:  
     {     {
         const CIMExportIndicationRequestMessage* request =          // If we fail to allocate a thread, don't retry now.
             dynamic_cast<const CIMExportIndicationRequestMessage*>(message);          _unloadIdleProvidersBusy--;
         _providerRegistrationManager->lookupIndicationConsumer(  
             request->destinationPath, provider, providerModule);  
         break;  
     }     }
       if (rtn != PEGASUS_THREAD_OK)
       {
           Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
               "Not enough threads to unload idle providers.");
  
     case CIM_ENABLE_INDICATIONS_REQUEST_MESSAGE:          Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
     case CIM_DISABLE_INDICATIONS_REQUEST_MESSAGE:              "Could not allocate thread for %s to unload idle providers.",
     case CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE:              getQueueName());
     case CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE:      }
     case CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE:      PEG_METHOD_EXIT();
     {  
         // Provider information is already in the message  
         const CIMIndicationRequestMessage* request =  
             dynamic_cast<const CIMIndicationRequestMessage*>(message);  
         providerModule = request->providerModule;  
         provider = request->provider;  
         break;  
     }     }
  
     case CIM_ENABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE:  PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL
     case CIM_MODIFY_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE:  ProviderManagerService::_unloadIdleProvidersHandler(void* arg) throw()
     case CIM_DISABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE:  {
     case CIM_PROCESS_INDICATION_REQUEST_MESSAGE:      try
     case CIM_HANDLE_INDICATION_REQUEST_MESSAGE:      {
     case CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE:          PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
     case CIM_NOTIFY_PROVIDER_TERMINATION_REQUEST_MESSAGE:              "ProviderManagerService::unloadIdleProvidersHandler");
         // These messages are not handled by the ProviderManagerService  
         PEGASUS_ASSERT(0);  
         break;  
  
     case CIM_DISABLE_MODULE_REQUEST_MESSAGE:          ProviderManagerService* myself =
     case CIM_ENABLE_MODULE_REQUEST_MESSAGE:              reinterpret_cast<ProviderManagerService*>(arg);
     case CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE:  
         // These messages are handled specially by the ProviderManagerService  
         PEGASUS_ASSERT(0);  
         break;  
  
     case CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE:          if (myself->_basicProviderManagerRouter)
     {     {
         // Provider information is already in the message              try
         const CIMInitializeProviderRequestMessage* request =              {
             dynamic_cast<const CIMInitializeProviderRequestMessage*>(message);                  myself->_basicProviderManagerRouter->unloadIdleProviders();
               }
         const ProviderIdContainer container =              catch (...)
             request->operationContext.get(ProviderIdContainer::NAME);              {
         providerModule = container.getModule();                  // Ignore errors
         provider = container.getProvider();                  PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
         break;                      "Unexpected exception from "
                           "BasicProviderManagerRouter::_unloadIdleProviders");
     }     }
   
     }     }
  
     PEGASUS_ASSERT(!providerModule.isUninitialized());          if (myself->_oopProviderManagerRouter)
     PEGASUS_ASSERT(!provider.isUninitialized());          {
               try
               {
                   myself->_oopProviderManagerRouter->unloadIdleProviders();
               }
               catch (...)
               {
                   // Ignore errors
                   PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
                       "Unexpected exception from "
                           "OOPProviderManagerRouter::_unloadIdleProviders");
               }
           }
  
           myself->_unloadIdleProvidersBusy--;
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
     return ProviderIdContainer(providerModule, provider);      }
       catch (...)
       {
           // Ignore errors
           PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
               "Unexpected exception in _unloadIdleProvidersHandler");
       }
   
       return(PEGASUS_THREAD_RETURN(0));
 } }
  
 // Updates the providerModule instance and the ProviderRegistrationManager // Updates the providerModule instance and the ProviderRegistrationManager
Line 800 
Line 838 
 void ProviderManagerService::indicationCallback( void ProviderManagerService::indicationCallback(
     CIMProcessIndicationRequestMessage* request)     CIMProcessIndicationRequestMessage* request)
 { {
       try
       {
           AcceptLanguageListContainer cntr = request->operationContext.get(AcceptLanguageListContainer::NAME);
       }catch(const Exception &)
       {
           request->operationContext.insert(AcceptLanguageListContainer(AcceptLanguageList()));
       }
   
     if (_indicationServiceQueueId == PEG_NOT_FOUND)     if (_indicationServiceQueueId == PEG_NOT_FOUND)
     {     {
         Array<Uint32> serviceIds;         Array<Uint32> serviceIds;
Line 823 
Line 869 
         _indicationServiceQueueId);         _indicationServiceQueueId);
  
     providerManagerService->SendForget(asyncRequest);     providerManagerService->SendForget(asyncRequest);
   
   
   
   
   #ifdef PEGASUS_INDICATIONS_Q_THRESHOLD
   
       // See Comments in config.mak asociated with
       //  PEGASUS_INDICATIONS_Q_THRESHOLD
       //
       // if INDICATIONS_Q_STALL THRESHOLD is gt 0
       // then if there are over INDICATIONS_Q_STALL_THRESHOLD
       //           indications in the queue
       //      then force this provider to sleep until the queue count
       //      is lower than INDICATIONS_Q_RESUME_THRESHOLD
   
   static Mutex   indicationThresholdReportedLock;
   static Boolean indicationThresholdReported = false;
   
   #define INDICATIONS_Q_STALL_THRESHOLD PEGASUS_INDICATIONS_Q_THRESHOLD
   #define INDICATIONS_Q_RESUME_THRESHOLD (int)(PEGASUS_INDICATIONS_Q_THRESHOLD*.90)
   #define INDICATIONS_Q_STALL_DURATION 250 // milli-seconds
   
       MessageQueue * indicationsQueue = MessageQueue::lookup(_indicationServiceQueueId);
   
       if (((MessageQueueService *)indicationsQueue)->getIncomingCount() > INDICATIONS_Q_STALL_THRESHOLD)
       {
           AutoMutex indicationThresholdReportedAutoMutex(indicationThresholdReportedLock);
           if (!indicationThresholdReported)
           {
               indicationThresholdReported = true;
               indicationThresholdReportedAutoMutex.unlock();
   
               // make log entry to record que max exceeded
   
               Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
                   "Indication generation stalled: maximum queue count ($0) exceeded.",
                   INDICATIONS_Q_STALL_THRESHOLD);
           }
           else
           {
               indicationThresholdReportedAutoMutex.unlock();
           }
   
           while (((MessageQueueService *)indicationsQueue)->getIncomingCount() > INDICATIONS_Q_RESUME_THRESHOLD)
           {
               pegasus_sleep(INDICATIONS_Q_STALL_DURATION);
           }
   
           AutoMutex indicationThresholdReportedAutoMutex1(indicationThresholdReportedLock);
           //        indicationThresholdReportedLock.lock(pegasus_thread_self());
           if(indicationThresholdReported)
           {
               indicationThresholdReported = false;
               indicationThresholdReportedAutoMutex1.unlock();
   
               Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
                     "Indication generation resumed: current queue count = $0",
                     ((MessageQueueService *)indicationsQueue)->getIncomingCount() );
   
           }
           else
           {
               indicationThresholdReportedAutoMutex1.unlock();
           }
       }
   #endif /* INDICATIONS_Q_STALL_THRESHOLD */
   
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.46  
changed lines
  Added in v.1.78

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2