(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.69

version 1.63, 2005/02/05 23:00:26 version 1.69, 2005/07/19 19:05:35
Line 38 
Line 38 
 //              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)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #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 192 
Line 194 
         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());
              }
          }          }
     }     }
     else     else
Line 218 
Line 230 
     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 264 
         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 275 
         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 289 
  
             if (msg != 0)             if (msg != 0)
             {             {
                         AcceptLanguages* langs =                  AcceptLanguages* langs = new AcceptLanguages(
                     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 302 
             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 607 
Line 621 
     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 688 
Line 704 
 { {
     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.value() == 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 719 
         // 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 853 
Line 877 
         _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.69

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2