(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.13 and 1.73.4.1

version 1.13, 2003/10/17 04:02:11 version 1.73.4.1, 2006/01/18 17:38:03
Line 1 
Line 1 
 //%/////////////////////////////////////////////////////////////////////////////  //%2005////////////////////////////////////////////////////////////////////////
 // //
 // 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.
   // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; VERITAS Software Corporation; The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 28 
Line 34 
 //              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)
   //              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/Tracer.h> #include <Pegasus/Common/Tracer.h>
 #include <Pegasus/Common/Logger.h> #include <Pegasus/Common/Logger.h>
 #include <Pegasus/Common/Destroyer.h>  #include <Pegasus/Common/AutoPtr.h>
   #include <Pegasus/Common/Constants.h>
  
 #include <Pegasus/Config/ConfigManager.h> #include <Pegasus/Config/ConfigManager.h>
  
 PEGASUS_NAMESPACE_BEGIN  #include <Pegasus/ProviderManager2/BasicProviderManagerRouter.h>
   #include <Pegasus/ProviderManager2/OOPProviderManagerRouter.h>
 // BEGIN TEMP SECTION  #include <Pegasus/ProviderManager2/OperationResponseHandler.h>
 class ProviderManagerContainer  
 {  
 public:  
     ProviderManagerContainer(const String & physicalName, const String & logicalName, const String & interfaceName)  
     {  
         #if defined(PEGASUS_OS_TYPE_WINDOWS)  
         _physicalName = physicalName + String(".dll");  
         #elif defined(PEGASUS_OS_HPUX) && defined(PEGASUS_PLATFORM_HPUX_PARISC_ACC)  
         _physicalName = ConfigManager::getHomedPath(ConfigManager::getInstance()->getCurrentValue("providerDir"));  
         _physicalName.append(String("/lib") + physical + String(".sl"));  
         #elif defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_HPUX_PARISC_ACC)  
         _physicalName = ConfigManager::getHomedPath(ConfigManager::getInstance()->getCurrentValue("providerDir"));  
         _physicalName.append(String("/lib") + physical + String(".so"));  
         #elif defined(PEGASUS_OS_OS400)  
         _physicalName = physicalName;  
         #else  
         _physicalName = ConfigManager::getHomedPath(ConfigManager::getInstance()->getCurrentValue("providerDir"));  
         _physicalName.append(String("/lib") + physical + String(".so"));  
         #endif  
   
         _logicalName = logicalName;  
   
         _interfaceName = interfaceName;  
   
         _module = ProviderManagerModule(_physicalName);  
   
         _module.load();  
   
         _manager = _module.getProviderManager(_logicalName);  
     }  
   
     ~ProviderManagerContainer(void)  
     {  
         _module.unload();  
     }  
   
     ProviderManager & getProviderManager(void)  
     {  
         return(*_manager);  
     }  
   
     String & getPhysicalName(void)  
     {  
         return(_physicalName);  
     }  
   
     String & getLogicalName(void)  
     {  
         return(_logicalName);  
     }  
   
     String & getInterfaceName(void)  
     {  
         return(_interfaceName);  
     }  
   
 private:  
     String _physicalName;  
     String _logicalName;  
     String _interfaceName;  
  
     ProviderManagerModule _module;  PEGASUS_NAMESPACE_BEGIN
     ProviderManager * _manager;  
   
 };  
   
 static Array<ProviderManagerContainer> _providerManagers;  
 // END TEMP SECTION  
  
 inline Boolean _isSupportedRequestType(const Message * message) inline Boolean _isSupportedRequestType(const Message * message)
 { {
Line 132 
Line 81 
     return(false);     return(false);
 } }
  
   ProviderManagerService* ProviderManagerService::providerManagerService=NULL;
   Uint32 ProviderManagerService::_indicationServiceQueueId = PEG_NOT_FOUND;
   
 ProviderManagerService::ProviderManagerService(void) ProviderManagerService::ProviderManagerService(void)
     : MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP)     : MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP)
 { {
       providerManagerService=this;
 } }
  
 ProviderManagerService::ProviderManagerService(ProviderRegistrationManager * providerRegistrationManager)  ProviderManagerService::ProviderManagerService(
           ProviderRegistrationManager * providerRegistrationManager,
           CIMRepository * repository)
     : MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP)     : MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP)
 { {
     SetProviderRegistrationManager(providerRegistrationManager);      providerManagerService=this;
       _repository=repository;
  
     // ATTN: this section is a temporary solution to populate the list of enabled      _providerRegistrationManager = providerRegistrationManager;
     // provider managers for a given distribution. it includes another temporary  
     // solution for converting a generic file name into a file name useable by      _unloadIdleProvidersBusy = 0;
     // each platform.  
       _basicProviderManagerRouter = 0;
     // BEGIN TEMP SECTION      _oopProviderManagerRouter = 0;
     //#if defined(PEGASUS_OS_OS400)  
     //_providerManagers.append(ProviderManagerContainer("QSYS/??????????", "INTERNAL", "INTERNAL"));      // Determine which ProviderManagerRouter(s) to use
     //#else  
     //_providerManager.append(ProviderManagerContainer("InternalProviderManager", "DEFAULT", "INTERNAL"));  
     //#endif  
   
     /*  
     #if defined(ENABLE_DEFAULT_PROVIDER_MANAGER)  
     #if defined(PEGASUS_OS_OS400)  
     _providerManagers.append(ProviderManagerContainer("QSYS/QYCMDFTPVM", "DEFAULT", "C++Default"));  
     #else  
     _providerManagers.append(ProviderManagerContainer("DefaultProviderManager", "DEFAULT", "C++Default"));  
     #endif  
     #endif  
  
     #if defined(ENABLE_CMPI_PROVIDER_MANAGER)      ConfigManager* configManager = ConfigManager::getInstance();
     #if defined(PEGASUS_OS_OS400)      Boolean forceProviderProcesses = String::equal(
     _providerManagers.append(ProviderManagerContainer("QSYS/QYCMCMPIPM", "CMPI", "CMPI"));          configManager->getCurrentValue("forceProviderProcesses"), "true");
   
   #ifdef PEGASUS_DISABLE_PROV_USERCTXT
       if (forceProviderProcesses)
       {
           _oopProviderManagerRouter =
               new OOPProviderManagerRouter(indicationCallback);
       }
       else
       {
           _basicProviderManagerRouter =
               new BasicProviderManagerRouter(indicationCallback);
       }
     #else     #else
     _providerManagers.append(ProviderManagerContainer("CMPIProviderManager", "CMPI", "CMPI"));      _oopProviderManagerRouter =
     #endif          new OOPProviderManagerRouter(indicationCallback);
   
       if (!forceProviderProcesses)
       {
           _basicProviderManagerRouter =
               new BasicProviderManagerRouter(indicationCallback);
       }
     #endif     #endif
     */  
     // END TEMP SECTION  
 } }
  
 ProviderManagerService::~ProviderManagerService(void) ProviderManagerService::~ProviderManagerService(void)
 { {
       delete _basicProviderManagerRouter;
       delete _oopProviderManagerRouter;
       providerManagerService=NULL;
 } }
  
 Boolean ProviderManagerService::messageOK(const Message * message) Boolean ProviderManagerService::messageOK(const Message * message)
