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

version 1.63, 2005/02/05 23:00:26 version 1.78, 2006/04/18 19:08:44
Line 1 
Line 1 
 //%2005////////////////////////////////////////////////////////////////////////  //%2006////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
Line 8 
Line 8 
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 // EMC Corporation; VERITAS Software Corporation; The Open Group. // 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 38 
Line 40 
 //              Amit K Arora (amita@in.ibm.com) for PEP-101 //              Amit K Arora (amita@in.ibm.com) for PEP-101
 //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 //              Seema Gupta (gseema@in.ibm.com for PEP135) //              Seema Gupta (gseema@in.ibm.com for PEP135)
   //              Jim Wunderlich (Jim_Wunderlich@prodigy.net)
   //              Aruran, IBM (ashanmug@in.ibm.com)for Bug# 3881
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include "ProviderManagerService.h" #include "ProviderManagerService.h"
  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
   #include <Pegasus/Common/PegasusVersion.h>
 #include <Pegasus/Common/Constants.h> #include <Pegasus/Common/Constants.h>
 #include <Pegasus/Common/CIMMessage.h> #include <Pegasus/Common/CIMMessage.h>
 #include <Pegasus/Common/Thread.h> #include <Pegasus/Common/Thread.h>
Line 111 
Line 116 
 #ifdef PEGASUS_DISABLE_PROV_USERCTXT #ifdef PEGASUS_DISABLE_PROV_USERCTXT
     if (forceProviderProcesses)     if (forceProviderProcesses)
     {     {
         _oopProviderManagerRouter =          _oopProviderManagerRouter = new OOPProviderManagerRouter(
             new OOPProviderManagerRouter(indicationCallback);              indicationCallback, responseChunkCallback);
     }     }
     else     else
     {     {
         _basicProviderManagerRouter =          _basicProviderManagerRouter = new BasicProviderManagerRouter(
             new BasicProviderManagerRouter(indicationCallback);              indicationCallback, responseChunkCallback);
     }     }
 #else #else
     _oopProviderManagerRouter =      _oopProviderManagerRouter = new OOPProviderManagerRouter(
         new OOPProviderManagerRouter(indicationCallback);          indicationCallback, responseChunkCallback);
  
     if (!forceProviderProcesses)     if (!forceProviderProcesses)
     {     {
         _basicProviderManagerRouter =          _basicProviderManagerRouter = new BasicProviderManagerRouter(
             new BasicProviderManagerRouter(indicationCallback);              indicationCallback, responseChunkCallback);
     }     }
 #endif #endif
 } }
Line 192 
Line 197 
         request->op->processing();         request->op->processing();
  
         _incomingQueue.enqueue(request->op);         _incomingQueue.enqueue(request->op);
           ThreadStatus rtn = PEGASUS_THREAD_OK;
          while (!_thread_pool->allocate_and_awaken(          while (( rtn =_thread_pool->allocate_and_awaken(
                      (void *)this, ProviderManagerService::handleCimOperation))                       (void *)this, ProviderManagerService::handleCimOperation)) != PEGASUS_THREAD_OK)
          {          {
               if (rtn==PEGASUS_THREAD_INSUFFICIENT_RESOURCES)
              pegasus_yield();              pegasus_yield();
               else
               {
                   Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
                       "Not enough threads to service provider manager." );
   
                   Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
                       "Could not allocate thread for %s.",
                       getQueueName());
                   break;
              }
          }          }
     }     }
     else     else
Line 218 
Line 234 
     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
         "ProviderManagerService::handleCimOperation");         "ProviderManagerService::handleCimOperation");
  
     if(arg == 0)      PEGASUS_ASSERT(arg != 0);
     {  
         // thread started with invalid argument.  
         return(PEGASUS_THREAD_RETURN(1));  
     }  
  
     // get the service from argument     // get the service from argument
     ProviderManagerService * service =     ProviderManagerService * service =
         reinterpret_cast<ProviderManagerService *>(arg);         reinterpret_cast<ProviderManagerService *>(arg);
       PEGASUS_ASSERT(service != 0);
  
       try
       {
     if(service->_incomingQueue.size() == 0)     if(service->_incomingQueue.size() == 0)
     {     {
         PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4,              PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
             "ProviderManagerService::handleCimOperation() called with no "             "ProviderManagerService::handleCimOperation() called with no "
                 "op node in queue");                 "op node in queue");
  
         PEG_METHOD_EXIT();         PEG_METHOD_EXIT();
   
         // thread started with no message in queue.  
         return(PEGASUS_THREAD_RETURN(1));         return(PEGASUS_THREAD_RETURN(1));
     }     }
  
