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

   1 karl  1.75 //%2006////////////////////////////////////////////////////////////////////////
   2 chip  1.1  //
   3 karl  1.59 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
   4            // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   5            // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   6 karl  1.15 // IBM Corp.; EMC Corporation, The Open Group.
   7 karl  1.59 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   9 karl  1.63 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
  10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
  11 karl  1.75 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
  12            // EMC Corporation; Symantec Corporation; The Open Group.
  13 chip  1.1  //
  14            // Permission is hereby granted, free of charge, to any person obtaining a copy
  15            // of this software and associated documentation files (the "Software"), to
  16            // deal in the Software without restriction, including without limitation the
  17            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  18            // sell copies of the Software, and to permit persons to whom the Software is
  19            // furnished to do so, subject to the following conditions:
  20 karl  1.59 // 
  21 chip  1.1  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
  22            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
  23            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  24            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  25            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  26            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  27            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29            //
  30            //==============================================================================
  31            //
  32            // Author: Chip Vincent (cvincent@us.ibm.com)
  33            //
  34            // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
  35            //                  (carolann_graves@hp.com)
  36            //              Mike Day, IBM (mdday@us.ibm.com)
  37            //              Karl Schopmeyer(k.schopmeyer@opengroup.org) - Fix associators.
  38 chip  1.9  //              Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
  39 schuur 1.19 //              Adrian Schuur, IBM (schuur@de.ibm.com)
  40 a.arora 1.37 //              Amit K Arora (amita@in.ibm.com) for PEP-101
  41 kumpf   1.39 //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
  42 se.gupta 1.41 //              Seema Gupta (gseema@in.ibm.com for PEP135)
  43 jim.wunderlich 1.69 //              Jim Wunderlich (Jim_Wunderlich@prodigy.net)
  44 aruran.ms      1.71 //              Aruran, IBM (ashanmug@in.ibm.com)for Bug# 3881
  45 chip           1.1  //
  46                     //%/////////////////////////////////////////////////////////////////////////////
  47                     
  48                     #include "ProviderManagerService.h"
  49                     
  50                     #include <Pegasus/Common/Config.h>
  51 kumpf          1.65 #include <Pegasus/Common/PegasusVersion.h>
  52 chip           1.1  #include <Pegasus/Common/Constants.h>
  53                     #include <Pegasus/Common/CIMMessage.h>
  54 kumpf          1.39 #include <Pegasus/Common/Thread.h>
  55 chip           1.1  #include <Pegasus/Common/Tracer.h>
  56                     #include <Pegasus/Common/Logger.h>
  57 a.arora        1.37 #include <Pegasus/Common/AutoPtr.h>
  58 marek          1.88 #include <Pegasus/Common/Constants.h>
  59 kumpf          1.91 #include <Pegasus/Common/StatisticalData.h>
  60 chip           1.1  
  61 chip           1.6  #include <Pegasus/Config/ConfigManager.h>
  62                     
  63 kumpf          1.39 #include <Pegasus/ProviderManager2/BasicProviderManagerRouter.h>
  64 kumpf          1.51 #include <Pegasus/ProviderManager2/OOPProviderManagerRouter.h>
  65 brian.campbell 1.60 #include <Pegasus/ProviderManager2/OperationResponseHandler.h>
  66 chip           1.17 
  67 chip           1.1  PEGASUS_NAMESPACE_BEGIN
  68                     
  69 chip           1.11 inline Boolean _isSupportedRequestType(const Message * message)
  70                     {
  71                         // ATTN: needs implementation
  72                     
  73                         // for now, assume all requests are valid
  74                     
  75                         return(true);
  76 chip           1.3  }
  77                     
  78                     inline Boolean _isSupportedResponseType(const Message * message)
  79                     {
  80 chip           1.11     // ATTN: needs implementation
  81                     
  82                         // for now, assume all responses are invalid
  83 chip           1.3  
  84 chip           1.11     return(false);
  85 chip           1.3  }
  86                     
  87 schuur         1.19 ProviderManagerService* ProviderManagerService::providerManagerService=NULL;
  88 kumpf          1.39 Uint32 ProviderManagerService::_indicationServiceQueueId = PEG_NOT_FOUND;
  89 schuur         1.19 
  90 schuur         1.25 ProviderManagerService::ProviderManagerService(
  91                             ProviderRegistrationManager * providerRegistrationManager,
  92 mike           1.81         CIMRepository * repository,
  93 kumpf          1.82         ProviderManager* (*createDefaultProviderManagerCallback)())
  94 chip           1.1      : MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP)
  95                     {
  96 schuur         1.19     providerManagerService=this;
  97 schuur         1.25     _repository=repository;
  98 dj.gorey       1.31 
  99 kumpf          1.38     _providerRegistrationManager = providerRegistrationManager;
 100 kumpf          1.44 
 101                         _unloadIdleProvidersBusy = 0;
 102                     
 103 kumpf          1.62     _basicProviderManagerRouter = 0;
 104                         _oopProviderManagerRouter = 0;
 105                     
 106                         // Determine which ProviderManagerRouter(s) to use
 107                     
 108 kumpf          1.89     _forceProviderProcesses = ConfigManager::parseBooleanValue(
 109                             ConfigManager::getInstance()->getCurrentValue(
 110                                 "forceProviderProcesses"));
 111 kumpf          1.62 
 112                     #ifdef PEGASUS_DISABLE_PROV_USERCTXT
 113 kumpf          1.89     if (_forceProviderProcesses)
 114 kumpf          1.51     {
 115 kumpf          1.76         _oopProviderManagerRouter = new OOPProviderManagerRouter(
 116 carolann.graves 1.79             indicationCallback, responseChunkCallback,
 117                                  providerModuleFailureCallback);
 118 kumpf           1.51     }
 119                          else
 120                          {
 121 kumpf           1.76         _basicProviderManagerRouter = new BasicProviderManagerRouter(
 122 mike            1.81             indicationCallback, responseChunkCallback, 
 123 kumpf           1.82             createDefaultProviderManagerCallback);
 124 kumpf           1.62     }
 125                      #else
 126 kumpf           1.76     _oopProviderManagerRouter = new OOPProviderManagerRouter(
 127 carolann.graves 1.79         indicationCallback, responseChunkCallback,
 128                              providerModuleFailureCallback);
 129 kumpf           1.62 
 130 kumpf           1.89     if (!_forceProviderProcesses)
 131 kumpf           1.62     {
 132 kumpf           1.76         _basicProviderManagerRouter = new BasicProviderManagerRouter(
 133 kumpf           1.82             indicationCallback, responseChunkCallback,
 134                                  createDefaultProviderManagerCallback);
 135 kumpf           1.51     }
 136 kumpf           1.62 #endif
 137 chip            1.1  }
 138                      
 139                      ProviderManagerService::~ProviderManagerService(void)
 140                      {
 141 kumpf           1.62     delete _basicProviderManagerRouter;
 142                          delete _oopProviderManagerRouter;
 143 schuur          1.19     providerManagerService=NULL;
 144 chip            1.1  }
 145                      
 146                      Boolean ProviderManagerService::messageOK(const Message * message)
 147                      {
 148                          PEGASUS_ASSERT(message != 0);
 149                      
 150 chip            1.3      if(_isSupportedRequestType(message))
 151 chip            1.1      {
 152 chip            1.3          return(MessageQueueService::messageOK(message));
 153 chip            1.1      }
 154                      
 155 chip            1.3      return(false);
 156 chip            1.1  }
 157                      
 158                      void ProviderManagerService::handleEnqueue(void)
 159                      {
 160                          Message * message = dequeue();
 161                      
 162                          handleEnqueue(message);
 163                      }
 164                      
 165                      void ProviderManagerService::handleEnqueue(Message * message)
 166                      {
 167                          PEGASUS_ASSERT(message != 0);
 168                      
 169                          AsyncLegacyOperationStart * asyncRequest;
 170                      
 171                          if(message->_async != NULL)
 172                          {
 173                              asyncRequest = static_cast<AsyncLegacyOperationStart *>(message->_async);
 174                          }
 175                          else
 176                          {
 177 chip            1.1          asyncRequest = new AsyncLegacyOperationStart(
 178                                  0,
 179                                  this->getQueueId(),
 180                                  message,
 181                                  this->getQueueId());
 182                          }
 183                      
 184                          _handle_async_request(asyncRequest);
 185                      }
 186                      
 187                      void ProviderManagerService::_handle_async_request(AsyncRequest * request)
 188                      {
 189                          PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
 190                              "ProviderManagerService::_handle_async_request");
 191                      
 192                          PEGASUS_ASSERT((request != 0) && (request->op != 0));
 193                      
 194                          if(request->getType() == async_messages::ASYNC_LEGACY_OP_START)
 195                          {
 196                              request->op->processing();
 197                      
 198 mike            1.83         _incomingQueue.insert_back(request->op);
 199 konrad.r        1.68         ThreadStatus rtn = PEGASUS_THREAD_OK;
 200 kumpf           1.77         while (( rtn =_thread_pool->allocate_and_awaken(
 201 konrad.r        1.68                      (void *)this, ProviderManagerService::handleCimOperation)) != PEGASUS_THREAD_OK)
 202 kumpf           1.77         {
 203                                  if (rtn==PEGASUS_THREAD_INSUFFICIENT_RESOURCES)
 204 mike            1.90                 Threads::yield();
 205 kumpf           1.77             else
 206                                  {
 207                                      Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
 208                                          "Not enough threads to service provider manager." );
 209                      
 210                                      Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
 211                                          "Could not allocate thread for %s.",
 212                                          getQueueName());
 213                                      break;
 214                                 }
 215 konrad.r        1.68         }
 216 chip            1.1      }
 217                          else
 218                          {
 219                              // pass all other operations to the default handler
 220                              MessageQueueService::_handle_async_request(request);
 221                          }
 222                      
 223                          PEG_METHOD_EXIT();
 224                      
 225                          return;
 226                      }
 227                      
 228 kumpf           1.57 // Note: This method should not throw an exception.  It is used as a thread
 229                      // entry point, and any exceptions thrown are ignored.
 230 mike            1.90 ThreadReturnType PEGASUS_THREAD_CDECL
 231 kumpf           1.77 ProviderManagerService::handleCimOperation(void* arg)
 232 chip            1.1  {
 233 kumpf           1.39     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
 234                              "ProviderManagerService::handleCimOperation");
 235 chip            1.1  
 236 kumpf           1.67     PEGASUS_ASSERT(arg != 0);
 237 chip            1.8  
 238 chip            1.1      // get the service from argument
 239 kumpf           1.67     ProviderManagerService* service =
 240 kumpf           1.39         reinterpret_cast<ProviderManagerService *>(arg);
 241 kumpf           1.67     PEGASUS_ASSERT(service != 0);
 242 chip            1.1  
 243 kumpf           1.67     try
 244 chip            1.1      {
 245 kumpf           1.67         if (service->_incomingQueue.size() == 0)
 246                              {
 247                                  PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
 248                                      "ProviderManagerService::handleCimOperation() called with no "
 249                                          "op node in queue");
 250 chip            1.1  
 251 kumpf           1.67             PEG_METHOD_EXIT();
 252 mike            1.90             return(ThreadReturnType(1));
 253 kumpf           1.67         }
 254 chip            1.1  
 255 mike            1.83         AsyncOpNode* op = service->_incomingQueue.remove_front();
 256 kumpf           1.87         PEGASUS_ASSERT(op != 0);
 257                              PEGASUS_ASSERT(op->_request.get() != 0);
 258 chip            1.1  
 259 kumpf           1.67         AsyncRequest* request =
 260 kumpf           1.87             static_cast<AsyncRequest*>(op->_request.get());
 261 chip            1.1  
 262 kumpf           1.67         if ((request == 0) ||
 263                                  (request->getType() != async_messages::ASYNC_LEGACY_OP_START))
 264                              {
 265                                  // reply with NAK
 266                                  PEG_METHOD_EXIT();
 267 mike            1.90             return(ThreadReturnType(0));
 268 kumpf           1.67         }
 269 chip            1.1  
 270 kumpf           1.39         Message* legacy =
 271                                  static_cast<AsyncLegacyOperationStart *>(request)->get_action();
 272 chip            1.1  
 273 chip            1.8          if(_isSupportedRequestType(legacy))
 274 chip            1.1          {
 275 a.arora         1.37             AutoPtr<Message> xmessage(legacy);
 276 chip            1.1  
 277 chip            1.8              // Set the client's requested language into this service thread.
 278                                  // This will allow functions in this service to return messages
 279                                  // in the correct language.
 280 kumpf           1.39             CIMMessage* msg = dynamic_cast<CIMMessage *>(legacy);
 281 chip            1.8  
 282 kumpf           1.39             if (msg != 0)
 283 chip            1.8              {
 284 kumpf           1.74                 AcceptLanguageList* langs = new AcceptLanguageList(
 285 kumpf           1.67                     ((AcceptLanguageListContainer)msg->operationContext.get(
 286                                              AcceptLanguageListContainer::NAME)).getLanguages());
 287 chip            1.8                  Thread::setLanguages(langs);
 288                                  }
 289                                  else
 290                                  {
 291                                      Thread::clearLanguages();
 292                                  }
 293 chip            1.1  
 294                                  service->handleCimRequest(op, legacy);
 295 chip            1.3          }
 296 chip            1.8      }
 297 konrad.r        1.66     catch (const Exception& e)
 298 kumpf           1.67     {
 299 konrad.r        1.66         PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
 300 kumpf           1.67             "Unexpected exception in handleCimOperation: " + e.getMessage());
 301                          }
 302 konrad.r        1.66     catch (...)
 303 kumpf           1.67     {
 304 konrad.r        1.66         PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
 305 kumpf           1.67             "Unexpected exception in handleCimOperation.");
 306                          }
 307 chip            1.1  
 308                          PEG_METHOD_EXIT();
 309                      
 310 mike            1.90     return(ThreadReturnType(0));
 311 chip            1.1  }
 312                      
 313 kumpf           1.39 void ProviderManagerService::handleCimRequest(
 314                          AsyncOpNode * op,
 315                          Message * message)
 316 chip            1.1  {
 317 kumpf           1.39     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
 318                              "ProviderManagerService::handleCimRequest");
 319 chip            1.1  
 320 kumpf           1.38     CIMRequestMessage * request = dynamic_cast<CIMRequestMessage *>(message);
 321                          PEGASUS_ASSERT(request != 0);
 322 chip            1.1  
 323                          // get request from op node
 324 kumpf           1.87     AsyncRequest * async = static_cast<AsyncRequest *>(op->_request.get());
 325 kumpf           1.38     PEGASUS_ASSERT(async != 0);
 326                      
 327                          Message * response = 0;
 328 kumpf           1.58     Boolean consumerLookupFailed = false;
 329 chip            1.1  
 330 kumpf           1.58     if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE)
 331                          {
 332                              //
 333                              // Get a ProviderIdContainer for ExportIndicationRequestMessage.
 334                              // Note: This can be removed when the CIMExportRequestDispatcher
 335                              // is updated to add the ProviderIdContainer to the message.
 336                              //
 337                              CIMInstance providerModule;
 338                              CIMInstance provider;
 339                              const CIMExportIndicationRequestMessage* expRequest =
 340                                  dynamic_cast<const CIMExportIndicationRequestMessage*>(request);
 341                              if (_providerRegistrationManager->lookupIndicationConsumer(
 342                                      expRequest->destinationPath, provider, providerModule))
 343                              {
 344                                  request->operationContext.insert(
 345                                      ProviderIdContainer(providerModule, provider));
 346                              }
 347                              else
 348                              {
 349                                  consumerLookupFailed = true;
 350                              }
 351 kumpf           1.58     }
 352                      
 353                          if (consumerLookupFailed)
 354                          {
 355                              CIMResponseMessage* cimResponse = request->buildResponse();
 356                              cimResponse->cimException = PEGASUS_CIM_EXCEPTION(
 357                                  CIM_ERR_NOT_SUPPORTED, String::EMPTY);
 358                              response = cimResponse;
 359                          }
 360                          else if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) ||
 361 kumpf           1.46         (dynamic_cast<CIMIndicationRequestMessage*>(request) != 0) ||
 362 kumpf           1.40         (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) ||
 363 kumpf           1.45         (request->getType() == CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE))
 364 kumpf           1.38     {
 365 kumpf           1.45         // Handle CIMOperationRequestMessage, CIMExportIndicationRequestMessage,
 366 kumpf           1.46         // CIMIndicationRequestMessage, and CIMInitializeProviderRequestMessage.
 367                              // (These should be blocked when the provider module is disabled.)
 368 kumpf           1.45 
 369 kumpf           1.46         //
 370                              // Get the provider module instance to check for a disabled module
 371                              //
 372                              CIMInstance providerModule;
 373 kumpf           1.45 
 374 kumpf           1.58         // The provider ID container is added to the OperationContext
 375                              // by the CIMOperationRequestDispatcher for all CIM operation
 376                              // requests to providers, so it does not need to be added again.
 377                              // CIMInitializeProviderRequestMessage also has a provider ID
 378                              // container.
 379                              ProviderIdContainer pidc =
 380                                  request->operationContext.get(ProviderIdContainer::NAME);
 381                              providerModule = pidc.getModule();
 382 kumpf           1.38 
 383 kumpf           1.45         //
 384                              // Check if the target provider is disabled
 385                              //
 386                              Boolean moduleDisabled = false;
 387                              Uint32 pos = providerModule.findProperty(CIMName("OperationalStatus"));
 388                              PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
 389                              Array<Uint16> operationalStatus;
 390                              providerModule.getProperty(pos).getValue().get(operationalStatus);
 391                      
 392                              for(Uint32 i = 0; i < operationalStatus.size(); i++)
 393                              {
 394 kumpf           1.50             if ((operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED) ||
 395                                      (operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING))
 396 kumpf           1.45             {
 397                                      moduleDisabled = true;
 398                                      break;
 399                                  }
 400                              }
 401                      
 402                              if (moduleDisabled)
 403                              {
 404                                  //
 405                                  // Send a "provider blocked" response
 406                                  //
 407                                  CIMResponseMessage* cimResponse = request->buildResponse();
 408                                  cimResponse->cimException = PEGASUS_CIM_EXCEPTION_L(
 409                                      CIM_ERR_ACCESS_DENIED,
 410                                      MessageLoaderParms(
 411                                          "ProviderManager.ProviderManagerService.PROVIDER_BLOCKED",
 412                                          "provider blocked."));
 413                                  response = cimResponse;
 414 w.white         1.70 
 415                                   STAT_COPYDISPATCHER
 416 kumpf           1.45         }
 417                              else
 418                              {
 419                                  //
 420                                  // Forward the request to the appropriate ProviderManagerRouter
 421                                  //
 422 kumpf           1.62             response = _processMessage(request);
 423 kumpf           1.45         }
 424 schuur          1.19     }
 425 kumpf           1.38     else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE)
 426                          {
 427                              // Handle CIMEnableModuleRequestMessage
 428                              CIMEnableModuleRequestMessage * emReq =
 429                                  dynamic_cast<CIMEnableModuleRequestMessage*>(request);
 430                      
 431                              CIMInstance providerModule = emReq->providerModule;
 432 dj.gorey        1.31 
 433 kumpf           1.38         try
 434                              {
 435 kumpf           1.39             // Forward the request to the ProviderManager
 436 kumpf           1.62             response = _processMessage(request);
 437 kumpf           1.38 
 438                                  // If successful, update provider module status to OK
 439                                  // ATTN: Use CIMEnableModuleResponseMessage operationalStatus?
 440                                  CIMEnableModuleResponseMessage * emResp =
 441                                      dynamic_cast<CIMEnableModuleResponseMessage*>(response);
 442                                  if (emResp->cimException.getCode() == CIM_ERR_SUCCESS)
 443                                  {
 444 carolann.graves 1.80                 //
 445                                      //  On a successful enable, remove Stopped status and
 446                                      //  append OK status
 447                                      //
 448                                      Array<Uint16> removeStatus;
 449                                      Array<Uint16> appendStatus;
 450                                      removeStatus.append (CIM_MSE_OPSTATUS_VALUE_STOPPED);
 451                                      appendStatus.append (CIM_MSE_OPSTATUS_VALUE_OK);
 452 kumpf           1.38                 _updateProviderModuleStatus(
 453 carolann.graves 1.80                     providerModule, removeStatus, appendStatus);
 454 kumpf           1.38             }
 455                              }
 456                              catch (Exception& e)
 457                              {
 458                                  // Get the OperationalStatus property from the provider module
 459                                  Array<Uint16> operationalStatus;
 460                                  CIMValue itValue = emReq->providerModule.getProperty(
 461                                      emReq->providerModule.findProperty("OperationalStatus"))
 462                                          .getValue();
 463                                  itValue.get(operationalStatus);
 464                      
 465 kumpf           1.78             delete response;
 466 kumpf           1.38 
 467                                  response = new CIMEnableModuleResponseMessage(
 468                                      request->messageId,
 469                                      CIMException(CIM_ERR_FAILED, e.getMessage()),
 470                                      request->queueIds.copyAndPop(),
 471                                      operationalStatus);
 472                              }
 473                          }
 474                          else if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE)
 475                          {
 476                              // Handle CIMDisableModuleRequestMessage
 477                              CIMDisableModuleRequestMessage * dmReq =
 478                                  dynamic_cast<CIMDisableModuleRequestMessage*>(request);
 479                      
 480                              CIMInstance providerModule = dmReq->providerModule;
 481                              Boolean updateModuleStatus = !dmReq->disableProviderOnly;
 482                      
 483                              try
 484                              {
 485 carolann.graves 1.80             //
 486                                  //  On issuing a disable request, append Stopping status
 487                                  //  Do not remove existing status
 488                                  //
 489 kumpf           1.38             if (updateModuleStatus)
 490                                  {
 491 carolann.graves 1.80                 Array<Uint16> removeStatus;
 492                                      Array<Uint16> appendStatus;
 493                                      appendStatus.append (CIM_MSE_OPSTATUS_VALUE_STOPPING);
 494 kumpf           1.38                 _updateProviderModuleStatus(
 495 carolann.graves 1.80                     providerModule, removeStatus, appendStatus);
 496 kumpf           1.38             }
 497                      
 498 kumpf           1.39             // Forward the request to the ProviderManager
 499 kumpf           1.62             response = _processMessage(request);
 500 kumpf           1.38 
 501                                  // Update provider module status based on success or failure
 502                                  if (updateModuleStatus)
 503                                  {
 504                                      CIMDisableModuleResponseMessage * dmResp =
 505                                          dynamic_cast<CIMDisableModuleResponseMessage*>(response);
 506                                      if (dmResp->cimException.getCode() != CIM_ERR_SUCCESS)
 507                                      {
 508 carolann.graves 1.80                     //
 509                                          //  On an unsuccessful disable, remove Stopping status
 510                                          //
 511                                          Array<Uint16> removeStatus;
 512                                          Array<Uint16> appendStatus;
 513                                          removeStatus.append (CIM_MSE_OPSTATUS_VALUE_STOPPING);
 514 kumpf           1.38                     _updateProviderModuleStatus(
 515 carolann.graves 1.80                         providerModule, removeStatus, appendStatus);
 516 kumpf           1.38                 }
 517                                      else
 518                                      {
 519                                          // Disable may or may not have been successful,
 520                                          // depending on whether there are outstanding requests.
 521 carolann.graves 1.80                     // Remove Stopping status
 522                                          // Append status, if any, from disable module response
 523                                          Array<Uint16> removeStatus;
 524                                          Array<Uint16> appendStatus;
 525                                          removeStatus.append (CIM_MSE_OPSTATUS_VALUE_STOPPING);
 526                                          if (dmResp->operationalStatus.size() > 0)
 527                                          {
 528                                              //
 529                                              //  On a successful disable, remove an OK or a Degraded
 530                                              //  status, if present
 531                                              //
 532                                              if (dmResp->operationalStatus[
 533                                                  dmResp->operationalStatus.size()-1] ==
 534                                                  CIM_MSE_OPSTATUS_VALUE_STOPPED)
 535                                              {
 536                                                  removeStatus.append (CIM_MSE_OPSTATUS_VALUE_OK);
 537                                                  removeStatus.append
 538                                                      (CIM_MSE_OPSTATUS_VALUE_DEGRADED);
 539                                              }
 540                                              appendStatus.append (dmResp->operationalStatus[
 541                                                  dmResp->operationalStatus.size()-1]);
 542 carolann.graves 1.80                     }
 543 kumpf           1.38                     _updateProviderModuleStatus(
 544 carolann.graves 1.80                         providerModule, removeStatus, appendStatus);
 545 kumpf           1.38                 }
 546                                  }
 547                              }
 548                              catch (Exception& e)
 549                              {
 550                                  // Get the OperationalStatus property from the provider module
 551                                  Array<Uint16> operationalStatus;
 552                                  CIMValue itValue = dmReq->providerModule.getProperty(
 553                                      dmReq->providerModule.findProperty("OperationalStatus"))
 554                                          .getValue();
 555                                  itValue.get(operationalStatus);
 556                      
 557 kumpf           1.78             delete response;
 558 kumpf           1.38 
 559                                  response = new CIMDisableModuleResponseMessage(
 560                                      request->messageId,
 561                                      CIMException(CIM_ERR_FAILED, e.getMessage()),
 562                                      request->queueIds.copyAndPop(),
 563                                      operationalStatus);
 564                              }
 565                          }
 566                          else
 567                          {
 568 kumpf           1.62         response = _processMessage(request);
 569 schuur          1.23     }
 570 chip            1.13 
 571 schuur          1.19     AsyncLegacyOperationResult * async_result =
 572                              new AsyncLegacyOperationResult(
 573                              op,
 574                              response);
 575 chip            1.13 
 576 schuur          1.19     _complete_op_node(op, ASYNC_OPSTATE_COMPLETE, 0, 0);
 577 chip            1.13 
 578 schuur          1.19     PEG_METHOD_EXIT();
 579                      }
 580 chip            1.13 
 581 kumpf           1.76 void ProviderManagerService::responseChunkCallback(
 582                          CIMRequestMessage* request,
 583                          CIMResponseMessage* response)
 584 brian.campbell  1.60 {
 585 kumpf           1.77     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
 586                              "ProviderManagerService::responseChunkCallback");
 587 brian.campbell  1.60 
 588 kumpf           1.77     try
 589                          {
 590                              // only incomplete messages are processed because the caller ends up
 591                              // sending the complete() stage
 592                              PEGASUS_ASSERT(response->isComplete() == false);
 593                      
 594                              AsyncLegacyOperationStart *requestAsync =
 595                                  dynamic_cast<AsyncLegacyOperationStart *>(request->_async);
 596                              PEGASUS_ASSERT(requestAsync);
 597                              AsyncOpNode *op = requestAsync->op;
 598                              PEGASUS_ASSERT(op);
 599                              PEGASUS_ASSERT(!response->_async);
 600                              response->_async = new AsyncLegacyOperationResult(
 601 kumpf           1.86             op, response);
 602 kumpf           1.77 
 603                              // set the destination
 604                              op->_op_dest = op->_callback_response_q;
 605                      
 606                              MessageQueueService *service =
 607                                  dynamic_cast<MessageQueueService *>(op->_callback_response_q);
 608                      
 609                              PEGASUS_ASSERT(service);
 610                      
 611                              // the last chunk MUST be sent last, so use execute the callback
 612                              // not all chunks are going through the dispatcher's chunk
 613                              // resequencer, so this must be a synchronous call here
 614                              // After the call is done, response and asyncResponse are now invalid
 615                              // as they have been sent and deleted externally
 616 brian.campbell  1.60 
 617 kumpf           1.77         op->_async_callback(op, service, op->_callback_ptr);
 618                          }
 619                          catch(Exception &e)
 620                          {
 621                              PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
 622                                  "Exception in ProviderManagerService::responseChunkCallback: " +
 623                                      e.getMessage() + ".  Chunk not delivered.");
 624                          }
 625                          catch(...)
 626                          {
 627                              PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
 628                                  "Exception in ProviderManagerService::responseChunkCallback.  "
 629                                      "Chunk not delivered.");
 630                          }
 631                      
 632                          PEG_METHOD_EXIT();
 633 brian.campbell  1.60 }
 634                      
 635 kumpf           1.62 Message* ProviderManagerService::_processMessage(CIMRequestMessage* request)
 636                      {
 637                          Message* response = 0;
 638                      
 639                          if ((request->getType() == CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE) ||
 640 kumpf           1.77         (request->getType() ==
 641 carolann.graves 1.64             CIM_SUBSCRIPTION_INIT_COMPLETE_REQUEST_MESSAGE) ||
 642 kumpf           1.62         (request->getType() == CIM_NOTIFY_CONFIG_CHANGE_REQUEST_MESSAGE))
 643                          {
 644                              if (_basicProviderManagerRouter)
 645                              {
 646                                  response = _basicProviderManagerRouter->processMessage(request);
 647                              }
 648                      
 649                              if (_oopProviderManagerRouter)
 650                              {
 651                                  // Note: These responses do not contain interesting data, so just
 652                                  // use the last one.
 653 kumpf           1.78             delete response;
 654 kumpf           1.62 
 655                                  response = _oopProviderManagerRouter->processMessage(request);
 656                              }
 657                          }
 658                          else
 659                          {
 660                              CIMInstance providerModule;
 661                      
 662                              if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE)
 663                              {
 664                                  CIMEnableModuleRequestMessage* emReq =
 665                                      dynamic_cast<CIMEnableModuleRequestMessage*>(request);
 666                                  providerModule = emReq->providerModule;
 667                              }
 668                              else if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE)
 669                              {
 670                                  CIMDisableModuleRequestMessage* dmReq =
 671                                      dynamic_cast<CIMDisableModuleRequestMessage*>(request);
 672                                  providerModule = dmReq->providerModule;
 673                              }
 674                              else
 675 kumpf           1.62         {
 676                                  ProviderIdContainer pidc =
 677                                      request->operationContext.get(ProviderIdContainer::NAME);
 678                                  providerModule = pidc.getModule();
 679 marek           1.88 #ifdef PEGASUS_ZOS_SECURITY
 680                                  if (request->getType() != CIM_EXPORT_INDICATION_REQUEST_MESSAGE)
 681                                  {
 682                                      // this is a z/OS only function
 683                                      // the function checks user authorization
 684                                      // based on CIM operation versus provider profile
 685                                      // Input: request and Provider ID Container
 686                                      //Return: failure: a response message for the client
 687                                      //        success: NULL 
 688                                      response = checkSAFProviderProfile(request, pidc);
 689                                      if (response != NULL)
 690                                      {
 691                                          return response;
 692                                      }
 693                                  }
 694                      #endif
 695 kumpf           1.62         }
 696                      
 697 carolann.graves 1.79         Uint16 userContext = PEGASUS_DEFAULT_PROV_USERCTXT;
 698 kumpf           1.62         Uint32 pos = providerModule.findProperty(
 699                                  PEGASUS_PROPERTYNAME_MODULE_USERCONTEXT);
 700                              if (pos != PEG_NOT_FOUND)
 701                              {
 702                                  providerModule.getProperty(pos).getValue().get(userContext);
 703                              }
 704                      
 705                              // Forward the request to the appropriate ProviderManagerRouter, based
 706                              // on the CIM Server configuration and the UserContext setting.
 707                      
 708 kumpf           1.89         if (_forceProviderProcesses
 709 kumpf           1.62 #ifndef PEGASUS_DISABLE_PROV_USERCTXT
 710                                  || (userContext == PG_PROVMODULE_USERCTXT_REQUESTOR)
 711                                  || (userContext == PG_PROVMODULE_USERCTXT_DESIGNATED)
 712                                  || ((userContext == PG_PROVMODULE_USERCTXT_PRIVILEGED) &&
 713                                      !System::isPrivilegedUser(System::getEffectiveUserName()))
 714                      #endif
 715                                 )
 716                              {
 717                                  response = _oopProviderManagerRouter->processMessage(request);
 718                              }
 719                              else
 720                              {
 721                                  response = _basicProviderManagerRouter->processMessage(request);
 722                              }
 723                          }
 724                      
 725                          return response;
 726                      }
 727                      
 728 kumpf           1.44 void ProviderManagerService::unloadIdleProviders()
 729                      {
 730                          PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
 731                              "ProviderManagerService::unloadIdleProviders");
 732 konrad.r        1.68     ThreadStatus rtn = PEGASUS_THREAD_OK;
 733 kumpf           1.44     // Ensure that only one _unloadIdleProvidersHandler thread runs at a time
 734                          _unloadIdleProvidersBusy++;
 735 mike            1.72     if ((_unloadIdleProvidersBusy.get() == 1) &&
 736 konrad.r        1.68         ((rtn = _thread_pool->allocate_and_awaken(
 737                                   (void*)this, ProviderManagerService::_unloadIdleProvidersHandler))==PEGASUS_THREAD_OK))
 738 kumpf           1.44     {
 739                              // _unloadIdleProvidersBusy is decremented in
 740                              // _unloadIdleProvidersHandler
 741                          }
 742                          else
 743                          {
 744                              // If we fail to allocate a thread, don't retry now.
 745                              _unloadIdleProvidersBusy--;
 746                          }
 747 kumpf           1.77     if (rtn != PEGASUS_THREAD_OK)
 748 konrad.r        1.68     {
 749 kumpf           1.77         Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
 750                                  "Not enough threads to unload idle providers.");
 751                      
 752                              Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
 753                                  "Could not allocate thread for %s to unload idle providers.",
 754                                  getQueueName());
 755 konrad.r        1.68     }
 756 kumpf           1.44     PEG_METHOD_EXIT();
 757                      }
 758                      
 759 mike            1.90 ThreadReturnType PEGASUS_THREAD_CDECL
 760 kumpf           1.44 ProviderManagerService::_unloadIdleProvidersHandler(void* arg) throw()
 761 chip            1.1  {
 762 kumpf           1.44     try
 763                          {
 764                              PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
 765                                  "ProviderManagerService::unloadIdleProvidersHandler");
 766                      
 767                              ProviderManagerService* myself =
 768                                  reinterpret_cast<ProviderManagerService*>(arg);
 769                      
 770 kumpf           1.62         if (myself->_basicProviderManagerRouter)
 771 kumpf           1.44         {
 772 kumpf           1.62             try
 773                                  {
 774                                      myself->_basicProviderManagerRouter->unloadIdleProviders();
 775                                  }
 776                                  catch (...)
 777                                  {
 778                                      // Ignore errors
 779                                      PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
 780                                          "Unexpected exception from "
 781                                              "BasicProviderManagerRouter::_unloadIdleProviders");
 782                                  }
 783 kumpf           1.44         }
 784 kumpf           1.62 
 785                              if (myself->_oopProviderManagerRouter)
 786 kumpf           1.44         {
 787 kumpf           1.62             try
 788                                  {
 789                                      myself->_oopProviderManagerRouter->unloadIdleProviders();
 790                                  }
 791                                  catch (...)
 792                                  {
 793                                      // Ignore errors
 794                                      PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
 795                                          "Unexpected exception from "
 796                                              "OOPProviderManagerRouter::_unloadIdleProviders");
 797                                  }
 798 kumpf           1.44         }
 799                      
 800                              myself->_unloadIdleProvidersBusy--;
 801                              PEG_METHOD_EXIT();
 802                          }
 803                          catch (...)
 804                          {
 805                              // Ignore errors
 806                              PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
 807                                  "Unexpected exception in _unloadIdleProvidersHandler");
 808                          }
 809                      
 810 mike            1.90     return(ThreadReturnType(0));
 811 kumpf           1.38 }
 812                      
 813                      // Updates the providerModule instance and the ProviderRegistrationManager
 814 carolann.graves 1.79 //
 815                      // This method is used to update the provider module status when the module is
 816                      // disabled or enabled.  If a Degraded status has been set (appended) to the
 817                      // OperationalStatus, it is cleared (removed) when the module is disabled or
 818                      // enabled.
 819                      //
 820 kumpf           1.38 void ProviderManagerService::_updateProviderModuleStatus(
 821                          CIMInstance& providerModule,
 822 carolann.graves 1.80     const Array<Uint16>& removeStatus,
 823                          const Array<Uint16>& appendStatus)
 824 kumpf           1.38 {
 825                          PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
 826                              "ProviderManagerService::_updateProviderModuleStatus");
 827                      
 828                          Array<Uint16> operationalStatus;
 829                          String providerModuleName;
 830                      
 831                          Uint32 pos = providerModule.findProperty(CIMName("Name"));
 832                          PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
 833                          providerModule.getProperty(pos).getValue().get(providerModuleName);
 834                      
 835                          //
 836                          // get operational status
 837                          //
 838                          pos = providerModule.findProperty(CIMName("OperationalStatus"));
 839                          PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
 840                          CIMProperty operationalStatusProperty = providerModule.getProperty(pos);
 841                      
 842 carolann.graves 1.80     if (_providerRegistrationManager->updateProviderModuleStatus(
 843                              providerModuleName, removeStatus, appendStatus, operationalStatus) ==
 844                              false)
 845 kumpf           1.38     {
 846                              throw PEGASUS_CIM_EXCEPTION_L(
 847                                  CIM_ERR_FAILED,
 848                                  MessageLoaderParms(
 849                                      "ProviderManager.ProviderManagerService."
 850                                          "SET_MODULE_STATUS_FAILED",
 851                                      "set module status failed."));
 852                          }
 853                      
 854                          operationalStatusProperty.setValue(CIMValue(operationalStatus));
 855                      
 856                          PEG_METHOD_EXIT();
 857 kumpf           1.39 }
 858                      
 859                      void ProviderManagerService::indicationCallback(
 860                          CIMProcessIndicationRequestMessage* request)
 861                      {
 862 a.dunfey        1.85     if(request->operationContext.contains(AcceptLanguageListContainer::NAME))
 863 kumpf           1.77     {
 864                              AcceptLanguageListContainer cntr = request->operationContext.get(AcceptLanguageListContainer::NAME);
 865 a.dunfey        1.85     }
 866                          else
 867 kumpf           1.77     {
 868                              request->operationContext.insert(AcceptLanguageListContainer(AcceptLanguageList()));
 869                          }
 870                      
 871                          if (_indicationServiceQueueId == PEG_NOT_FOUND)
 872 kumpf           1.39     {
 873                              Array<Uint32> serviceIds;
 874                      
 875                              providerManagerService->find_services(
 876                                  PEGASUS_QUEUENAME_INDICATIONSERVICE, 0, 0, &serviceIds);
 877                              PEGASUS_ASSERT(serviceIds.size() != 0);
 878                      
 879                              _indicationServiceQueueId = serviceIds[0];
 880                          }
 881                      
 882                          request->queueIds = QueueIdStack(
 883                              _indicationServiceQueueId, providerManagerService->getQueueId());
 884                      
 885                          AsyncLegacyOperationStart * asyncRequest =
 886                              new AsyncLegacyOperationStart(
 887                              0,
 888                              _indicationServiceQueueId,
 889                              request,
 890                              _indicationServiceQueueId);
 891                      
 892                          providerManagerService->SendForget(asyncRequest);
 893 jim.wunderlich  1.69 
 894                      
 895                      
 896                      
 897                      #ifdef PEGASUS_INDICATIONS_Q_THRESHOLD
 898                      
 899 kumpf           1.77     // See Comments in config.mak asociated with
 900 jim.wunderlich  1.69     //  PEGASUS_INDICATIONS_Q_THRESHOLD
 901                          //
 902                          // if INDICATIONS_Q_STALL THRESHOLD is gt 0
 903                          // then if there are over INDICATIONS_Q_STALL_THRESHOLD
 904 kumpf           1.77     //           indications in the queue
 905 jim.wunderlich  1.69     //      then force this provider to sleep until the queue count
 906                          //      is lower than INDICATIONS_Q_RESUME_THRESHOLD
 907                      
 908                      static Mutex   indicationThresholdReportedLock;
 909                      static Boolean indicationThresholdReported = false;
 910                      
 911                      #define INDICATIONS_Q_STALL_THRESHOLD PEGASUS_INDICATIONS_Q_THRESHOLD
 912                      #define INDICATIONS_Q_RESUME_THRESHOLD (int)(PEGASUS_INDICATIONS_Q_THRESHOLD*.90)
 913                      #define INDICATIONS_Q_STALL_DURATION 250 // milli-seconds
 914                      
 915                          MessageQueue * indicationsQueue = MessageQueue::lookup(_indicationServiceQueueId);
 916                      
 917                          if (((MessageQueueService *)indicationsQueue)->getIncomingCount() > INDICATIONS_Q_STALL_THRESHOLD)
 918 kumpf           1.77     {
 919 jim.wunderlich  1.69         AutoMutex indicationThresholdReportedAutoMutex(indicationThresholdReportedLock);
 920                              if (!indicationThresholdReported)
 921 kumpf           1.77         {
 922 jim.wunderlich  1.69             indicationThresholdReported = true;
 923                                  indicationThresholdReportedAutoMutex.unlock();
 924                      
 925 kumpf           1.77             // make log entry to record que max exceeded
 926 jim.wunderlich  1.69 
 927                                  Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
 928 kumpf           1.77                 "Indication generation stalled: maximum queue count ($0) exceeded.",
 929 jim.wunderlich  1.69                 INDICATIONS_Q_STALL_THRESHOLD);
 930 kumpf           1.77         }
 931                              else
 932                              {
 933 jim.wunderlich  1.69             indicationThresholdReportedAutoMutex.unlock();
 934 kumpf           1.77         }
 935 jim.wunderlich  1.69 
 936                              while (((MessageQueueService *)indicationsQueue)->getIncomingCount() > INDICATIONS_Q_RESUME_THRESHOLD)
 937 kumpf           1.77         {
 938 mike            1.90             Threads::sleep(INDICATIONS_Q_STALL_DURATION);
 939 kumpf           1.77         }
 940 jim.wunderlich  1.69 
 941                              AutoMutex indicationThresholdReportedAutoMutex1(indicationThresholdReportedLock);
 942 mike            1.90         //        indicationThresholdReportedLock.lock();
 943 jim.wunderlich  1.69         if(indicationThresholdReported)
 944 kumpf           1.77         {
 945 jim.wunderlich  1.69             indicationThresholdReported = false;
 946                                  indicationThresholdReportedAutoMutex1.unlock();
 947 kumpf           1.77 
 948 jim.wunderlich  1.69             Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
 949 kumpf           1.77                   "Indication generation resumed: current queue count = $0",
 950 jim.wunderlich  1.69                   ((MessageQueueService *)indicationsQueue)->getIncomingCount() );
 951                      
 952 kumpf           1.77         }
 953 jim.wunderlich  1.69         else
 954 kumpf           1.77         {
 955 jim.wunderlich  1.69             indicationThresholdReportedAutoMutex1.unlock();
 956 kumpf           1.77         }
 957                          }
 958 jim.wunderlich  1.69 #endif /* INDICATIONS_Q_STALL_THRESHOLD */
 959                      
 960 chip            1.1  }
 961                      
 962 carolann.graves 1.79 void ProviderManagerService::providerModuleFailureCallback
 963                          (const String & moduleName,
 964                           const String & userName,
 965                           Uint16 userContext)
 966                      {
 967                          PEG_METHOD_ENTER (TRC_PROVIDERMANAGER,
 968                              "ProviderManagerService::providerModuleFailureCallback");
 969                      
 970                          if (userContext == PG_PROVMODULE_USERCTXT_REQUESTOR)
 971                          {
 972                              Logger::put_l (
 973                                  Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
 974                                  "ProviderManager.OOPProviderManagerRouter."
 975                                      "OOP_PROVIDER_MODULE_USER_CTXT_FAILURE_DETECTED", 
 976                                  "A failure was detected in provider module $0 with"
 977                                      " user context $1.",
 978                                  moduleName, userName);
 979                          }
 980                          else  //  not requestor context
 981                          {
 982                              Logger::put_l (
 983 carolann.graves 1.79             Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
 984                                  "ProviderManager.OOPProviderManagerRouter."
 985                                      "OOP_PROVIDER_MODULE_FAILURE_DETECTED", 
 986                                  "A failure was detected in provider module $0.",
 987                                  moduleName);
 988                          }
 989                                      
 990                          //
 991                          //  Create Notify Provider Fail request message
 992                          //
 993                          CIMNotifyProviderFailRequestMessage * request =
 994                              new CIMNotifyProviderFailRequestMessage
 995                                  (XmlWriter::getNextMessageId (),
 996                                  moduleName,
 997                                  userName,
 998                                  QueueIdStack ());
 999                      
1000                          //
1001                          //  Send Notify Provider Fail request message to Indication Service
1002                          //
1003                          if (_indicationServiceQueueId == PEG_NOT_FOUND)
1004 carolann.graves 1.79     {
1005                              Array <Uint32> serviceIds;
1006                       
1007                              providerManagerService->find_services
1008                                  (PEGASUS_QUEUENAME_INDICATIONSERVICE, 0, 0, &serviceIds);
1009                              PEGASUS_ASSERT (serviceIds.size () != 0);
1010                      
1011                              _indicationServiceQueueId = serviceIds [0];
1012                          }
1013                      
1014                          request->queueIds = QueueIdStack
1015                              (_indicationServiceQueueId, providerManagerService->getQueueId ());
1016                      
1017 kumpf           1.86     AsyncLegacyOperationStart * asyncRequest = new AsyncLegacyOperationStart(
1018 carolann.graves 1.79         0,
1019                              _indicationServiceQueueId,
1020                              request,
1021                              _indicationServiceQueueId);
1022                      
1023                          AutoPtr <AsyncReply> asyncReply
1024                              (providerManagerService->SendWait (asyncRequest));
1025                      
1026                          AutoPtr <CIMNotifyProviderFailResponseMessage> response
1027                              (reinterpret_cast <CIMNotifyProviderFailResponseMessage *>
1028                                  ((dynamic_cast <AsyncLegacyOperationResult *>
1029                                  (asyncReply.get ()))->get_result ()));
1030                      
1031                          if (response->cimException.getCode () != CIM_ERR_SUCCESS)
1032                          {
1033                              PEG_TRACE_STRING (TRC_DISCARDED_DATA, Tracer::LEVEL2,
1034                                  "Unexpected exception in providerModuleFailureCallback: " +
1035                                  response->cimException.getMessage ());
1036                          }
1037                          else
1038                          {
1039 carolann.graves 1.79         //
1040                              //  Successful response
1041                              //  Examine result to see if any subscriptions were affected
1042                              //
1043                              if (response->numSubscriptionsAffected > 0)
1044                              {
1045                                  //
1046                                  //  Subscriptions were affected
1047                                  //  Update the provider module status to Degraded
1048                                  //
1049 carolann.graves 1.80             try
1050 carolann.graves 1.79             {
1051 carolann.graves 1.80                 CIMInstance providerModule;
1052                                      CIMKeyBinding keyBinding(
1053                                          _PROPERTY_PROVIDERMODULE_NAME,
1054                                          moduleName,
1055                                          CIMKeyBinding::STRING);
1056                                      Array<CIMKeyBinding> kbArray;
1057                                      kbArray.append(keyBinding);
1058                                      CIMObjectPath modulePath("", PEGASUS_NAMESPACENAME_INTEROP,
1059                                          PEGASUS_CLASSNAME_PROVIDERMODULE, kbArray);
1060                                      providerModule = 
1061                                          providerManagerService->_providerRegistrationManager->
1062                                              getInstance(
1063                                                  modulePath, false, false, CIMPropertyList());
1064                      
1065                                      Array<Uint16> removeStatus;
1066                                      Array<Uint16> appendStatus;
1067                                      removeStatus.append(CIM_MSE_OPSTATUS_VALUE_OK);
1068                                      appendStatus.append(CIM_MSE_OPSTATUS_VALUE_DEGRADED);
1069                                      providerManagerService->_updateProviderModuleStatus(
1070                                          providerModule, removeStatus, appendStatus);
1071 carolann.graves 1.79             }
1072 carolann.graves 1.80             catch (const Exception & e)
1073 carolann.graves 1.79             {
1074 carolann.graves 1.80                 PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
1075                                          "Failed to update provider module status: " +
1076                                          e.getMessage());
1077 carolann.graves 1.79             }
1078                      
1079                                  //
1080                                  //  Log a warning message since subscriptions were affected
1081                                  //
1082                                  Logger::put_l (
1083                                      Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1084                                      "ProviderManager.OOPProviderManagerRouter."
1085                                          "OOP_PROVIDER_MODULE_SUBSCRIPTIONS_AFFECTED", 
1086                                      "The generation of indications by providers in module $0 "
1087                                      "may be affected.  To ensure these providers are serving "
1088                                      "active subscriptions, disable and then re-enable this "
1089 carolann.graves 1.80                 "module using the cimprovider command.",
1090                                      moduleName);
1091 carolann.graves 1.79         }
1092                          }
1093 carolann.graves 1.80 
1094                          PEG_METHOD_EXIT();
1095 carolann.graves 1.79 }
1096                      
1097 a.arora         1.37 PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2