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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2