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

version 1.8, 2003/09/03 18:47:17 version 1.78, 2006/04/18 19:08:44
Line 1 
Line 1 
 //%/////////////////////////////////////////////////////////////////////////////  //%2006////////////////////////////////////////////////////////////////////////
 // //
 // 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.
   // 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 28 
Line 36 
 //              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>
 // ATTN: this section is a temporary solution to populate the list of enabled  #include <Pegasus/ProviderManager2/OperationResponseHandler.h>
 // provider managers for a given distribution. it includes another temporary  
 // solution for converting a generic file name into a file name useable by  
 // each platform.  
   
 // BEGIN TEMP SECTION  
 String _resolveFileName(const String & fileName)  
 {  
     String temp;  
   
     #if defined(PEGASUS_OS_TYPE_WINDOWS)  
     temp = fileName + String(".dll");  
     #elif defined(PEGASUS_OS_HPUX) && defined(PEGASUS_PLATFORM_HPUX_PARISC_ACC)  
     temp = ConfigManager::getHomedPath(ConfigManager::getInstance()->getCurrentValue("providerDir"));  
     temp.append(String("/lib") + fileName + String(".sl"));  
     #elif defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_HPUX_PARISC_ACC)  
     temp = ConfigManager::getHomedPath(ConfigManager::getInstance()->getCurrentValue("providerDir"));  
     temp.append(String("/lib") + fileName + String(".so"));  
     #elif defined(PEGASUS_OS_OS400)  
     temp = fileName;  
     #else  
     temp = ConfigManager::getHomedPath(ConfigManager::getInstance()->getCurrentValue("providerDir"));  
     temp.append(String("/lib") + fileName + String(".so"));  
     #endif  
  
     return(temp);  PEGASUS_NAMESPACE_BEGIN
 }  
   
 Array<Pair<String, String> > _initializeFileNames(void)  
 {  
     Array<Pair<String, String> > temp;  
   
     #if defined(ENABLE_DEFAULT_PROVIDER_MANAGER)  
     #if defined(PEGASUS_OS_OS400)  
     temp.append(Pair<String, String>(_resolveFileName("QSYS/QYCMDFTPVM"), String("DEFAULT")));  
     #else  
     temp.append(Pair<String, String>(_resolveFileName("DefaultProviderManager"), String("DEFAULT")));  
     #endif  
     #endif  
   
     #if defined(ENABLE_CMPI_PROVIDER_MANAGER)  
     #if defined(PEGASUS_OS_OS400)  
     temp.append(Pair<String, String>(_resolveFileName("QSYS/QYCMCMPIPM"), String("CMPI")));  
     #else  
     temp.append(Pair<String, String>(_resolveFileName("CMPIProviderManager"), String("CMPI")));  
     #endif  
     #endif  
   
     return(temp);  
 }  
   
 static const Array<Pair<String,String> > _fileNames = _initializeFileNames();  
 // END TEMP SECTION  
  
 inline Boolean _isSupportedRequestType(const Message * message) inline Boolean _isSupportedRequestType(const Message * message)
 { {
     Boolean rc = false;      // ATTN: needs implementation
  
     if(message == 0)      // for now, assume all requests are valid
     {  
         return(rc);  
     }  
   
     /*  
     // ATTN : need to determine valid request message types  
     // before enabling.  
   
     switch(message->getType())  
     {  
     case CIM_GET_INSTANCE_REQUEST_MESSAGE:  
     case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE:  
     case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE:  
     case CIM_CREATE_INSTANCE_REQUEST_MESSAGE:  
     case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE:  
     case CIM_DELETE_INSTANCE_REQUEST_MESSAGE:  
     case CIM_EXEC_QUERY_REQUEST_MESSAGE:  
     case CIM_ASSOCIATORS_REQUEST_MESSAGE:  
     case CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE:  
     case CIM_REFERENCES_REQUEST_MESSAGE:  
     case CIM_REFERENCE_NAMES_REQUEST_MESSAGE:  
     case CIM_GET_PROPERTY_REQUEST_MESSAGE:  
     case CIM_SET_PROPERTY_REQUEST_MESSAGE:  
     case CIM_INVOKE_METHOD_REQUEST_MESSAGE:  
     case CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE:  
     case CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE:  
     case CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE:  
     case CIM_ENABLE_INDICATIONS_REQUEST_MESSAGE:  
     case CIM_DISABLE_INDICATIONS_REQUEST_MESSAGE:  
     case CIM_DISABLE_MODULE_REQUEST_MESSAGE:  
     case CIM_ENABLE_MODULE_REQUEST_MESSAGE:  
     case CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE:  
     case CIM_CONSUME_INDICATION_REQUEST_MESSAGE:  
         rc = true;  
  
         break;      return(true);
     default:  
         rc = false;  
   
         break;  
     }  
     */  
   
     rc = true;  
   
     return(rc);  
 } }
  
 inline Boolean _isSupportedResponseType(const Message * message) inline Boolean _isSupportedResponseType(const Message * message)
 { {
     Boolean rc = false;      // ATTN: needs implementation
  
     return(rc);      // for now, assume all responses are invalid
   
       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)
 { {
     for(Uint32 i = 0, n = _fileNames.size(); i < n; i++)      providerManagerService=this;
     {      _repository=repository;
         String message;  
  
         message = "ProviderManagerService::ProviderManagerService() loading " +      _providerRegistrationManager = providerRegistrationManager;
             _fileNames[i].first + "(" + _fileNames[i].second + ")";  
  
         PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, message);      _unloadIdleProvidersBusy = 0;
  
         try      _basicProviderManagerRouter = 0;
         {      _oopProviderManagerRouter = 0;
             ProviderManagerModule module(_fileNames[i].first);  
  
             if(module.load() == false)      // Determine which ProviderManagerRouter(s) to use
             {  
                 throw 0;    // ATTN: inefficient  
             }  
  
             ProviderManager * manager = module.getProviderManager(_fileNames[i].second);      ConfigManager* configManager = ConfigManager::getInstance();
       Boolean forceProviderProcesses = String::equal(
           configManager->getCurrentValue("forceProviderProcesses"), "true");
  
             if(manager == 0)  #ifdef PEGASUS_DISABLE_PROV_USERCTXT
       if (forceProviderProcesses)
             {             {
                 throw 0;    // ATTN: inefficient          _oopProviderManagerRouter = new OOPProviderManagerRouter(
               indicationCallback, responseChunkCallback);
             }             }
       else
             // ATTN: only set the hacked/cached provider registration manager pointer after the  
             // DEFAULT provider manager is loaded.  
             if(String::equalNoCase(_fileNames[i].second, "DEFAULT"))  
             {             {
                 manager->setProviderRegistrationManager(providerRegistrationManager);          _basicProviderManagerRouter = new BasicProviderManagerRouter(
               indicationCallback, responseChunkCallback);
             }             }
   #else
       _oopProviderManagerRouter = new OOPProviderManagerRouter(
           indicationCallback, responseChunkCallback);
  
             _providerManagers.append(Pair<ProviderManager *, ProviderManagerModule>(manager, module));      if (!forceProviderProcesses)
         }  
         catch(...)  
         {         {
             message = "ProviderManagerService::ProviderManagerService() exception loading " +          _basicProviderManagerRouter = new BasicProviderManagerRouter(
                 _fileNames[i].first + "(" + _fileNames[i].second + ")";              indicationCallback, responseChunkCallback);
   
             PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, message);  
         }  
     }     }
   #endif
 } }
  
 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 268 