Line 232 
Line 195 
         request->op->processing();         request->op->processing();
  
         _incomingQueue.enqueue(request->op);         _incomingQueue.enqueue(request->op);
           ThreadStatus rtn = PEGASUS_THREAD_OK;
           while (( rtn =_thread_pool->allocate_and_awaken(
                        (void *)this, ProviderManagerService::handleCimOperation)) != PEGASUS_THREAD_OK)
           {
              if (rtn==PEGASUS_THREAD_INSUFFICIENT_RESOURCES)
                  pegasus_yield();
              else
              {
                  Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
                           "Not enough threads to service provider manager." );
  
         _thread_pool->allocate_and_awaken((void *)this, ProviderManagerService::handleCimOperation);                 Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
                           "Could not allocate thread for %s.",
                            getQueueName());
                      break;
              }
           }
     }     }
     else     else
     {     {
Line 246 
Line 224 
     return;     return;
 } }
  
 /*  // Note: This method should not throw an exception.  It is used as a thread
 PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL ProviderManagerService::handleServiceOperation(void * arg) throw()  // entry point, and any exceptions thrown are ignored.
 {  PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL
     // get the service from argument  ProviderManagerService::handleCimOperation(void* arg)
     ProviderManagerService * service = reinterpret_cast<ProviderManagerService *>(arg);  
   
     PEGASUS_ASSERT(service != 0);  
   
     // get message from service queue  
     Message * message = service->_incomingQueue.dequeue();  
   
     PEGASUS_ASSERT(message != 0);  
   
     if(service->_incomingQueue.size() == 0)  
     {  
         PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4,  
             "ProviderManagerService::handleCimOperation() called with no op node in queue" );  
   
         PEG_METHOD_EXIT();  
   
         // thread started with no message in queue.  
         return(PEGASUS_THREAD_RETURN(1));  
     }  
   
     AsyncOpNode * op = service->_incomingQueue.dequeue();  
   
     PEGASUS_ASSERT(op != 0 );  
   
     if(op->_request.count() == 0)  
     {  
         MessageQueue * queue = MessageQueue::lookup(op->_source_queue);  
   
         PEGASUS_ASSERT(queue != 0);  
   
         PEG_METHOD_EXIT();  
   
         // no request in op node  
         return(PEGASUS_THREAD_RETURN(1));  
     }  
   
     return(0);  
 }  
 */  
   
 PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL ProviderManagerService::handleCimOperation(void * arg) throw()  
 { {
     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderManagerService::handleCimOperation");      PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
           "ProviderManagerService::handleCimOperation");
  
     if(arg == 0)      PEGASUS_ASSERT(arg != 0);
     {  
         // thread started with invalid argument.  
         return(PEGASUS_THREAD_RETURN(1));  
     }  
  
     // get the service from argument     // get the service from argument
     ProviderManagerService * service = reinterpret_cast<ProviderManagerService *>(arg);      ProviderManagerService* service =
           reinterpret_cast<ProviderManagerService *>(arg);
       PEGASUS_ASSERT(service != 0);
  
       try
       {
     if(service->_incomingQueue.size() == 0)     if(service->_incomingQueue.size() == 0)
     {     {
         PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4,              PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
             "ProviderManagerService::handleCimOperation() called with no op node in queue" );                  "ProviderManagerService::handleCimOperation() called with no "
                       "op node in queue");
  
         PEG_METHOD_EXIT();         PEG_METHOD_EXIT();
   
         // thread started with no message in queue.  
         return(PEGASUS_THREAD_RETURN(1));         return(PEGASUS_THREAD_RETURN(1));
     }     }
  
