(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                              _incomingQueue.enqueue(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 kumpf           1.67         AsyncOpNode* op = service->_incomingQueue.dequeue();
 261 chip            1.1  
 262 kumpf           1.67         if ((op == 0) || (op->_request.count() == 0))
 263                              {
 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                                  static_cast<AsyncRequest*>(op->_request.next(0));
 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                          AsyncRequest * async = static_cast<AsyncRequest *>(op->_request.next(0));
 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->getKey(),
 590                              async->getRouting(),
 591                              op,
 592                              response);
 593 chip            1.13 
 594 schuur          1.19     _complete_op_node(op, ASYNC_OPSTATE_COMPLETE, 0, 0);
 595 chip            1.13 
 596 schuur          1.19     PEG_METHOD_EXIT();
 597                      }
 598 chip            1.13 
 599 kumpf           1.76 void ProviderManagerService::responseChunkCallback(
 600                          CIMRequestMessage* request,
 601                          CIMResponseMessage* response)
 602 brian.campbell  1.60 {
 603 kumpf           1.77     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
 604                              "ProviderManagerService::responseChunkCallback");
 605 brian.campbell  1.60 
 606 kumpf           1.77     try
 607                          {
 608                              // only incomplete messages are processed because the caller ends up
 609                              // sending the complete() stage
 610                              PEGASUS_ASSERT(response->isComplete() == false);
 611                      
 612                              AsyncLegacyOperationStart *requestAsync =
 613                                  dynamic_cast<AsyncLegacyOperationStart *>(request->_async);
 614                              PEGASUS_ASSERT(requestAsync);
 615                              AsyncOpNode *op = requestAsync->op;
 616                              PEGASUS_ASSERT(op);
 617                              PEGASUS_ASSERT(!response->_async);
 618                              response->_async = new AsyncLegacyOperationResult(
 619                                  requestAsync->getKey(), requestAsync->getRouting(), op, response);
 620                      
 621                              // set the destination
 622                              op->_op_dest = op->_callback_response_q;
 623                      
 624                              MessageQueueService *service =
 625                                  dynamic_cast<MessageQueueService *>(op->_callback_response_q);
 626                      
 627 kumpf           1.77         PEGASUS_ASSERT(service);
 628                      
 629                              // the last chunk MUST be sent last, so use execute the callback
 630                              // not all chunks are going through the dispatcher's chunk
 631                              // resequencer, so this must be a synchronous call here
 632                              // After the call is done, response and asyncResponse are now invalid
 633                              // as they have been sent and deleted externally
 634 brian.campbell  1.60 
 635 kumpf           1.77         op->_async_callback(op, service, op->_callback_ptr);
 636                          }
 637                          catch(Exception &e)
 638                          {
 639                              PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
 640                                  "Exception in ProviderManagerService::responseChunkCallback: " +
 641                                      e.getMessage() + ".  Chunk not delivered.");
 642                          }
 643                          catch(...)
 644                          {
 645                              PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
 646                                  "Exception in ProviderManagerService::responseChunkCallback.  "
 647                                      "Chunk not delivered.");
 648                          }
 649                      
 650                          PEG_METHOD_EXIT();
 651 brian.campbell  1.60 }
 652                      
 653 kumpf           1.62 Message* ProviderManagerService::_processMessage(CIMRequestMessage* request)
 654                      {
 655                          Message* response = 0;
 656                      
 657                          if ((request->getType() == CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE) ||
 658 kumpf           1.77         (request->getType() ==
 659 carolann.graves 1.64             CIM_SUBSCRIPTION_INIT_COMPLETE_REQUEST_MESSAGE) ||
 660 kumpf           1.62         (request->getType() == CIM_NOTIFY_CONFIG_CHANGE_REQUEST_MESSAGE))
 661                          {
 662                              if (_basicProviderManagerRouter)
 663                              {
 664                                  response = _basicProviderManagerRouter->processMessage(request);
 665                              }
 666                      
 667                              if (_oopProviderManagerRouter)
 668                              {
 669                                  // Note: These responses do not contain interesting data, so just
 670                                  // use the last one.
 671 kumpf           1.78             delete response;
 672 kumpf           1.62 
 673                                  response = _oopProviderManagerRouter->processMessage(request);
 674                              }
 675                          }
 676                          else
 677                          {
 678                              CIMInstance providerModule;
 679                      
 680                              if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE)
 681                              {
 682                                  CIMEnableModuleRequestMessage* emReq =
 683                                      dynamic_cast<CIMEnableModuleRequestMessage*>(request);
 684                                  providerModule = emReq->providerModule;
 685                              }
 686                              else if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE)
 687                              {
 688                                  CIMDisableModuleRequestMessage* dmReq =
 689                                      dynamic_cast<CIMDisableModuleRequestMessage*>(request);
 690                                  providerModule = dmReq->providerModule;
 691                              }
 692                              else
 693 kumpf           1.62         {
 694                                  ProviderIdContainer pidc =
 695                                      request->operationContext.get(ProviderIdContainer::NAME);
 696                                  providerModule = pidc.getModule();
 697                              }
 698                      
 699 carolann.graves 1.79         Uint16 userContext = PEGASUS_DEFAULT_PROV_USERCTXT;
 700 kumpf           1.62         Uint32 pos = providerModule.findProperty(
 701                                  PEGASUS_PROPERTYNAME_MODULE_USERCONTEXT);
 702                              if (pos != PEG_NOT_FOUND)
 703                              {
 704                                  providerModule.getProperty(pos).getValue().get(userContext);
 705                              }
 706                      
 707                              // Forward the request to the appropriate ProviderManagerRouter, based
 708                              // on the CIM Server configuration and the UserContext setting.
 709                      
 710                              ConfigManager* configManager = ConfigManager::getInstance();
 711                              Boolean forceProviderProcesses = String::equal(
 712                                  configManager->getCurrentValue("forceProviderProcesses"), "true");
 713                      
 714                              if (forceProviderProcesses
 715                      #ifndef PEGASUS_DISABLE_PROV_USERCTXT
 716                                  || (userContext == PG_PROVMODULE_USERCTXT_REQUESTOR)
 717                                  || (userContext == PG_PROVMODULE_USERCTXT_DESIGNATED)
 718                                  || ((userContext == PG_PROVMODULE_USERCTXT_PRIVILEGED) &&
 719                                      !System::isPrivilegedUser(System::getEffectiveUserName()))
 720                      #endif
 721 kumpf           1.62            )
 722                              {
 723                                  response = _oopProviderManagerRouter->processMessage(request);
 724                              }
 725                              else
 726                              {
 727                                  response = _basicProviderManagerRouter->processMessage(request);
 728                              }
 729                          }
 730                      
 731                          return response;
 732                      }
 733                      
 734 kumpf           1.44 void ProviderManagerService::unloadIdleProviders()
 735                      {
 736                          PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
 737                              "ProviderManagerService::unloadIdleProviders");
 738 konrad.r        1.68     ThreadStatus rtn = PEGASUS_THREAD_OK;
 739 kumpf           1.44     // Ensure that only one _unloadIdleProvidersHandler thread runs at a time
 740                          _unloadIdleProvidersBusy++;
 741 mike            1.72     if ((_unloadIdleProvidersBusy.get() == 1) &&
 742 konrad.r        1.68         ((rtn = _thread_pool->allocate_and_awaken(
 743                                   (void*)this, ProviderManagerService::_unloadIdleProvidersHandler))==PEGASUS_THREAD_OK))
 744 kumpf           1.44     {
 745                              // _unloadIdleProvidersBusy is decremented in
 746                              // _unloadIdleProvidersHandler
 747                          }
 748                          else
 749                          {
 750                              // If we fail to allocate a thread, don't retry now.
 751                              _unloadIdleProvidersBusy--;
 752                          }
 753 kumpf           1.77     if (rtn != PEGASUS_THREAD_OK)
 754 konrad.r        1.68     {
 755 kumpf           1.77         Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
 756                                  "Not enough threads to unload idle providers.");
 757                      
 758                              Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
 759                                  "Could not allocate thread for %s to unload idle providers.",
 760                                  getQueueName());
 761 konrad.r        1.68     }
 762 kumpf           1.44     PEG_METHOD_EXIT();
 763                      }
 764                      
 765                      PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL
 766                      ProviderManagerService::_unloadIdleProvidersHandler(void* arg) throw()
 767 chip            1.1  {
 768 kumpf           1.44     try
 769                          {
 770                              PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
 771                                  "ProviderManagerService::unloadIdleProvidersHandler");
 772                      
 773                              ProviderManagerService* myself =
 774                                  reinterpret_cast<ProviderManagerService*>(arg);
 775                      
 776 kumpf           1.62         if (myself->_basicProviderManagerRouter)
 777 kumpf           1.44         {
 778 kumpf           1.62             try
 779                                  {
 780                                      myself->_basicProviderManagerRouter->unloadIdleProviders();
 781                                  }
 782                                  catch (...)
 783                                  {
 784                                      // Ignore errors
 785                                      PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
 786                                          "Unexpected exception from "
 787                                              "BasicProviderManagerRouter::_unloadIdleProviders");
 788                                  }
 789 kumpf           1.44         }
 790 kumpf           1.62 
 791                              if (myself->_oopProviderManagerRouter)
 792 kumpf           1.44         {
 793 kumpf           1.62             try
 794                                  {
 795                                      myself->_oopProviderManagerRouter->unloadIdleProviders();
 796                                  }
 797                                  catch (...)
 798                                  {
 799                                      // Ignore errors
 800                                      PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
 801                                          "Unexpected exception from "
 802                                              "OOPProviderManagerRouter::_unloadIdleProviders");
 803                                  }
 804 kumpf           1.44         }
 805                      
 806                              myself->_unloadIdleProvidersBusy--;
 807                              PEG_METHOD_EXIT();
 808                          }
 809                          catch (...)
 810                          {
 811                              // Ignore errors
 812                              PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
 813                                  "Unexpected exception in _unloadIdleProvidersHandler");
 814                          }
 815                      
 816                          return(PEGASUS_THREAD_RETURN(0));
 817 kumpf           1.38 }
 818                      
 819                      // Updates the providerModule instance and the ProviderRegistrationManager
 820 carolann.graves 1.79 //
 821                      // This method is used to update the provider module status when the module is
 822                      // disabled or enabled.  If a Degraded status has been set (appended) to the
 823                      // OperationalStatus, it is cleared (removed) when the module is disabled or
 824                      // enabled.
 825                      //
 826 kumpf           1.38 void ProviderManagerService::_updateProviderModuleStatus(
 827                          CIMInstance& providerModule,
 828 carolann.graves 1.80     const Array<Uint16>& removeStatus,
 829                          const Array<Uint16>& appendStatus)
 830 kumpf           1.38 {
 831                          PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
 832                              "ProviderManagerService::_updateProviderModuleStatus");
 833                      
 834                          Array<Uint16> operationalStatus;
 835                          String providerModuleName;
 836                      
 837                          Uint32 pos = providerModule.findProperty(CIMName("Name"));
 838                          PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
 839                          providerModule.getProperty(pos).getValue().get(providerModuleName);
 840                      
 841                          //
 842                          // get operational status
 843                          //
 844                          pos = providerModule.findProperty(CIMName("OperationalStatus"));
 845                          PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
 846                          CIMProperty operationalStatusProperty = providerModule.getProperty(pos);
 847                      
 848 carolann.graves 1.80     if (_providerRegistrationManager->updateProviderModuleStatus(
 849                              providerModuleName, removeStatus, appendStatus, operationalStatus) ==
 850                              false)
 851 kumpf           1.38     {
 852                              throw PEGASUS_CIM_EXCEPTION_L(
 853                                  CIM_ERR_FAILED,
 854                                  MessageLoaderParms(
 855                                      "ProviderManager.ProviderManagerService."
 856                                          "SET_MODULE_STATUS_FAILED",
 857                                      "set module status failed."));
 858                          }
 859                      
 860                          operationalStatusProperty.setValue(CIMValue(operationalStatus));
 861                      
 862                          PEG_METHOD_EXIT();
 863 kumpf           1.39 }
 864                      
 865                      void ProviderManagerService::indicationCallback(
 866                          CIMProcessIndicationRequestMessage* request)
 867                      {
 868 kumpf           1.77     try
 869                          {
 870                              AcceptLanguageListContainer cntr = request->operationContext.get(AcceptLanguageListContainer::NAME);
 871                          }catch(const Exception &)
 872                          {
 873                              request->operationContext.insert(AcceptLanguageListContainer(AcceptLanguageList()));
 874                          }
 875                      
 876                          if (_indicationServiceQueueId == PEG_NOT_FOUND)
 877 kumpf           1.39     {
 878                              Array<Uint32> serviceIds;
 879                      
 880                              providerManagerService->find_services(
 881                                  PEGASUS_QUEUENAME_INDICATIONSERVICE, 0, 0, &serviceIds);
 882                              PEGASUS_ASSERT(serviceIds.size() != 0);
 883                      
 884                              _indicationServiceQueueId = serviceIds[0];
 885                          }
 886                      
 887                          request->queueIds = QueueIdStack(
 888                              _indicationServiceQueueId, providerManagerService->getQueueId());
 889                      
 890                          AsyncLegacyOperationStart * asyncRequest =
 891                              new AsyncLegacyOperationStart(
 892                              providerManagerService->get_next_xid(),
 893                              0,
 894                              _indicationServiceQueueId,
 895                              request,
 896                              _indicationServiceQueueId);
 897                      
 898 kumpf           1.39     providerManagerService->SendForget(asyncRequest);
 899 jim.wunderlich  1.69 
 900                      
 901                      
 902                      
 903                      #ifdef PEGASUS_INDICATIONS_Q_THRESHOLD
 904                      
 905 kumpf           1.77     // See Comments in config.mak asociated with
 906 jim.wunderlich  1.69     //  PEGASUS_INDICATIONS_Q_THRESHOLD
 907                          //
 908                          // if INDICATIONS_Q_STALL THRESHOLD is gt 0
 909                          // then if there are over INDICATIONS_Q_STALL_THRESHOLD
 910 kumpf           1.77     //           indications in the queue
 911 jim.wunderlich  1.69     //      then force this provider to sleep until the queue count
 912                          //      is lower than INDICATIONS_Q_RESUME_THRESHOLD
 913                      
 914                      static Mutex   indicationThresholdReportedLock;
 915                      static Boolean indicationThresholdReported = false;
 916                      
 917                      #define INDICATIONS_Q_STALL_THRESHOLD PEGASUS_INDICATIONS_Q_THRESHOLD
 918                      #define INDICATIONS_Q_RESUME_THRESHOLD (int)(PEGASUS_INDICATIONS_Q_THRESHOLD*.90)
 919                      #define INDICATIONS_Q_STALL_DURATION 250 // milli-seconds
 920                      
 921                          MessageQueue * indicationsQueue = MessageQueue::lookup(_indicationServiceQueueId);
 922                      
 923                          if (((MessageQueueService *)indicationsQueue)->getIncomingCount() > INDICATIONS_Q_STALL_THRESHOLD)
 924 kumpf           1.77     {
 925 jim.wunderlich  1.69         AutoMutex indicationThresholdReportedAutoMutex(indicationThresholdReportedLock);
 926                              if (!indicationThresholdReported)
 927 kumpf           1.77         {
 928 jim.wunderlich  1.69             indicationThresholdReported = true;
 929                                  indicationThresholdReportedAutoMutex.unlock();
 930                      
 931 kumpf           1.77             // make log entry to record que max exceeded
 932 jim.wunderlich  1.69 
 933                                  Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
 934 kumpf           1.77                 "Indication generation stalled: maximum queue count ($0) exceeded.",
 935 jim.wunderlich  1.69                 INDICATIONS_Q_STALL_THRESHOLD);
 936 kumpf           1.77         }
 937                              else
 938                              {
 939 jim.wunderlich  1.69             indicationThresholdReportedAutoMutex.unlock();
 940 kumpf           1.77         }
 941 jim.wunderlich  1.69 
 942                              while (((MessageQueueService *)indicationsQueue)->getIncomingCount() > INDICATIONS_Q_RESUME_THRESHOLD)
 943 kumpf           1.77         {
 944 jim.wunderlich  1.69             pegasus_sleep(INDICATIONS_Q_STALL_DURATION);
 945 kumpf           1.77         }
 946 jim.wunderlich  1.69 
 947                              AutoMutex indicationThresholdReportedAutoMutex1(indicationThresholdReportedLock);
 948                              //        indicationThresholdReportedLock.lock(pegasus_thread_self());
 949                              if(indicationThresholdReported)
 950 kumpf           1.77         {
 951 jim.wunderlich  1.69             indicationThresholdReported = false;
 952                                  indicationThresholdReportedAutoMutex1.unlock();
 953 kumpf           1.77 
 954 jim.wunderlich  1.69             Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
 955 kumpf           1.77                   "Indication generation resumed: current queue count = $0",
 956 jim.wunderlich  1.69                   ((MessageQueueService *)indicationsQueue)->getIncomingCount() );
 957                      
 958 kumpf           1.77         }
 959 jim.wunderlich  1.69         else
 960 kumpf           1.77         {
 961 jim.wunderlich  1.69             indicationThresholdReportedAutoMutex1.unlock();
 962 kumpf           1.77         }
 963                          }
 964 jim.wunderlich  1.69 #endif /* INDICATIONS_Q_STALL_THRESHOLD */
 965                      
 966 chip            1.1  }
 967                      
 968 carolann.graves 1.79 void ProviderManagerService::providerModuleFailureCallback
 969                          (const String & moduleName,
 970                           const String & userName,
 971                           Uint16 userContext)
 972                      {
 973                          PEG_METHOD_ENTER (TRC_PROVIDERMANAGER,
 974                              "ProviderManagerService::providerModuleFailureCallback");
 975                      
 976                          if (userContext == PG_PROVMODULE_USERCTXT_REQUESTOR)
 977                          {
 978                              Logger::put_l (
 979                                  Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
 980                                  "ProviderManager.OOPProviderManagerRouter."
 981                                      "OOP_PROVIDER_MODULE_USER_CTXT_FAILURE_DETECTED", 
 982                                  "A failure was detected in provider module $0 with"
 983                                      " user context $1.",
 984                                  moduleName, userName);
 985                          }
 986                          else  //  not requestor context
 987                          {
 988                              Logger::put_l (
 989 carolann.graves 1.79             Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
 990                                  "ProviderManager.OOPProviderManagerRouter."
 991                                      "OOP_PROVIDER_MODULE_FAILURE_DETECTED", 
 992                                  "A failure was detected in provider module $0.",
 993                                  moduleName);
 994                          }
 995                                      
 996                          //
 997                          //  Create Notify Provider Fail request message
 998                          //
 999                          CIMNotifyProviderFailRequestMessage * request =
1000                              new CIMNotifyProviderFailRequestMessage
1001                                  (XmlWriter::getNextMessageId (),
1002                                  moduleName,
1003                                  userName,
1004                                  QueueIdStack ());
1005                      
1006                          //
1007                          //  Send Notify Provider Fail request message to Indication Service
1008                          //
1009                          if (_indicationServiceQueueId == PEG_NOT_FOUND)
1010 carolann.graves 1.79     {
1011                              Array <Uint32> serviceIds;
1012                       
1013                              providerManagerService->find_services
1014                                  (PEGASUS_QUEUENAME_INDICATIONSERVICE, 0, 0, &serviceIds);
1015                              PEGASUS_ASSERT (serviceIds.size () != 0);
1016                      
1017                              _indicationServiceQueueId = serviceIds [0];
1018                          }
1019                      
1020                          request->queueIds = QueueIdStack
1021                              (_indicationServiceQueueId, providerManagerService->getQueueId ());
1022                      
1023                          AsyncLegacyOperationStart * asyncRequest = new AsyncLegacyOperationStart
1024                              (providerManagerService->get_next_xid (),
1025                              0,
1026                              _indicationServiceQueueId,
1027                              request,
1028                              _indicationServiceQueueId);
1029                      
1030                          AutoPtr <AsyncReply> asyncReply
1031 carolann.graves 1.79         (providerManagerService->SendWait (asyncRequest));
1032                      
1033                          AutoPtr <CIMNotifyProviderFailResponseMessage> response
1034                              (reinterpret_cast <CIMNotifyProviderFailResponseMessage *>
1035                                  ((dynamic_cast <AsyncLegacyOperationResult *>
1036                                  (asyncReply.get ()))->get_result ()));
1037                      
1038                          if (response->cimException.getCode () != CIM_ERR_SUCCESS)
1039                          {
1040                              PEG_TRACE_STRING (TRC_DISCARDED_DATA, Tracer::LEVEL2,
1041                                  "Unexpected exception in providerModuleFailureCallback: " +
1042                                  response->cimException.getMessage ());
1043                          }
1044                          else
1045                          {
1046                              //
1047                              //  Successful response
1048                              //  Examine result to see if any subscriptions were affected
1049                              //
1050                              if (response->numSubscriptionsAffected > 0)
1051                              {
1052 carolann.graves 1.79             //
1053                                  //  Subscriptions were affected
1054                                  //  Update the provider module status to Degraded
1055                                  //
1056 carolann.graves 1.80             try
1057 carolann.graves 1.79             {
1058 carolann.graves 1.80                 CIMInstance providerModule;
1059                                      CIMKeyBinding keyBinding(
1060                                          _PROPERTY_PROVIDERMODULE_NAME,
1061                                          moduleName,
1062                                          CIMKeyBinding::STRING);
1063                                      Array<CIMKeyBinding> kbArray;
1064                                      kbArray.append(keyBinding);
1065                                      CIMObjectPath modulePath("", PEGASUS_NAMESPACENAME_INTEROP,
1066                                          PEGASUS_CLASSNAME_PROVIDERMODULE, kbArray);
1067                                      providerModule = 
1068                                          providerManagerService->_providerRegistrationManager->
1069                                              getInstance(
1070                                                  modulePath, false, false, CIMPropertyList());
1071                      
1072                                      Array<Uint16> removeStatus;
1073                                      Array<Uint16> appendStatus;
1074                                      removeStatus.append(CIM_MSE_OPSTATUS_VALUE_OK);
1075                                      appendStatus.append(CIM_MSE_OPSTATUS_VALUE_DEGRADED);
1076                                      providerManagerService->_updateProviderModuleStatus(
1077                                          providerModule, removeStatus, appendStatus);
1078 carolann.graves 1.79             }
1079 carolann.graves 1.80             catch (const Exception & e)
1080 carolann.graves 1.79             {
1081 carolann.graves 1.80                 PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
1082                                          "Failed to update provider module status: " +
1083                                          e.getMessage());
1084 carolann.graves 1.79             }
1085                      
1086                                  //
1087                                  //  Log a warning message since subscriptions were affected
1088                                  //
1089                                  Logger::put_l (
1090                                      Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1091                                      "ProviderManager.OOPProviderManagerRouter."
1092                                          "OOP_PROVIDER_MODULE_SUBSCRIPTIONS_AFFECTED", 
1093                                      "The generation of indications by providers in module $0 "
1094                                      "may be affected.  To ensure these providers are serving "
1095                                      "active subscriptions, disable and then re-enable this "
1096 carolann.graves 1.80                 "module using the cimprovider command.",
1097                                      moduleName);
1098 carolann.graves 1.79         }
1099                          }
1100 carolann.graves 1.80 
1101                          PEG_METHOD_EXIT();
1102 carolann.graves 1.79 }
1103                      
1104 a.arora         1.37 PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2