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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2