Line 318 
Line 255 
  
     if((op == 0) || (op->_request.count() == 0))     if((op == 0) || (op->_request.count() == 0))
     {     {
               // ATTN: This may dereference a null pointer!
         MessageQueue * queue = MessageQueue::lookup(op->_source_queue);         MessageQueue * queue = MessageQueue::lookup(op->_source_queue);
  
         PEGASUS_ASSERT(queue != 0);         PEGASUS_ASSERT(queue != 0);
Line 328 
Line 266 
         return(PEGASUS_THREAD_RETURN(1));         return(PEGASUS_THREAD_RETURN(1));
     }     }
  
     AsyncRequest * request = static_cast<AsyncRequest *>(op->_request.next(0));          AsyncRequest* request =
               static_cast<AsyncRequest*>(op->_request.next(0));
  
     if((request == 0) || (request->getType() != async_messages::ASYNC_LEGACY_OP_START))          if ((request == 0) ||
               (request->getType() != async_messages::ASYNC_LEGACY_OP_START))
     {     {
         // reply with NAK         // reply with NAK
   
         PEG_METHOD_EXIT();         PEG_METHOD_EXIT();
   
         return(PEGASUS_THREAD_RETURN(0));         return(PEGASUS_THREAD_RETURN(0));
     }     }
  
     try          Message* legacy =
     {              static_cast<AsyncLegacyOperationStart *>(request)->get_action();
         Message * legacy = static_cast<AsyncLegacyOperationStart *>(request)->get_action();  
  
         if(_isSupportedRequestType(legacy))         if(_isSupportedRequestType(legacy))
         {         {
             Destroyer<Message> xmessage(legacy);              AutoPtr<Message> xmessage(legacy);
  
             // Set the client's requested language into this service thread.             // Set the client's requested language into this service thread.
             // This will allow functions in this service to return messages             // This will allow functions in this service to return messages
Line 354 
Line 291 
  
             if(msg != 0)             if(msg != 0)
             {             {
                 AcceptLanguages * langs = new AcceptLanguages(msg->acceptLanguages);                  AcceptLanguageList* langs = new AcceptLanguageList(
                       ((AcceptLanguageListContainer)msg->operationContext.get(
                           AcceptLanguageListContainer::NAME)).getLanguages());
                 Thread::setLanguages(langs);                 Thread::setLanguages(langs);
             }             }
             else             else
Line 366 
Line 304 
             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 376 
Line 320 
     return(PEGASUS_THREAD_RETURN(0));     return(PEGASUS_THREAD_RETURN(0));
 } }
  
 void ProviderManagerService::handleCimRequest(AsyncOpNode * op, const Message * message)  void ProviderManagerService::handleCimRequest(
       AsyncOpNode * op,
       Message * message)
 { {
     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderManagerService::handleCimRequest");      PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
           "ProviderManagerService::handleCimRequest");
  
     // ATTN: ensure message is a request???      CIMRequestMessage * request = dynamic_cast<CIMRequestMessage *>(message);
     CIMMessage * request = dynamic_cast<CIMMessage *>(const_cast<Message *>(message));      PEGASUS_ASSERT(request != 0);
  
     // get request from op node     // get request from op node
     AsyncRequest * async = static_cast<AsyncRequest *>(op->_request.next(0));     AsyncRequest * async = static_cast<AsyncRequest *>(op->_request.next(0));
       PEGASUS_ASSERT(async != 0);
     PEGASUS_ASSERT((request != 0) && (async != 0));  
  
     Message * response = 0;     Message * response = 0;
       Boolean consumerLookupFailed = false;
  
     // get namespace and class name from message      if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE)
     String nameSpace;      {
     String className;          //
           // 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;
           }
       }
  
     switch(message->getType())      if (consumerLookupFailed)
     {     {
     case CIM_GET_CLASS_REQUEST_MESSAGE:          CIMResponseMessage* cimResponse = request->buildResponse();
           cimResponse->cimException = PEGASUS_CIM_EXCEPTION(
               CIM_ERR_NOT_SUPPORTED, String::EMPTY);
           response = cimResponse;
       }
       else if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) ||
           (dynamic_cast<CIMIndicationRequestMessage*>(request) != 0) ||
           (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) ||
           (request->getType() == CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE))
         {         {
             const CIMGetClassRequestMessage * p = dynamic_cast<const CIMGetClassRequestMessage *>(message);          // Handle CIMOperationRequestMessage, CIMExportIndicationRequestMessage,
           // CIMIndicationRequestMessage, and CIMInitializeProviderRequestMessage.
           // (These should be blocked when the provider module is disabled.)
  
             PEGASUS_ASSERT(p != 0);          //
           // Get the provider module instance to check for a disabled module
           //
           CIMInstance providerModule;
  
             nameSpace = p->nameSpace.getString();          // The provider ID container is added to the OperationContext
             className = p->className.getString();          // 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();
  
         break;          //
     case CIM_ENUMERATE_CLASSES_REQUEST_MESSAGE:          // 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++)
         {         {
             const CIMEnumerateClassesRequestMessage * p = dynamic_cast<const CIMEnumerateClassesRequestMessage *>(message);              if ((operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED) ||
                   (operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING))
               {
                   moduleDisabled = true;
                   break;
               }
           }
  
             PEGASUS_ASSERT(p != 0);          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;
  
             nameSpace = p->nameSpace.getString();               STAT_COPYDISPATCHER
             className = p->className.getString();  
         }         }
           else
           {
               //
               // Forward the request to the appropriate ProviderManagerRouter
               //
               response = _processMessage(request);
           }
       }
       else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE)
       {
           // Handle CIMEnableModuleRequestMessage
           CIMEnableModuleRequestMessage * emReq =
               dynamic_cast<CIMEnableModuleRequestMessage*>(request);
  
         break;          CIMInstance providerModule = emReq->providerModule;
     case CIM_ENUMERATE_CLASS_NAMES_REQUEST_MESSAGE:  
           try
         {         {
             const CIMEnumerateClassNamesRequestMessage * p = dynamic_cast<const CIMEnumerateClassNamesRequestMessage *>(message);              // Forward the request to the ProviderManager
               response = _processMessage(request);
  
             PEGASUS_ASSERT(p != 0);              // If successful, update provider module status to OK
               // ATTN: Use CIMEnableModuleResponseMessage operationalStatus?
               CIMEnableModuleResponseMessage * emResp =
                   dynamic_cast<CIMEnableModuleResponseMessage*>(response);
               if (emResp->cimException.getCode() == CIM_ERR_SUCCESS)
               {
                   _updateProviderModuleStatus(
                       providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPED,
                       CIM_MSE_OPSTATUS_VALUE_OK);
               }
           }
           catch (Exception& e)
           {
               // Get the OperationalStatus property from the provider module
               Array<Uint16> operationalStatus;
               CIMValue itValue = emReq->providerModule.getProperty(
                   emReq->providerModule.findProperty("OperationalStatus"))
                       .getValue();
               itValue.get(operationalStatus);
  
             nameSpace = p->nameSpace.getString();              if (response != 0)
             className = p->className.getString();              {
                   delete response;
         }         }
  
         break;              response = new CIMEnableModuleResponseMessage(
     case CIM_CREATE_CLASS_REQUEST_MESSAGE:                  request->messageId,
                   CIMException(CIM_ERR_FAILED, e.getMessage()),
                   request->queueIds.copyAndPop(),
                   operationalStatus);
           }
       }
       else if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE)
         {         {
             const CIMCreateClassRequestMessage * p = dynamic_cast<const CIMCreateClassRequestMessage *>(message);          // Handle CIMDisableModuleRequestMessage
           CIMDisableModuleRequestMessage * dmReq =
               dynamic_cast<CIMDisableModuleRequestMessage*>(request);
  
             PEGASUS_ASSERT(p != 0);          CIMInstance providerModule = dmReq->providerModule;
           Boolean updateModuleStatus = !dmReq->disableProviderOnly;
  
             nameSpace = p->nameSpace.getString();          try
             //className = p->className.getString();          {
               // Change module status from OK to STOPPING
               if (updateModuleStatus)
               {
                   _updateProviderModuleStatus(
                       providerModule, CIM_MSE_OPSTATUS_VALUE_OK,
                       CIM_MSE_OPSTATUS_VALUE_STOPPING);
         }         }
  
         break;              // Forward the request to the ProviderManager
     case CIM_MODIFY_CLASS_REQUEST_MESSAGE:              response = _processMessage(request);
         {  
             const CIMModifyClassRequestMessage * p = dynamic_cast<const CIMModifyClassRequestMessage *>(message);  
  
             PEGASUS_ASSERT(p != 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)
                   {
                       // Disable operation failed.  Module not stopped.
                       _updateProviderModuleStatus(
                           providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPING,
                           CIM_MSE_OPSTATUS_VALUE_OK);
                   }
                   else
                   {
                       // Disable may or may not have been successful,
                       // depending on whether there are outstanding requests.
                       // Use last operationalStatus entry.
                       _updateProviderModuleStatus(
                           providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPING,
                           dmResp->operationalStatus[
                               dmResp->operationalStatus.size()-1]);
                   }
               }
           }
           catch (Exception& e)
           {
               // Get the OperationalStatus property from the provider module
               Array<Uint16> operationalStatus;
               CIMValue itValue = dmReq->providerModule.getProperty(
                   dmReq->providerModule.findProperty("OperationalStatus"))
                       .getValue();
               itValue.get(operationalStatus);
  
             nameSpace = p->nameSpace.getString();              if (response != 0)
             //className = p->className.getString();              {
                   delete response;
         }         }
  
         break;              response = new CIMDisableModuleResponseMessage(
     case CIM_DELETE_CLASS_REQUEST_MESSAGE:                  request->messageId,
                   CIMException(CIM_ERR_FAILED, e.getMessage()),
                   request->queueIds.copyAndPop(),
                   operationalStatus);
           }
       }
       else
         {         {
             const CIMDeleteClassRequestMessage * p = dynamic_cast<const CIMDeleteClassRequestMessage *>(message);          response = _processMessage(request);
       }
   
       AsyncLegacyOperationResult * async_result =
           new AsyncLegacyOperationResult(
           async->getKey(),
           async->getRouting(),
           op,
           response);
  
             PEGASUS_ASSERT(p != 0);      _complete_op_node(op, ASYNC_OPSTATE_COMPLETE, 0, 0);
  
             nameSpace = p->nameSpace.getString();      PEG_METHOD_EXIT();
             className = p->className.getString();  
         }         }
  
         break;  void
     case CIM_GET_INSTANCE_REQUEST_MESSAGE:  ProviderManagerService::handleCimResponse(CIMRequestMessage &request,
                                                                                                                                                                           CIMResponseMessage &response)
   {
           CIMStatusCode code = CIM_ERR_SUCCESS;
           String message;
   
           try
         {         {
             const CIMGetInstanceRequestMessage * p = dynamic_cast<const CIMGetInstanceRequestMessage *>(message);                  // only incomplete messages are processed because the caller ends up
                   // sending the complete() stage
                   PEGASUS_ASSERT(response.isComplete() == false);
  
             PEGASUS_ASSERT(p != 0);                  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);
  
             nameSpace = p->nameSpace.getString();                  // set the destination
             //className = p->className.getString();                  op->_op_dest = op->_callback_response_q;
         }  
  
         break;                  MessageQueueService *service =
     case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE:                          dynamic_cast<MessageQueueService *>(op->_callback_response_q);
         {  
             const CIMEnumerateInstancesRequestMessage * p = dynamic_cast<const CIMEnumerateInstancesRequestMessage *>(message);  
  
             PEGASUS_ASSERT(p != 0);                  PEGASUS_ASSERT(service);
  
             nameSpace = p->nameSpace.getString();                  // the last chunk MUST be sent last, so use execute the callback
             className = p->className.getString();                  // 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);
         }         }
  
         break;          catch(CIMException &e)
     case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE:  
         {         {
             const CIMEnumerateInstanceNamesRequestMessage * p = dynamic_cast<const CIMEnumerateInstanceNamesRequestMessage *>(message);                  code = e.getCode();
                   message = e.getMessage();
             PEGASUS_ASSERT(p != 0);          }
           catch(Exception &e)
           {
                   code = CIM_ERR_FAILED;
                   message = e.getMessage();
           }
           catch(...)
           {
                   code = CIM_ERR_FAILED;
                   message = cimStatusCodeToString(code);
           }
  
             nameSpace = p->nameSpace.getString();          if (code !=  CIM_ERR_SUCCESS)
             className = p->className.getString();                  response.cimException = PEGASUS_CIM_EXCEPTION(code, message);
         }         }
  
         break;  Message* ProviderManagerService::_processMessage(CIMRequestMessage* request)
     case CIM_CREATE_INSTANCE_REQUEST_MESSAGE:  
         {         {
             const CIMCreateInstanceRequestMessage * p = dynamic_cast<const CIMCreateInstanceRequestMessage *>(message);      Message* response = 0;
   
             PEGASUS_ASSERT(p != 0);  
  
             nameSpace = p->nameSpace.getString();      if ((request->getType() == CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE) ||
             //className = p->className.getString();          (request->getType() ==
               CIM_SUBSCRIPTION_INIT_COMPLETE_REQUEST_MESSAGE) ||
           (request->getType() == CIM_NOTIFY_CONFIG_CHANGE_REQUEST_MESSAGE))
       {
           if (_basicProviderManagerRouter)
           {
               response = _basicProviderManagerRouter->processMessage(request);
         }         }
  
         break;          if (_oopProviderManagerRouter)
     case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE:  
         {         {
             const CIMModifyInstanceRequestMessage * p = dynamic_cast<const CIMModifyInstanceRequestMessage *>(message);              // Note: These responses do not contain interesting data, so just
               // use the last one.
               if (response)
               {
                   delete response;
               }
  
             PEGASUS_ASSERT(p != 0);              response = _oopProviderManagerRouter->processMessage(request);
           }
       }
       else
       {
           CIMInstance providerModule;
  
             nameSpace = p->nameSpace.getString();          if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE)
             //className = p->className.getString();          {
               CIMEnableModuleRequestMessage* emReq =
                   dynamic_cast<CIMEnableModuleRequestMessage*>(request);
               providerModule = emReq->providerModule;
           }
           else if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE)
           {
               CIMDisableModuleRequestMessage* dmReq =
                   dynamic_cast<CIMDisableModuleRequestMessage*>(request);
               providerModule = dmReq->providerModule;
           }
           else
           {
               ProviderIdContainer pidc =
                   request->operationContext.get(ProviderIdContainer::NAME);
               providerModule = pidc.getModule();
         }         }
  
         break;          Uint16 userContext = 0;
     case CIM_DELETE_INSTANCE_REQUEST_MESSAGE:          Uint32 pos = providerModule.findProperty(
               PEGASUS_PROPERTYNAME_MODULE_USERCONTEXT);
           if (pos != PEG_NOT_FOUND)
         {         {
             const CIMDeleteInstanceRequestMessage * p = dynamic_cast<const CIMDeleteInstanceRequestMessage *>(message);              providerModule.getProperty(pos).getValue().get(userContext);
           }
  
             PEGASUS_ASSERT(p != 0);          // Forward the request to the appropriate ProviderManagerRouter, based
           // on the CIM Server configuration and the UserContext setting.
  
             nameSpace = p->nameSpace.getString();          ConfigManager* configManager = ConfigManager::getInstance();
             //className = p->className.getString();          Boolean forceProviderProcesses = String::equal(
         }              configManager->getCurrentValue("forceProviderProcesses"), "true");
  
         break;          if (forceProviderProcesses
     case CIM_EXEC_QUERY_REQUEST_MESSAGE:  #ifndef PEGASUS_DISABLE_PROV_USERCTXT
         break;              || (userContext == PG_PROVMODULE_USERCTXT_REQUESTOR)
     case CIM_ASSOCIATORS_REQUEST_MESSAGE:              || (userContext == PG_PROVMODULE_USERCTXT_DESIGNATED)
               || ((userContext == PG_PROVMODULE_USERCTXT_PRIVILEGED) &&
                   !System::isPrivilegedUser(System::getEffectiveUserName()))
   #endif
              )
         {         {
             const CIMAssociatorsRequestMessage * p = dynamic_cast<const CIMAssociatorsRequestMessage *>(message);              response = _oopProviderManagerRouter->processMessage(request);
           }
             PEGASUS_ASSERT(p != 0);          else
           {
               response = _basicProviderManagerRouter->processMessage(request);
           }
       }
  
             nameSpace = p->nameSpace.getString();      return response;
             //className = p->className.getString();  
         }         }
  
         break;  void ProviderManagerService::unloadIdleProviders()
     case CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE:  
         {         {
             const CIMAssociatorNamesRequestMessage * p = dynamic_cast<const CIMAssociatorNamesRequestMessage *>(message);      PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
           "ProviderManagerService::unloadIdleProviders");
             PEGASUS_ASSERT(p != 0);      ThreadStatus rtn = PEGASUS_THREAD_OK;
       // Ensure that only one _unloadIdleProvidersHandler thread runs at a time
       _unloadIdleProvidersBusy++;
       if ((_unloadIdleProvidersBusy.get() == 1) &&
           ((rtn = _thread_pool->allocate_and_awaken(
                (void*)this, ProviderManagerService::_unloadIdleProvidersHandler))==PEGASUS_THREAD_OK))
       {
           // _unloadIdleProvidersBusy is decremented in
           // _unloadIdleProvidersHandler
       }
       else
       {
           // If we fail to allocate a thread, don't retry now.
           _unloadIdleProvidersBusy--;
       }
       if (rtn != PEGASUS_THREAD_OK)
       {
           Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
                   "Not enough threads to unload idle providers.");
  
             nameSpace = p->nameSpace.getString();          Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
             //className = p->className.getString();                  "Could not allocate thread for %s to unload idle providers.",
                   getQueueName());
       }
       PEG_METHOD_EXIT();
         }         }
  
         break;  PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL
     case CIM_REFERENCES_REQUEST_MESSAGE:  ProviderManagerService::_unloadIdleProvidersHandler(void* arg) throw()
   {
       try
         {         {
             const CIMReferencesRequestMessage * p = dynamic_cast<const CIMReferencesRequestMessage *>(message);          PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
               "ProviderManagerService::unloadIdleProvidersHandler");
  
             PEGASUS_ASSERT(p != 0);          ProviderManagerService* myself =
               reinterpret_cast<ProviderManagerService*>(arg);
  
             nameSpace = p->nameSpace.getString();          if (myself->_basicProviderManagerRouter)
             //className = p->className.getString();          {
               try
               {
                   myself->_basicProviderManagerRouter->unloadIdleProviders();
               }
               catch (...)
               {
                   // Ignore errors
                   PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
                       "Unexpected exception from "
                           "BasicProviderManagerRouter::_unloadIdleProviders");
               }
         }         }
  
         break;          if (myself->_oopProviderManagerRouter)
     case CIM_REFERENCE_NAMES_REQUEST_MESSAGE:          {
               try
         {         {
             const CIMReferenceNamesRequestMessage * p = dynamic_cast<const CIMReferenceNamesRequestMessage *>(message);                  myself->_oopProviderManagerRouter->unloadIdleProviders();
               }
               catch (...)
               {
                   // Ignore errors
                   PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
                       "Unexpected exception from "
                           "OOPProviderManagerRouter::_unloadIdleProviders");
               }
           }
  
             PEGASUS_ASSERT(p != 0);          myself->_unloadIdleProvidersBusy--;
           PEG_METHOD_EXIT();
       }
       catch (...)
       {
           // Ignore errors
           PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
               "Unexpected exception in _unloadIdleProvidersHandler");
       }
  
             nameSpace = p->nameSpace.getString();      return(PEGASUS_THREAD_RETURN(0));
             //className = p->className.getString();  
         }         }
  
         break;  // Updates the providerModule instance and the ProviderRegistrationManager
     case CIM_GET_PROPERTY_REQUEST_MESSAGE:  void ProviderManagerService::_updateProviderModuleStatus(
       CIMInstance& providerModule,
       Uint16 fromStatus,
       Uint16 toStatus)
         {         {
             const CIMGetPropertyRequestMessage * p = dynamic_cast<const CIMGetPropertyRequestMessage *>(message);      PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
           "ProviderManagerService::_updateProviderModuleStatus");
   
       Array<Uint16> operationalStatus;
       String providerModuleName;
   
       Uint32 pos = providerModule.findProperty(CIMName("Name"));
       PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
       providerModule.getProperty(pos).getValue().get(providerModuleName);
  
             PEGASUS_ASSERT(p != 0);      //
       // get operational status
       //
       pos = providerModule.findProperty(CIMName("OperationalStatus"));
       PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
       CIMProperty operationalStatusProperty = providerModule.getProperty(pos);
       CIMValue operationalStatusValue = operationalStatusProperty.getValue();
  
             nameSpace = p->nameSpace.getString();      if (!operationalStatusValue.isNull())
             //className = p->className.getString();      {
           operationalStatusValue.get(operationalStatus);
         }         }
  
         break;      //
     case CIM_SET_PROPERTY_REQUEST_MESSAGE:      // update module status
       //
       for (Uint32 i = operationalStatus.size(); i > 0; i--)
       {
           if (operationalStatus[i-1] == fromStatus)
         {         {
             const CIMSetPropertyRequestMessage * p = dynamic_cast<const CIMSetPropertyRequestMessage *>(message);              operationalStatus.remove(i-1);
           }
       }
  
             PEGASUS_ASSERT(p != 0);      operationalStatus.append(toStatus);
  
             nameSpace = p->nameSpace.getString();      if (_providerRegistrationManager->setProviderModuleStatus(
             //className = p->className.getString();              providerModuleName, operationalStatus) == false)
       {
           throw PEGASUS_CIM_EXCEPTION_L(
               CIM_ERR_FAILED,
               MessageLoaderParms(
                   "ProviderManager.ProviderManagerService."
                       "SET_MODULE_STATUS_FAILED",
                   "set module status failed."));
         }         }
  
         break;      operationalStatusProperty.setValue(CIMValue(operationalStatus));
     case CIM_INVOKE_METHOD_REQUEST_MESSAGE:  
         {  
             const CIMInvokeMethodRequestMessage * p = dynamic_cast<const CIMInvokeMethodRequestMessage *>(message);  
  
             PEGASUS_ASSERT(p != 0);      PEG_METHOD_EXIT();
   }
  
             nameSpace = p->nameSpace.getString();  void ProviderManagerService::indicationCallback(
             //className = p->className.getString();      CIMProcessIndicationRequestMessage* request)
   {
           try
           {
                   AcceptLanguageListContainer cntr = request->operationContext.get(AcceptLanguageListContainer::NAME);
           }catch(const Exception &)
           {
                   request->operationContext.insert(AcceptLanguageListContainer(AcceptLanguageList()));
         }         }
  
         break;          if (_indicationServiceQueueId == PEG_NOT_FOUND)
     /*  
     case CIM_ENABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE:  
         {         {
             const CIMEnableIndicationsSubscriptionRequestMessage * p = dynamic_cast<const CIMEnableIndicationsRequestMessage *>(message);          Array<Uint32> serviceIds;
  
             PEGASUS_ASSERT(p != 0);          providerManagerService->find_services(
               PEGASUS_QUEUENAME_INDICATIONSERVICE, 0, 0, &serviceIds);
           PEGASUS_ASSERT(serviceIds.size() != 0);
  
             nameSpace = p->nameSpace.getString();          _indicationServiceQueueId = serviceIds[0];
             className = p->className.getString();  
         }         }
  
         break;      request->queueIds = QueueIdStack(
     case CIM_MODIFY_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE:          _indicationServiceQueueId, providerManagerService->getQueueId());
         {  
             const CIMModifyIndicationsRequestMessage * p = dynamic_cast<const CIMModifyIndicationsRequestMessage *>(message);  
  
             PEGASUS_ASSERT(p != 0);      AsyncLegacyOperationStart * asyncRequest =
           new AsyncLegacyOperationStart(
           providerManagerService->get_next_xid(),
           0,
           _indicationServiceQueueId,
           request,
           _indicationServiceQueueId);
  
             nameSpace = p->nameSpace.getString();      providerManagerService->SendForget(asyncRequest);
             className = p->className.getString();  
         }  
  
         break;  
     case CIM_DISABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE:  
         {  
             const CIMGetClassRequestMessage * p = dynamic_cast<const CIMGetClassRequestMessage *>(message);  
  
             PEGASUS_ASSERT(p != 0);  
  
             nameSpace = p->nameSpace.getString();  
             className = p->className.getString();  
         }  
  
         break;  #ifdef PEGASUS_INDICATIONS_Q_THRESHOLD
     */  
     default:  
         break;  
     }  
  
     ProviderName name(      // See Comments in config.mak asociated with
         CIMObjectPath(String::EMPTY, nameSpace, className).toString(),      //  PEGASUS_INDICATIONS_Q_THRESHOLD
         String::EMPTY,      //
         String::EMPTY,      // if INDICATIONS_Q_STALL THRESHOLD is gt 0
         String::EMPTY,      // then if there are over INDICATIONS_Q_STALL_THRESHOLD
         0);      //           indications in the queue
       //      then force this provider to sleep until the queue count
       //      is lower than INDICATIONS_Q_RESUME_THRESHOLD
  
     // find provider manager  static Mutex   indicationThresholdReportedLock;
     name = ProviderRegistrar().findProvider(name);  static Boolean indicationThresholdReported = false;
  
     // find provider manager for provider interface  #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);
  
     try      if (((MessageQueueService *)indicationsQueue)->getIncomingCount() > INDICATIONS_Q_STALL_THRESHOLD)
         {
           AutoMutex indicationThresholdReportedAutoMutex(indicationThresholdReportedLock);
           if (!indicationThresholdReported)
     {     {
         PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4,              indicationThresholdReported = true;
             "ProviderManagerService::handleCimRequest() passing control to provider manager.");              indicationThresholdReportedAutoMutex.unlock();
  
         // forward request              // make log entry to record que max exceeded
         response = _providerManagers[0].getProviderManager().processMessage(request);  
               Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
                  "Indication generation stalled: maximum queue count ($0) exceeded.",
                   INDICATIONS_Q_STALL_THRESHOLD);
     }     }
     catch(...)          else
     {     {
         // ATTN: create response with error message              indicationThresholdReportedAutoMutex.unlock();
     }     }
  
     // preserve message key          while (((MessageQueueService *)indicationsQueue)->getIncomingCount() > INDICATIONS_Q_RESUME_THRESHOLD)
     response->setKey(request->getKey());            {
               pegasus_sleep(INDICATIONS_Q_STALL_DURATION);
     // set HTTP method in response from request            }
     response->setHttpMethod(request->getHttpMethod());  
  
     AsyncLegacyOperationResult * async_result =          AutoMutex indicationThresholdReportedAutoMutex1(indicationThresholdReportedLock);
         new AsyncLegacyOperationResult(          //        indicationThresholdReportedLock.lock(pegasus_thread_self());
         async->getKey(),          if(indicationThresholdReported)
         async->getRouting(),            {
         op,              indicationThresholdReported = false;
         response);              indicationThresholdReportedAutoMutex1.unlock();
  
     _complete_op_node(op, ASYNC_OPSTATE_COMPLETE, 0, 0);              Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
                     "Indication generation resumed: current queue count = $0",
                     ((MessageQueueService *)indicationsQueue)->getIncomingCount() );
  
     PEG_METHOD_EXIT();  
 } }
           else
 void ProviderManagerService::unload_idle_providers(void)  
 { {
               indicationThresholdReportedAutoMutex1.unlock();
 } }
         }
   #endif /* INDICATIONS_Q_STALL_THRESHOLD */
  
 PEGASUS_NAMESPACE_END  }
  
   PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.13  
changed lines
  Added in v.1.73.4.1

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2