Line 255 
Line 268 
         return(PEGASUS_THREAD_RETURN(1));         return(PEGASUS_THREAD_RETURN(1));
     }     }
  
     AsyncRequest * request = static_cast<AsyncRequest *>(op->_request.next(0));          AsyncRequest* request =
               static_cast<AsyncRequest*>(op->_request.next(0));
  
     if ((request == 0) ||     if ((request == 0) ||
         (request->getType() != async_messages::ASYNC_LEGACY_OP_START))         (request->getType() != async_messages::ASYNC_LEGACY_OP_START))
Line 265 
Line 279 
         return(PEGASUS_THREAD_RETURN(0));         return(PEGASUS_THREAD_RETURN(0));
     }     }
  
     try  
     {  
         Message* legacy =         Message* legacy =
             static_cast<AsyncLegacyOperationStart *>(request)->get_action();             static_cast<AsyncLegacyOperationStart *>(request)->get_action();
  
Line 281 
Line 293 
  
             if (msg != 0)             if (msg != 0)
             {             {
                         AcceptLanguages* langs =                  AcceptLanguageList* langs = new AcceptLanguageList(
                     new AcceptLanguages(((AcceptLanguageListContainer)msg->operationContext.get                      ((AcceptLanguageListContainer)msg->operationContext.get(
                                                                                         (AcceptLanguageListContainer::NAME)).getLanguages());                          AcceptLanguageListContainer::NAME)).getLanguages());
                 Thread::setLanguages(langs);                 Thread::setLanguages(langs);
             }             }
             else             else
Line 294 
Line 306 
             service->handleCimRequest(op, legacy);             service->handleCimRequest(op, legacy);
         }         }
     }     }
       catch (const Exception& e)
       {
           PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
               "Unexpected exception in handleCimOperation: " + e.getMessage());
       }
     catch(...)     catch(...)
     {     {
         // ATTN: log error          PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
               "Unexpected exception in handleCimOperation.");
     }     }
  
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
Line 405 
Line 423 
                     "ProviderManager.ProviderManagerService.PROVIDER_BLOCKED",                     "ProviderManager.ProviderManagerService.PROVIDER_BLOCKED",
                     "provider blocked."));                     "provider blocked."));
             response = cimResponse;             response = cimResponse;
   
                STAT_COPYDISPATCHER
         }         }
         else         else
         {         {
Line 447 
Line 467 
                     .getValue();                     .getValue();
             itValue.get(operationalStatus);             itValue.get(operationalStatus);
  
             if (response != 0)  
             {  
                 delete response;                 delete response;
             }  
  
             response = new CIMEnableModuleResponseMessage(             response = new CIMEnableModuleResponseMessage(
                 request->messageId,                 request->messageId,
Line 514 
Line 531 
                     .getValue();                     .getValue();
             itValue.get(operationalStatus);             itValue.get(operationalStatus);
  
             if (response != 0)  
             {  
                 delete response;                 delete response;
             }  
  
             response = new CIMDisableModuleResponseMessage(             response = new CIMDisableModuleResponseMessage(
                 request->messageId,                 request->messageId,
Line 543 
Line 557 
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
 } }
  
 void  void ProviderManagerService::responseChunkCallback(
 ProviderManagerService::handleCimResponse(CIMRequestMessage &request,      CIMRequestMessage* request,
                                                                                                                                                                         CIMResponseMessage &response)      CIMResponseMessage* response)
 { {
         CIMStatusCode code = CIM_ERR_SUCCESS;      PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
         String message;          "ProviderManagerService::responseChunkCallback");
  
         try         try
         {         {
                 // only incomplete messages are processed because the caller ends up                 // only incomplete messages are processed because the caller ends up
                 // sending the complete() stage                 // sending the complete() stage
                 PEGASUS_ASSERT(response.isComplete() == false);          PEGASUS_ASSERT(response->isComplete() == false);
  
                 AsyncLegacyOperationStart *requestAsync =                 AsyncLegacyOperationStart *requestAsync =
                         dynamic_cast<AsyncLegacyOperationStart *>(request._async);              dynamic_cast<AsyncLegacyOperationStart *>(request->_async);
                 PEGASUS_ASSERT(requestAsync);                 PEGASUS_ASSERT(requestAsync);
                 AsyncOpNode *op = requestAsync->op;                 AsyncOpNode *op = requestAsync->op;
                 PEGASUS_ASSERT(op);                 PEGASUS_ASSERT(op);
                 PEGASUS_ASSERT(! response._async);          PEGASUS_ASSERT(!response->_async);
                 response._async = new AsyncLegacyOperationResult          response->_async = new AsyncLegacyOperationResult(
                         (requestAsync->getKey(), requestAsync->getRouting(), op, &response);              requestAsync->getKey(), requestAsync->getRouting(), op, response);
  
                 // set the destination                 // set the destination
                 op->_op_dest = op->_callback_response_q;                 op->_op_dest = op->_callback_response_q;
Line 581 
Line 595 
  
                 op->_async_callback(op, service, op->_callback_ptr);                 op->_async_callback(op, service, op->_callback_ptr);
         }         }
   
         catch(CIMException &e)  
         {  
                 code = e.getCode();  
                 message = e.getMessage();  
         }  
         catch(Exception &e)         catch(Exception &e)
         {         {
                 code = CIM_ERR_FAILED;          PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
                 message = e.getMessage();              "Exception in ProviderManagerService::responseChunkCallback: " +
                   e.getMessage() + ".  Chunk not delivered.");
         }         }
         catch(...)         catch(...)
         {         {
                 code = CIM_ERR_FAILED;          PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
                 message = cimStatusCodeToString(code);              "Exception in ProviderManagerService::responseChunkCallback.  "
                   "Chunk not delivered.");
         }         }
  
         if (code !=  CIM_ERR_SUCCESS)      PEG_METHOD_EXIT();
                 response.cimException = PEGASUS_CIM_EXCEPTION(code, message);  
 } }
  
 Message* ProviderManagerService::_processMessage(CIMRequestMessage* request) Message* ProviderManagerService::_processMessage(CIMRequestMessage* request)
Line 607 
Line 616 
     Message* response = 0;     Message* response = 0;
  
     if ((request->getType() == CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE) ||     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))         (request->getType() == CIM_NOTIFY_CONFIG_CHANGE_REQUEST_MESSAGE))
     {     {
         if (_basicProviderManagerRouter)         if (_basicProviderManagerRouter)
Line 618 
Line 629 
         {         {
             // Note: These responses do not contain interesting data, so just             // Note: These responses do not contain interesting data, so just
             // use the last one.             // use the last one.
             if (response)  
             {  
                 delete response;                 delete response;
             }  
  
             response = _oopProviderManagerRouter->processMessage(request);             response = _oopProviderManagerRouter->processMessage(request);
         }         }
Line 688 
Line 696 
 { {
     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
         "ProviderManagerService::unloadIdleProviders");         "ProviderManagerService::unloadIdleProviders");
       ThreadStatus rtn = PEGASUS_THREAD_OK;
     // Ensure that only one _unloadIdleProvidersHandler thread runs at a time     // Ensure that only one _unloadIdleProvidersHandler thread runs at a time
     _unloadIdleProvidersBusy++;     _unloadIdleProvidersBusy++;
     if ((_unloadIdleProvidersBusy.value() == 1) &&      if ((_unloadIdleProvidersBusy.get() == 1) &&
         (_thread_pool->allocate_and_awaken(          ((rtn = _thread_pool->allocate_and_awaken(
              (void*)this, ProviderManagerService::_unloadIdleProvidersHandler)))               (void*)this, ProviderManagerService::_unloadIdleProvidersHandler))==PEGASUS_THREAD_OK))
     {     {
         // _unloadIdleProvidersBusy is decremented in         // _unloadIdleProvidersBusy is decremented in
         // _unloadIdleProvidersHandler         // _unloadIdleProvidersHandler
Line 703 
Line 711 
         // If we fail to allocate a thread, don't retry now.         // If we fail to allocate a thread, don't retry now.
         _unloadIdleProvidersBusy--;         _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();     PEG_METHOD_EXIT();
 } }
  
Line 827 
Line 843 
                 AcceptLanguageListContainer cntr = request->operationContext.get(AcceptLanguageListContainer::NAME);                 AcceptLanguageListContainer cntr = request->operationContext.get(AcceptLanguageListContainer::NAME);
         }catch(const Exception &)         }catch(const Exception &)
         {         {
                 request->operationContext.insert(AcceptLanguageListContainer(AcceptLanguages::EMPTY));          request->operationContext.insert(AcceptLanguageListContainer(AcceptLanguageList()));
         }         }
  
         if (_indicationServiceQueueId == PEG_NOT_FOUND)         if (_indicationServiceQueueId == PEG_NOT_FOUND)
