(file) Return to OOPProviderManagerRouter.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2 / Attic

Diff for /pegasus/src/Pegasus/ProviderManager2/Attic/OOPProviderManagerRouter.cpp between version 1.20 and 1.25.2.2

version 1.20, 2005/06/29 19:48:10 version 1.25.2.2, 2006/03/15 21:28:36
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 96 
Line 98 
 public: public:
     OutstandingRequestEntry(     OutstandingRequestEntry(
         String messageId_,         String messageId_,
           CIMRequestMessage* requestMessage_,
         CIMResponseMessage*& responseMessage_,         CIMResponseMessage*& responseMessage_,
         Semaphore* responseReady_)         Semaphore* responseReady_)
         : messageId(messageId_),         : messageId(messageId_),
             requestMessage(requestMessage_),
           responseMessage(responseMessage_),           responseMessage(responseMessage_),
           responseReady(responseReady_)           responseReady(responseReady_)
     {     {
     }     }
  
     String messageId;     String messageId;
       CIMRequestMessage* requestMessage;
     CIMResponseMessage*& responseMessage;     CIMResponseMessage*& responseMessage;
     Semaphore* responseReady;     Semaphore* responseReady;
 }; };
Line 123 
Line 128 
     ProviderAgentContainer(     ProviderAgentContainer(
         const String & moduleName,         const String & moduleName,
         const String & userName,         const String & userName,
         PEGASUS_INDICATION_CALLBACK indicationCallback,          PEGASUS_INDICATION_CALLBACK_T indicationCallback,
           PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback,
         Boolean subscriptionInitComplete);         Boolean subscriptionInitComplete);
  
     ~ProviderAgentContainer();     ~ProviderAgentContainer();