Line 197 
         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 282 
Line 226 
     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
   ProviderManagerService::handleCimOperation(void* arg)
 { {
     // get the service from argument      PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
     ProviderManagerService * service = reinterpret_cast<ProviderManagerService *>(arg);          "ProviderManagerService::handleCimOperation");
   
     PEGASUS_ASSERT(service != 0);  
  
     // get message from service queue      PEGASUS_ASSERT(arg != 0);
     Message * message = service->_incomingQueue.dequeue();  
  
     PEGASUS_ASSERT(message != 0);      // get the service from argument
       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));
     }     }
  
     AsyncOpNode * op = service->_incomingQueue.dequeue();     AsyncOpNode * op = service->_incomingQueue.dequeue();
  
     PEGASUS_ASSERT(op != 0 );          if ((op == 0) || (op->_request.count() == 0))
   
     if(op->_request.count() == 0)  
     {     {
               // ATTN: This may dereference a null pointer!
         MessageQueue * queue = MessageQueue::lookup(op->_source_queue);         MessageQueue * queue = MessageQueue::lookup(op->_source_queue);
  
         PEGASUS_ASSERT(queue != 0);         PEGASUS_ASSERT(queue != 0);
Line 322 
Line 268 
         return(PEGASUS_THREAD_RETURN(1));         return(PEGASUS_THREAD_RETURN(1));
     }     }
  
     return(0);          AsyncRequest* request =
               static_cast<AsyncRequest*>(op->_request.next(0));
   
           if ((request == 0) ||
               (request->getType() != async_messages::ASYNC_LEGACY_OP_START))
           {
               // reply with NAK
               PEG_METHOD_EXIT();
               return(PEGASUS_THREAD_RETURN(0));
 } }
 */  
  
 PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL ProviderManagerService::handleCimOperation(void * arg) throw()          Message* legacy =
               static_cast<AsyncLegacyOperationStart *>(request)->get_action();
   
           if(_isSupportedRequestType(legacy))
 { {
     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderManagerService::handleCimOperation");              AutoPtr<Message> xmessage(legacy);
   
               // Set the client's requested language into this service thread.
               // This will allow functions in this service to return messages
               // in the correct language.
               CIMMessage* msg = dynamic_cast<CIMMessage *>(legacy);
  
     if(arg == 0)              if (msg != 0)
     {     {
         // thread started with invalid argument.                  AcceptLanguageList* langs = new AcceptLanguageList(
         return(PEGASUS_THREAD_RETURN(1));                      ((AcceptLanguageListContainer)msg->operationContext.get(
                           AcceptLanguageListContainer::NAME)).getLanguages());
                   Thread::setLanguages(langs);
               }
               else
               {
                   Thread::clearLanguages();
     }     }
  
     // get the service from argument              service->handleCimRequest(op, legacy);
     ProviderManagerService * service = reinterpret_cast<ProviderManagerService *>(arg);          }
       }
     if(service->_incomingQueue.size() == 0)      catch (const Exception& e)
     {     {
         PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4,          PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
             "ProviderManagerService::handleCimOperation() called with no op node in queue" );              "Unexpected exception in handleCimOperation: " + e.getMessage());
       }
       catch (...)
       {
           PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
               "Unexpected exception in handleCimOperation.");
       }
  
         PEG_METHOD_EXIT();         PEG_METHOD_EXIT();
  
         // thread started with no message in queue.      return(PEGASUS_THREAD_RETURN(0));
         return(PEGASUS_THREAD_RETURN(1));  
     }     }
  
     AsyncOpNode * op = service->_incomingQueue.dequeue();  void ProviderManagerService::handleCimRequest(
       AsyncOpNode * op,
     if((op == 0) || (op->_request.count() == 0))      Message * message)
     {     {
         MessageQueue * queue = MessageQueue::lookup(op->_source_queue);      PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
           "ProviderManagerService::handleCimRequest");
  
         PEGASUS_ASSERT(queue != 0);      CIMRequestMessage * request = dynamic_cast<CIMRequestMessage *>(message);
       PEGASUS_ASSERT(request != 0);
  
         PEG_METHOD_EXIT();      // get request from op node
       AsyncRequest * async = static_cast<AsyncRequest *>(op->_request.next(0));
       PEGASUS_ASSERT(async != 0);
  
         // no request in op node      Message * response = 0;
         return(PEGASUS_THREAD_RETURN(1));      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 (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) ||
           (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) ||
           (request->getType() == CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE))
       {
           // Handle CIMOperationRequestMessage, CIMExportIndicationRequestMessage,
           // CIMIndicationRequestMessage, and CIMInitializeProviderRequestMessage.
           // (These should be blocked when the provider module is disabled.)
  
     AsyncRequest * request = static_cast<AsyncRequest *>(op->_request.next(0));          //
           // Get the provider module instance to check for a disabled module
           //
           CIMInstance providerModule;
   
           // 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();
  
     if((request == 0) || (request->getType() != async_messages::ASYNC_LEGACY_OP_START))          //
           // 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++)
     {     {
         // reply with NAK              if ((operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED) ||
                   (operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING))
               {
                   moduleDisabled = true;
                   break;
               }
           }
  
         PEG_METHOD_EXIT();          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;
  
         return(PEGASUS_THREAD_RETURN(0));               STAT_COPYDISPATCHER
     }     }
           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);
   
           CIMInstance providerModule = emReq->providerModule;
  
     try     try
     {     {
         Message * legacy = static_cast<AsyncLegacyOperationStart *>(request)->get_action();              // Forward the request to the ProviderManager
               response = _processMessage(request);
  
         if(_isSupportedRequestType(legacy))              // 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)
         {         {
             Destroyer<Message> xmessage(legacy);                  _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);
  
             // Set the client's requested language into this service thread.              delete response;
             // This will allow functions in this service to return messages  
             // in the correct language.  
             CIMMessage * msg = dynamic_cast<CIMMessage *>(legacy);  
  
             if(msg != 0)              response = new CIMEnableModuleResponseMessage(
                   request->messageId,
                   CIMException(CIM_ERR_FAILED, e.getMessage()),
                   request->queueIds.copyAndPop(),
                   operationalStatus);
           }
       }
       else if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE)
             {             {
                 AcceptLanguages * langs = new AcceptLanguages(msg->acceptLanguages);          // Handle CIMDisableModuleRequestMessage
           CIMDisableModuleRequestMessage * dmReq =
               dynamic_cast<CIMDisableModuleRequestMessage*>(request);
  
                 Thread::setLanguages(langs);          CIMInstance providerModule = dmReq->providerModule;
           Boolean updateModuleStatus = !dmReq->disableProviderOnly;
   
           try
           {
               // Change module status from OK to STOPPING
               if (updateModuleStatus)
               {
                   _updateProviderModuleStatus(
                       providerModule, CIM_MSE_OPSTATUS_VALUE_OK,
                       CIM_MSE_OPSTATUS_VALUE_STOPPING);
               }
   
               // Forward the request to the ProviderManager
               response = _processMessage(request);
   
               // 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             else
             {             {
                 Thread::clearLanguages();                      // 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);
   
               delete response;
   
               response = new CIMDisableModuleResponseMessage(
                   request->messageId,
                   CIMException(CIM_ERR_FAILED, e.getMessage()),
                   request->queueIds.copyAndPop(),
                   operationalStatus);
           }
       }
       else
       {
           response = _processMessage(request);
             }             }
  
             service->handleCimRequest(op, legacy);      AsyncLegacyOperationResult * async_result =
           new AsyncLegacyOperationResult(
           async->getKey(),
           async->getRouting(),
           op,
           response);
   
       _complete_op_node(op, ASYNC_OPSTATE_COMPLETE, 0, 0);
   
       PEG_METHOD_EXIT();
         }         }
   
   void ProviderManagerService::responseChunkCallback(
       CIMRequestMessage* request,
       CIMResponseMessage* response)
   {
       PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
           "ProviderManagerService::responseChunkCallback");
   
       try
       {
           // only incomplete messages are processed because the caller ends up
           // 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);
       }
       catch(Exception &e)
       {
           PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
               "Exception in ProviderManagerService::responseChunkCallback: " +
                   e.getMessage() + ".  Chunk not delivered.");
     }     }
     catch(...)     catch(...)
     {     {
         // ATTN: log error          PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
               "Exception in ProviderManagerService::responseChunkCallback.  "
                   "Chunk not delivered.");
     }     }
  
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
   }
  
     return(PEGASUS_THREAD_RETURN(0));  Message* ProviderManagerService::_processMessage(CIMRequestMessage* request)
   {
       Message* response = 0;
   
       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))
       {
           if (_basicProviderManagerRouter)
           {
               response = _basicProviderManagerRouter->processMessage(request);
 } }
  
 void ProviderManagerService::handleCimRequest(AsyncOpNode * op, const Message * message)          if (_oopProviderManagerRouter)
 { {
     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderManagerService::handleCimRequest");              // Note: These responses do not contain interesting data, so just
               // use the last one.
               delete response;
  
     // ATTN: ensure message is a request???              response = _oopProviderManagerRouter->processMessage(request);
     CIMMessage * request = dynamic_cast<CIMMessage *>(const_cast<Message *>(message));          }
       }
       else
       {
           CIMInstance providerModule;
  
     // get request from op node          if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE)
     AsyncRequest * async = static_cast<AsyncRequest *>(op->_request.next(0));          {
               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();
           }
  
     PEGASUS_ASSERT((request != 0) && (async != 0));          Uint16 userContext = 0;
           Uint32 pos = providerModule.findProperty(
               PEGASUS_PROPERTYNAME_MODULE_USERCONTEXT);
           if (pos != PEG_NOT_FOUND)
           {
               providerModule.getProperty(pos).getValue().get(userContext);
           }
  
     Message * response = 0;          // Forward the request to the appropriate ProviderManagerRouter, based
           // on the CIM Server configuration and the UserContext setting.
  
     // find provider manager          ConfigManager* configManager = ConfigManager::getInstance();
     // ATTN: implement efficient lookup          Boolean forceProviderProcesses = String::equal(
     ProviderManager * manager = _providerManagers[0].first;              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
              )
           {
               response = _oopProviderManagerRouter->processMessage(request);
           }
           else
           {
               response = _basicProviderManagerRouter->processMessage(request);
           }
       }
   
       return response;
   }
   
   void ProviderManagerService::unloadIdleProviders()
   {
       PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
           "ProviderManagerService::unloadIdleProviders");
       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.");
   
           Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
               "Could not allocate thread for %s to unload idle providers.",
               getQueueName());
       }
       PEG_METHOD_EXIT();
   }
   
   PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL
   ProviderManagerService::_unloadIdleProvidersHandler(void* arg) throw()
   {
     try     try
     {     {
         PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4,          PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
             "ProviderManagerService::handleCimRequest() passing control to provider manager.");              "ProviderManagerService::unloadIdleProvidersHandler");
   
           ProviderManagerService* myself =
               reinterpret_cast<ProviderManagerService*>(arg);
  
         // forward request          if (myself->_basicProviderManagerRouter)
         response = manager->processMessage(request);          {
               try
               {
                   myself->_basicProviderManagerRouter->unloadIdleProviders();
     }     }
     catch(...)     catch(...)
     {     {
         // ATTN: create response with error message                  // Ignore errors
                   PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
                       "Unexpected exception from "
                           "BasicProviderManagerRouter::_unloadIdleProviders");
               }
     }     }
  
     // preserve message key          if (myself->_oopProviderManagerRouter)
     response->setKey(request->getKey());          {
               try
               {
                   myself->_oopProviderManagerRouter->unloadIdleProviders();
               }
               catch (...)
               {
                   // Ignore errors
                   PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
                       "Unexpected exception from "
                           "OOPProviderManagerRouter::_unloadIdleProviders");
               }
           }
  
     // set HTTP method in response from request          myself->_unloadIdleProvidersBusy--;
     response->setHttpMethod(request->getHttpMethod());          PEG_METHOD_EXIT();
       }
       catch (...)
       {
           // Ignore errors
           PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
               "Unexpected exception in _unloadIdleProvidersHandler");
       }
  
     AsyncLegacyOperationResult * async_result =      return(PEGASUS_THREAD_RETURN(0));
         new AsyncLegacyOperationResult(  }
             async->getKey(),  
             async->getRouting(),  
             op,  
             response);  
  
     _complete_op_node(op, ASYNC_OPSTATE_COMPLETE, 0, 0);  // Updates the providerModule instance and the ProviderRegistrationManager
   void ProviderManagerService::_updateProviderModuleStatus(
       CIMInstance& providerModule,
       Uint16 fromStatus,
       Uint16 toStatus)
   {
       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);
   
       //
       // get operational status
       //
       pos = providerModule.findProperty(CIMName("OperationalStatus"));
       PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
       CIMProperty operationalStatusProperty = providerModule.getProperty(pos);
       CIMValue operationalStatusValue = operationalStatusProperty.getValue();
   
       if (!operationalStatusValue.isNull())
       {
           operationalStatusValue.get(operationalStatus);
       }
   
       //
       // update module status
       //
       for (Uint32 i = operationalStatus.size(); i > 0; i--)
       {
           if (operationalStatus[i-1] == fromStatus)
           {
               operationalStatus.remove(i-1);
           }
       }
   
       operationalStatus.append(toStatus);
   
       if (_providerRegistrationManager->setProviderModuleStatus(
               providerModuleName, operationalStatus) == false)
       {
           throw PEGASUS_CIM_EXCEPTION_L(
               CIM_ERR_FAILED,
               MessageLoaderParms(
                   "ProviderManager.ProviderManagerService."
                       "SET_MODULE_STATUS_FAILED",
                   "set module status failed."));
       }
   
       operationalStatusProperty.setValue(CIMValue(operationalStatus));
  
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
 } }
  
 void ProviderManagerService::unload_idle_providers(void)  void ProviderManagerService::indicationCallback(
       CIMProcessIndicationRequestMessage* request)
   {
       try
       {
           AcceptLanguageListContainer cntr = request->operationContext.get(AcceptLanguageListContainer::NAME);
       }catch(const Exception &)
       {
           request->operationContext.insert(AcceptLanguageListContainer(AcceptLanguageList()));
       }
   
       if (_indicationServiceQueueId == PEG_NOT_FOUND)
       {
           Array<Uint32> serviceIds;
   
           providerManagerService->find_services(
               PEGASUS_QUEUENAME_INDICATIONSERVICE, 0, 0, &serviceIds);
           PEGASUS_ASSERT(serviceIds.size() != 0);
   
           _indicationServiceQueueId = serviceIds[0];
       }
   
       request->queueIds = QueueIdStack(
           _indicationServiceQueueId, providerManagerService->getQueueId());
   
       AsyncLegacyOperationStart * asyncRequest =
           new AsyncLegacyOperationStart(
           providerManagerService->get_next_xid(),
           0,
           _indicationServiceQueueId,
           request,
           _indicationServiceQueueId);
   
       providerManagerService->SendForget(asyncRequest);
   
   
   
   
   #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.8  
changed lines
  Added in v.1.78

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2