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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2