Line 175 
Line 181 
         with an error result.         with an error result.
  
         Note: The caller must lock the _agentMutex.         Note: The caller must lock the _agentMutex.
   
           @param cleanShutdown Indicates whether the provider agent process
           exited cleanly.  A value of true indicates that responses have been
           sent for all requests that have been processed.  A value of false
           indicates that one or more requests may have been partially processed.
        */
       void _uninitialize(Boolean cleanShutdown);
   
       /**
           Performs the processMessage work, but does not retry on a transient
           error.
      */      */
     void _uninitialize();      CIMResponseMessage* _processMessage(CIMRequestMessage* request);
  
     /**     /**
         Read and process response messages from the Provider Agent until         Read and process response messages from the Provider Agent until
Line 211 
Line 228 
         Callback function to which all generated indications are sent for         Callback function to which all generated indications are sent for
         processing.         processing.
      */      */
     PEGASUS_INDICATION_CALLBACK _indicationCallback;      PEGASUS_INDICATION_CALLBACK_T _indicationCallback;
   
       /**
           Callback function to which response chunks are sent for processing.
        */
       PEGASUS_RESPONSE_CHUNK_CALLBACK_T _responseChunkCallback;
  
     /**     /**
         Indicates whether the Provider Agent is active.         Indicates whether the Provider Agent is active.
Line 275 
Line 297 
     static Uint32 _maxProviderProcesses;     static Uint32 _maxProviderProcesses;
  
     /**     /**
           A value indicating that a request message has not been processed.
           A CIMResponseMessage pointer with this value indicates that the
           corresponding CIMRequestMessage has not been processed.  This is
           used to indicate that a provider agent exited without starting to
           process the request, and that the request should be retried.
        */
       static CIMResponseMessage* _REQUEST_NOT_PROCESSED;
   
       /**
         Indicates whether the Indication Service has completed initialization.         Indicates whether the Indication Service has completed initialization.
  
         For more information, please see the description of the         For more information, please see the description of the
Line 287 
Line 318 
 Mutex ProviderAgentContainer::_numProviderProcessesMutex; Mutex ProviderAgentContainer::_numProviderProcessesMutex;
 Uint32 ProviderAgentContainer::_maxProviderProcesses = PEG_NOT_FOUND; Uint32 ProviderAgentContainer::_maxProviderProcesses = PEG_NOT_FOUND;
  
   // Set this to a value that no valid CIMResponseMessage* will have.
   CIMResponseMessage* ProviderAgentContainer::_REQUEST_NOT_PROCESSED =
       reinterpret_cast<CIMResponseMessage*>(&_REQUEST_NOT_PROCESSED);
   
 ProviderAgentContainer::ProviderAgentContainer( ProviderAgentContainer::ProviderAgentContainer(
     const String & moduleName,     const String & moduleName,
     const String & userName,     const String & userName,
     PEGASUS_INDICATION_CALLBACK indicationCallback,      PEGASUS_INDICATION_CALLBACK_T indicationCallback,
       PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback,
     Boolean subscriptionInitComplete)     Boolean subscriptionInitComplete)
     : _moduleName(moduleName),     : _moduleName(moduleName),
       _userName(userName),       _userName(userName),
       _indicationCallback(indicationCallback),       _indicationCallback(indicationCallback),
         _responseChunkCallback(responseChunkCallback),
       _isInitialized(false),       _isInitialized(false),
       _subscriptionInitComplete(subscriptionInitComplete)       _subscriptionInitComplete(subscriptionInitComplete)
 { {
Line 335 
Line 372 
     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
         "ProviderAgentContainer::_startAgentProcess");         "ProviderAgentContainer::_startAgentProcess");
  
       //
       // Serialize the starting of agent processes.  If two agent processes are
       // started at the same time, they may get copies of each other's pipe
       // descriptors.  If this happens, the cimserver will not get a pipe read
       // error when one of the agent processes exits, because the pipe will
       // still be writable by the other process.  This locking control needs to
       // cover the period from where the pipes are created to where the agent
       // ends of the pipes are closed by the cimserver.
       //
       static Mutex agentStartupMutex;
       AutoMutex lock(agentStartupMutex);
   
     AutoPtr<AnonymousPipe> pipeFromAgent(new AnonymousPipe());     AutoPtr<AnonymousPipe> pipeFromAgent(new AnonymousPipe());
     AutoPtr<AnonymousPipe> pipeToAgent(new AnonymousPipe());     AutoPtr<AnonymousPipe> pipeToAgent(new AnonymousPipe());
  
Line 623 
Line 672 
             _moduleName));             _moduleName));
     }     }
  
     // Do not wait for a response from the Provider Agent.  (It isn't coming.)      // Wait for a null response from the Provider Agent indicating it has
       // initialized successfully.
   
       CIMMessage* message;
       AnonymousPipe::Status readStatus;
       do
       {
           readStatus = _pipeFromAgent->readMessage(message);
       } while (readStatus == AnonymousPipe::STATUS_INTERRUPT);
   
       if (readStatus != AnonymousPipe::STATUS_SUCCESS)
       {
           PEG_METHOD_EXIT();
           throw Exception(MessageLoaderParms(
               "ProviderManager.OOPProviderManagerRouter."
                   "CIMPROVAGT_COMMUNICATION_FAILED",
               "Failed to communicate with cimprovagt \"$0\".",
               _moduleName));
       }
   
       PEGASUS_ASSERT(message == 0);
  
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
 } }
Line 643 
Line 712 
  
     if (_maxProviderProcesses == PEG_NOT_FOUND)     if (_maxProviderProcesses == PEG_NOT_FOUND)
     {     {
         String maxProviderProcesses = ConfigManager::getInstance()->getCurrentValue("maxProviderProcesses");          String maxProviderProcesses = ConfigManager::getInstance()->
               getCurrentValue("maxProviderProcesses");
         CString maxProviderProcessesString = maxProviderProcesses.getCString();         CString maxProviderProcessesString = maxProviderProcesses.getCString();
         char* end = 0;         char* end = 0;
         _maxProviderProcesses = strtol(maxProviderProcessesString, &end, 10);         _maxProviderProcesses = strtol(maxProviderProcessesString, &end, 10);
Line 757 
Line 827 
 } }
  
 // Note: Caller must lock _agentMutex // Note: Caller must lock _agentMutex
 void ProviderAgentContainer::_uninitialize()  void ProviderAgentContainer::_uninitialize(Boolean cleanShutdown)
 { {
     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
         "ProviderAgentContainer::_uninitialize");         "ProviderAgentContainer::_uninitialize");
Line 811 
Line 881 
         // connection         // connection
         //         //
         {         {
               //
               //  If not a clean shutdown, log a warning message in case module
               //  included indication providers
               //
               if (!cleanShutdown)
               {
                   Logger::put_l(
                       Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
                       "ProviderManager.OOPProviderManagerRouter."
                           "OOP_PROVIDER_MODULE_FAILURE_DETECTED",
                       "A failure was detected in provider module $0.  The"
                           " generation of indications by providers in this module"
                           " may be affected.  To ensure these providers are"
                           " serving active subscriptions, disable and then"
                           " re-enable this module using the cimprovider command.",
                       _moduleName);
               }
   
             AutoMutex tableLock(_outstandingRequestTableMutex);             AutoMutex tableLock(_outstandingRequestTableMutex);
  
               CIMResponseMessage* response =
                   cleanShutdown ? _REQUEST_NOT_PROCESSED : 0;
   
             for (OutstandingRequestTable::Iterator i =             for (OutstandingRequestTable::Iterator i =
                      _outstandingRequestTable.start();                      _outstandingRequestTable.start();
                  i != 0; i++)                  i != 0; i++)
Line 820 
Line 911 
                 PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,                 PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
                     String("Completing messageId \"") + i.value()->messageId +                     String("Completing messageId \"") + i.value()->messageId +
                         "\" with a null response.");                         "\" with a null response.");
                 i.value()->responseMessage = 0;                  i.value()->responseMessage = response;
                 i.value()->responseReady->signal();                 i.value()->responseReady->signal();
             }             }
  
Line 849 
Line 940 
         "ProviderAgentContainer::processMessage");         "ProviderAgentContainer::processMessage");
  
     CIMResponseMessage* response;     CIMResponseMessage* response;
   
       do
       {
           response = _processMessage(request);
   
           if (response == _REQUEST_NOT_PROCESSED)
           {
               // Check for request message types that should not be retried.
               if ((request->getType() ==
                        CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE) ||
                   (request->getType() ==
                        CIM_NOTIFY_CONFIG_CHANGE_REQUEST_MESSAGE) ||
                   (request->getType() ==
                        CIM_SUBSCRIPTION_INIT_COMPLETE_REQUEST_MESSAGE) ||
                   (request->getType() ==
                        CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE))
               {
                   response = request->buildResponse();
                   break;
               }
               else if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE)
               {
                   CIMDisableModuleResponseMessage* dmResponse =
                       dynamic_cast<CIMDisableModuleResponseMessage*>(response);
                   PEGASUS_ASSERT(dmResponse != 0);
   
                   Array<Uint16> operationalStatus;
                   operationalStatus.append(CIM_MSE_OPSTATUS_VALUE_STOPPED);
                   dmResponse->operationalStatus = operationalStatus;
                   break;
               }
           }
       } while (response == _REQUEST_NOT_PROCESSED);
   
       PEG_METHOD_EXIT();
       return response;
   }
   
   CIMResponseMessage* ProviderAgentContainer::_processMessage(
       CIMRequestMessage* request)
   {
       PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
           "ProviderAgentContainer::_processMessage");
   
       CIMResponseMessage* response;
     String originalMessageId = request->messageId;     String originalMessageId = request->messageId;
  
     // These three variables are used for the provider module optimization.     // These three variables are used for the provider module optimization.
Line 875 
Line 1011 
         //         //
         Semaphore waitSemaphore(0);         Semaphore waitSemaphore(0);
         OutstandingRequestEntry outstandingRequestEntry(         OutstandingRequestEntry outstandingRequestEntry(
             uniqueMessageId, response, &waitSemaphore);              uniqueMessageId, request, response, &waitSemaphore);
  
         //         //
         // Lock the Provider Agent Container while initializing the         // Lock the Provider Agent Container while initializing the
Line 959 
Line 1095 
                     Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2,                     Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
                         "Failed to write message to pipe.  writeStatus = %d.",                         "Failed to write message to pipe.  writeStatus = %d.",
                         writeStatus);                         writeStatus);
                     throw Exception(MessageLoaderParms(  
                         "ProviderManager.OOPProviderManagerRouter."                      request->messageId = originalMessageId;
                             "CIMPROVAGT_COMMUNICATION_FAILED",  
                         "Failed to communicate with cimprovagt \"$0\".",                      if (doProviderModuleOptimization)
                         _moduleName));                      {
                           request->operationContext.set(*origProviderId.get());
                       }
   
                       // Remove this OutstandingRequestTable entry
                       {
                           AutoMutex tableLock(_outstandingRequestTableMutex);
                           Boolean removed =
                               _outstandingRequestTable.remove(uniqueMessageId);
                           PEGASUS_ASSERT(removed);
                       }
   
                       // A response value of _REQUEST_NOT_PROCESSED indicates
                       // that the request was not processed by the provider
                       // agent, so it can be retried safely.
                       PEG_METHOD_EXIT();
                       return _REQUEST_NOT_PROCESSED;
                 }                 }
  
                 if (updateProviderModuleCache)                 if (updateProviderModuleCache)
Line 989 
Line 1141 
                         _outstandingRequestTable.remove(uniqueMessageId);                         _outstandingRequestTable.remove(uniqueMessageId);
                     PEGASUS_ASSERT(removed);                     PEGASUS_ASSERT(removed);
                 }                 }
                   PEG_METHOD_EXIT();
                 throw;                 throw;
             }             }
         }         }
Line 1010 
Line 1163 
                     _outstandingRequestTable.remove(uniqueMessageId);                     _outstandingRequestTable.remove(uniqueMessageId);
                 PEGASUS_ASSERT(removed);                 PEGASUS_ASSERT(removed);
             }             }
               PEG_METHOD_EXIT();
             throw;             throw;
         }         }
  
           // A response value of _REQUEST_NOT_PROCESSED indicates that the
           // provider agent process was terminating when the request was sent.
           // The request was not processed by the provider agent, so it can be
           // retried safely.
           if (response == _REQUEST_NOT_PROCESSED)
           {
               PEG_METHOD_EXIT();
               return response;
           }
   
         // A null response is returned when an agent connection is closed         // A null response is returned when an agent connection is closed
         // while requests remain outstanding.         // while requests remain outstanding.
         if (response == 0)         if (response == 0)
Line 1105 
Line 1269 
                 (readStatus == AnonymousPipe::STATUS_CLOSED))                 (readStatus == AnonymousPipe::STATUS_CLOSED))
             {             {
                 AutoMutex lock(_agentMutex);                 AutoMutex lock(_agentMutex);
                 _uninitialize();                  _uninitialize(false);
                   return;
               }
   
               // A null message indicates that the provider agent process has
               // finished its processing and is ready to exit.
               if (message == 0)
               {
                   AutoMutex lock(_agentMutex);
                   _uninitialize(true);
                 return;                 return;
             }             }
  
Line 1116 
Line 1289 
                     reinterpret_cast<CIMProcessIndicationRequestMessage*>(                     reinterpret_cast<CIMProcessIndicationRequestMessage*>(
                         message));                         message));
             }             }
               else if (!message->isComplete())
               {
                   CIMResponseMessage* response;
                   response = dynamic_cast<CIMResponseMessage*>(message);
                   PEGASUS_ASSERT(response != 0);
   
                   // Get the OutstandingRequestEntry for this response chunk
                   OutstandingRequestEntry* _outstandingRequestEntry = 0;
                   {
                       AutoMutex tableLock(_outstandingRequestTableMutex);
                       Boolean foundEntry = _outstandingRequestTable.lookup(
                           response->messageId, _outstandingRequestEntry);
                       PEGASUS_ASSERT(foundEntry);
                   }
   
                   // Put the original message ID into the response
                   response->messageId =
                       _outstandingRequestEntry->requestMessage->messageId;
   
                   // Call the response chunk callback to process the chunk
                   _responseChunkCallback(
                       _outstandingRequestEntry->requestMessage, response);
               }
             else             else
             {             {
                 CIMResponseMessage* response;                 CIMResponseMessage* response;
Line 1170 
Line 1366 
 ///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
  
 OOPProviderManagerRouter::OOPProviderManagerRouter( OOPProviderManagerRouter::OOPProviderManagerRouter(
     PEGASUS_INDICATION_CALLBACK indicationCallback)      PEGASUS_INDICATION_CALLBACK_T indicationCallback,
       PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
 { {
     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
         "OOPProviderManagerRouter::OOPProviderManagerRouter");         "OOPProviderManagerRouter::OOPProviderManagerRouter");
  
     _indicationCallback = indicationCallback;     _indicationCallback = indicationCallback;
       _responseChunkCallback = responseChunkCallback;
     _subscriptionInitComplete = false;     _subscriptionInitComplete = false;
  
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
Line 1201 
Line 1399 
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
 } }
  
 // Private, unimplemented constructor  
 OOPProviderManagerRouter::OOPProviderManagerRouter()  
 {  
 }  
   
 // Private, unimplemented constructor  
 OOPProviderManagerRouter::OOPProviderManagerRouter(  
     const OOPProviderManagerRouter&)  
     : ProviderManagerRouter(*this)  
 {  
 }  
   
 // Private, unimplemented assignment operator  
 OOPProviderManagerRouter& OOPProviderManagerRouter::operator=(  
     const OOPProviderManagerRouter&)  
 {  
     return *this;  
 }  
   
 Message* OOPProviderManagerRouter::processMessage(Message* message) Message* OOPProviderManagerRouter::processMessage(Message* message)
 { {
     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
Line 1551 
Line 1730 
     if (!_providerAgentTable.lookup(key, pa))     if (!_providerAgentTable.lookup(key, pa))
     {     {
         pa = new ProviderAgentContainer(         pa = new ProviderAgentContainer(
             moduleName, userName, _indicationCallback,              moduleName, userName, _indicationCallback, _responseChunkCallback,
             _subscriptionInitComplete);             _subscriptionInitComplete);
         _providerAgentTable.insert(key, pa);         _providerAgentTable.insert(key, pa);
     }     }


Legend:
Removed from v.1.20  
changed lines
  Added in v.1.25.2.2

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2