Line 853 
Line 869 
         _indicationServiceQueueId);         _indicationServiceQueueId);
  
     providerManagerService->SendForget(asyncRequest);     providerManagerService->SendForget(asyncRequest);
   
   
   
   
   #ifdef PEGASUS_INDICATIONS_Q_THRESHOLD
   
       // See Comments in config.mak asociated with
       //  PEGASUS_INDICATIONS_Q_THRESHOLD
       //
       // if INDICATIONS_Q_STALL THRESHOLD is gt 0
       // then if there are over INDICATIONS_Q_STALL_THRESHOLD
       //           indications in the queue
       //      then force this provider to sleep until the queue count
       //      is lower than INDICATIONS_Q_RESUME_THRESHOLD
   
   static Mutex   indicationThresholdReportedLock;
   static Boolean indicationThresholdReported = false;
   
   #define INDICATIONS_Q_STALL_THRESHOLD PEGASUS_INDICATIONS_Q_THRESHOLD
   #define INDICATIONS_Q_RESUME_THRESHOLD (int)(PEGASUS_INDICATIONS_Q_THRESHOLD*.90)
   #define INDICATIONS_Q_STALL_DURATION 250 // milli-seconds
   
       MessageQueue * indicationsQueue = MessageQueue::lookup(_indicationServiceQueueId);
   
       if (((MessageQueueService *)indicationsQueue)->getIncomingCount() > INDICATIONS_Q_STALL_THRESHOLD)
       {
           AutoMutex indicationThresholdReportedAutoMutex(indicationThresholdReportedLock);
           if (!indicationThresholdReported)
           {
               indicationThresholdReported = true;
               indicationThresholdReportedAutoMutex.unlock();
   
               // make log entry to record que max exceeded
   
               Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
                   "Indication generation stalled: maximum queue count ($0) exceeded.",
                   INDICATIONS_Q_STALL_THRESHOLD);
           }
           else
           {
               indicationThresholdReportedAutoMutex.unlock();
           }
   
           while (((MessageQueueService *)indicationsQueue)->getIncomingCount() > INDICATIONS_Q_RESUME_THRESHOLD)
           {
               pegasus_sleep(INDICATIONS_Q_STALL_DURATION);
           }
   
           AutoMutex indicationThresholdReportedAutoMutex1(indicationThresholdReportedLock);
           //        indicationThresholdReportedLock.lock(pegasus_thread_self());
           if(indicationThresholdReported)
           {
               indicationThresholdReported = false;
               indicationThresholdReportedAutoMutex1.unlock();
   
               Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
                     "Indication generation resumed: current queue count = $0",
                     ((MessageQueueService *)indicationsQueue)->getIncomingCount() );
   
           }
           else
           {
               indicationThresholdReportedAutoMutex1.unlock();
           }
       }
   #endif /* INDICATIONS_Q_STALL_THRESHOLD */
   
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2