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

  1 karl  1.59 //%2004////////////////////////////////////////////////////////////////////////
  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 chip  1.1  //
 10            // Permission is hereby granted, free of charge, to any person obtaining a copy
 11            // of this software and associated documentation files (the "Software"), to
 12            // deal in the Software without restriction, including without limitation the
 13            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 14            // sell copies of the Software, and to permit persons to whom the Software is
 15            // furnished to do so, subject to the following conditions:
 16 karl  1.59 // 
 17 chip  1.1  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 18            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 19            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 20            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 21            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 22            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 23            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 24            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 25            //
 26            //==============================================================================
 27            //
 28            // Author: Chip Vincent (cvincent@us.ibm.com)
 29            //
 30            // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
 31            //                  (carolann_graves@hp.com)
 32            //              Mike Day, IBM (mdday@us.ibm.com)
 33            //              Karl Schopmeyer(k.schopmeyer@opengroup.org) - Fix associators.
 34 chip  1.9  //              Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
 35 schuur 1.19 //              Adrian Schuur, IBM (schuur@de.ibm.com)
 36 a.arora 1.37 //              Amit K Arora (amita@in.ibm.com) for PEP-101
 37 kumpf   1.39 //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 38 se.gupta 1.41 //              Seema Gupta (gseema@in.ibm.com for PEP135)
 39 chip     1.1  //
 40               //%/////////////////////////////////////////////////////////////////////////////
 41               
 42               #include "ProviderManagerService.h"
 43               
 44               #include <Pegasus/Common/Config.h>
 45               #include <Pegasus/Common/Constants.h>
 46               #include <Pegasus/Common/CIMMessage.h>
 47 kumpf    1.39 #include <Pegasus/Common/Thread.h>
 48 chip     1.1  #include <Pegasus/Common/Tracer.h>
 49               #include <Pegasus/Common/Logger.h>
 50 a.arora  1.37 #include <Pegasus/Common/AutoPtr.h>
 51 kumpf    1.50 #include <Pegasus/Common/Constants.h>
 52 chip     1.1  
 53 chip     1.6  #include <Pegasus/Config/ConfigManager.h>
 54               
 55 kumpf    1.39 #include <Pegasus/ProviderManager2/BasicProviderManagerRouter.h>
 56 kumpf    1.51 #include <Pegasus/ProviderManager2/OOPProviderManagerRouter.h>
 57 chip     1.17 
 58 chip     1.1  PEGASUS_NAMESPACE_BEGIN
 59               
 60 chip     1.11 inline Boolean _isSupportedRequestType(const Message * message)
 61               {
 62                   // ATTN: needs implementation
 63               
 64                   // for now, assume all requests are valid
 65               
 66                   return(true);
 67 chip     1.3  }
 68               
 69               inline Boolean _isSupportedResponseType(const Message * message)
 70               {
 71 chip     1.11     // ATTN: needs implementation
 72               
 73                   // for now, assume all responses are invalid
 74 chip     1.3  
 75 chip     1.11     return(false);
 76 chip     1.3  }
 77               
 78 schuur   1.19 ProviderManagerService* ProviderManagerService::providerManagerService=NULL;
 79 kumpf    1.39 Uint32 ProviderManagerService::_indicationServiceQueueId = PEG_NOT_FOUND;
 80 schuur   1.19 
 81 chip     1.1  ProviderManagerService::ProviderManagerService(void)
 82                   : MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP)
 83               {
 84 schuur   1.19     providerManagerService=this;
 85 chip     1.1  }
 86               
 87 schuur   1.25 ProviderManagerService::ProviderManagerService(
 88                       ProviderRegistrationManager * providerRegistrationManager,
 89                       CIMRepository * repository)
 90 chip     1.1      : MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP)
 91               {
 92 schuur   1.19     providerManagerService=this;
 93 schuur   1.25     _repository=repository;
 94 dj.gorey 1.31 
 95 kumpf    1.38     _providerRegistrationManager = providerRegistrationManager;
 96 kumpf    1.44 
 97                   _unloadIdleProvidersBusy = 0;
 98               
 99 kumpf    1.51     // Determine whether Out-of-Process Provider support is enabled
100                   ConfigManager* configManager = ConfigManager::getInstance();
101                   if (String::equal(
102                       configManager->getCurrentValue("enableProviderProcesses"), "true"))
103                   {
104                       _providerManagerRouter =
105                           new OOPProviderManagerRouter(indicationCallback);
106                   }
107                   else
108                   {
109                       _providerManagerRouter =
110                           new BasicProviderManagerRouter(indicationCallback);
111                   }
112 chip     1.1  }
113               
114               ProviderManagerService::~ProviderManagerService(void)
115               {
116 kumpf    1.39     delete _providerManagerRouter;
117 schuur   1.19     providerManagerService=NULL;
118 chip     1.1  }
119               
120               Boolean ProviderManagerService::messageOK(const Message * message)
121               {
122                   PEGASUS_ASSERT(message != 0);
123               
124 chip     1.3      if(_isSupportedRequestType(message))
125 chip     1.1      {
126 chip     1.3          return(MessageQueueService::messageOK(message));
127 chip     1.1      }
128               
129 chip     1.3      return(false);
130 chip     1.1  }
131               
132               void ProviderManagerService::handleEnqueue(void)
133               {
134                   Message * message = dequeue();
135               
136                   handleEnqueue(message);
137               }
138               
139               void ProviderManagerService::handleEnqueue(Message * message)
140               {
141                   PEGASUS_ASSERT(message != 0);
142               
143                   AsyncLegacyOperationStart * asyncRequest;
144               
145                   if(message->_async != NULL)
146                   {
147                       asyncRequest = static_cast<AsyncLegacyOperationStart *>(message->_async);
148                   }
149                   else
150                   {
151 chip     1.1          asyncRequest = new AsyncLegacyOperationStart(
152                           get_next_xid(),
153                           0,
154                           this->getQueueId(),
155                           message,
156                           this->getQueueId());
157                   }
158               
159                   _handle_async_request(asyncRequest);
160               }
161               
162               void ProviderManagerService::_handle_async_request(AsyncRequest * request)
163               {
164                   PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
165                       "ProviderManagerService::_handle_async_request");
166               
167                   PEGASUS_ASSERT((request != 0) && (request->op != 0));
168               
169                   if(request->getType() == async_messages::ASYNC_LEGACY_OP_START)
170                   {
171                       request->op->processing();
172 chip     1.1  
173                       _incomingQueue.enqueue(request->op);
174               
175 denise.eckstein 1.59.2.1         ThreadStatus rtn = PEGASUS_THREAD_OK;
176                                  while (( rtn =_thread_pool->allocate_and_awaken(
177                                      (void *)this, ProviderManagerService::handleCimOperation)) !=
178                                       PEGASUS_THREAD_OK)
179                                  {
180                                     if (rtn==PEGASUS_THREAD_INSUFFICIENT_RESOURCES)
181                                         pegasus_yield();
182                                     else
183                                     {
184                                         Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
185                                                  "Not enough threads to service provider manager." );
186                          
187                                         Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
188                                                  "Could not allocate thread for %s.",
189                                                   getQueueName());
190                                         break;
191                                     }
192                                  }
193 chip            1.1          }
194                              else
195                              {
196                                  // pass all other operations to the default handler
197                                  MessageQueueService::_handle_async_request(request);
198                              }
199                          
200                              PEG_METHOD_EXIT();
201                          
202                              return;
203                          }
204                          
205 kumpf           1.57     // Note: This method should not throw an exception.  It is used as a thread
206                          // entry point, and any exceptions thrown are ignored.
207 kumpf           1.39     PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL
208 se.gupta        1.56     ProviderManagerService::handleCimOperation(void * arg) 
209 chip            1.1      {
210 kumpf           1.39         PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
211                                  "ProviderManagerService::handleCimOperation");
212 chip            1.1      
213 chip            1.8          if(arg == 0)
214                              {
215                                  // thread started with invalid argument.
216                                  return(PEGASUS_THREAD_RETURN(1));
217                              }
218                          
219 chip            1.1          // get the service from argument
220 kumpf           1.39         ProviderManagerService * service =
221                                  reinterpret_cast<ProviderManagerService *>(arg);
222 chip            1.1      
223                              if(service->_incomingQueue.size() == 0)
224                              {
225                                  PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4,
226 kumpf           1.39                 "ProviderManagerService::handleCimOperation() called with no "
227                                          "op node in queue");
228 chip            1.1      
229                                  PEG_METHOD_EXIT();
230                          
231                                  // thread started with no message in queue.
232                                  return(PEGASUS_THREAD_RETURN(1));
233                              }
234                          
235                              AsyncOpNode * op = service->_incomingQueue.dequeue();
236                          
237 chip            1.8          if((op == 0) || (op->_request.count() == 0))
238 chip            1.1          {
239 kumpf           1.39             // ATTN: This may dereference a null pointer!
240 chip            1.1              MessageQueue * queue = MessageQueue::lookup(op->_source_queue);
241                          
242                                  PEGASUS_ASSERT(queue != 0);
243                          
244                                  PEG_METHOD_EXIT();
245                          
246                                  // no request in op node
247                                  return(PEGASUS_THREAD_RETURN(1));
248                              }
249                          
250                              AsyncRequest * request = static_cast<AsyncRequest *>(op->_request.next(0));
251                          
252 kumpf           1.39         if ((request == 0) ||
253                                  (request->getType() != async_messages::ASYNC_LEGACY_OP_START))
254 chip            1.1          {
255                                  // reply with NAK
256                                  PEG_METHOD_EXIT();
257                                  return(PEGASUS_THREAD_RETURN(0));
258                              }
259                          
260 chip            1.8          try
261 chip            1.1          {
262 kumpf           1.39             Message* legacy =
263                                      static_cast<AsyncLegacyOperationStart *>(request)->get_action();
264 chip            1.1      
265 chip            1.8              if(_isSupportedRequestType(legacy))
266 chip            1.1              {
267 a.arora         1.37                 AutoPtr<Message> xmessage(legacy);
268 chip            1.1      
269 chip            1.8                  // Set the client's requested language into this service thread.
270                                      // This will allow functions in this service to return messages
271                                      // in the correct language.
272 kumpf           1.39                 CIMMessage* msg = dynamic_cast<CIMMessage *>(legacy);
273 chip            1.8      
274 kumpf           1.39                 if (msg != 0)
275 chip            1.8                  {
276 se.gupta        1.48     		        AcceptLanguages* langs =
277                                              new AcceptLanguages(((AcceptLanguageListContainer)msg->operationContext.get
278                          											(AcceptLanguageListContainer::NAME)).getLanguages());
279 chip            1.8                      Thread::setLanguages(langs);
280                                      }
281                                      else
282                                      {
283                                          Thread::clearLanguages();
284                                      }
285 chip            1.1      
286                                      service->handleCimRequest(op, legacy);
287 chip            1.3              }
288 chip            1.8          }
289                              catch(...)
290                              {
291                                  // ATTN: log error
292 chip            1.1          }
293                          
294                              PEG_METHOD_EXIT();
295                          
296                              return(PEGASUS_THREAD_RETURN(0));
297                          }
298                          
299 kumpf           1.39     void ProviderManagerService::handleCimRequest(
300                              AsyncOpNode * op,
301                              Message * message)
302 chip            1.1      {
303 kumpf           1.39         PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
304                                  "ProviderManagerService::handleCimRequest");
305 chip            1.1      
306 kumpf           1.38         CIMRequestMessage * request = dynamic_cast<CIMRequestMessage *>(message);
307                              PEGASUS_ASSERT(request != 0);
308 chip            1.1      
309                              // get request from op node
310                              AsyncRequest * async = static_cast<AsyncRequest *>(op->_request.next(0));
311 kumpf           1.38         PEGASUS_ASSERT(async != 0);
312                          
313                              Message * response = 0;
314 kumpf           1.58         Boolean consumerLookupFailed = false;
315 chip            1.1      
316 kumpf           1.58         if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE)
317                              {
318                                  //
319                                  // Get a ProviderIdContainer for ExportIndicationRequestMessage.
320                                  // Note: This can be removed when the CIMExportRequestDispatcher
321                                  // is updated to add the ProviderIdContainer to the message.
322                                  //
323                                  CIMInstance providerModule;
324                                  CIMInstance provider;
325                                  const CIMExportIndicationRequestMessage* expRequest =
326                                      dynamic_cast<const CIMExportIndicationRequestMessage*>(request);
327                                  if (_providerRegistrationManager->lookupIndicationConsumer(
328                                          expRequest->destinationPath, provider, providerModule))
329                                  {
330                                      request->operationContext.insert(
331                                          ProviderIdContainer(providerModule, provider));
332                                  }
333                                  else
334                                  {
335                                      consumerLookupFailed = true;
336                                  }
337 kumpf           1.58         }
338                          
339                              if (consumerLookupFailed)
340                              {
341                                  CIMResponseMessage* cimResponse = request->buildResponse();
342                                  cimResponse->cimException = PEGASUS_CIM_EXCEPTION(
343                                      CIM_ERR_NOT_SUPPORTED, String::EMPTY);
344                                  response = cimResponse;
345                              }
346                              else if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) ||
347 kumpf           1.46             (dynamic_cast<CIMIndicationRequestMessage*>(request) != 0) ||
348 kumpf           1.40             (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) ||
349 kumpf           1.45             (request->getType() == CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE))
350 kumpf           1.38         {
351 kumpf           1.45             // Handle CIMOperationRequestMessage, CIMExportIndicationRequestMessage,
352 kumpf           1.46             // CIMIndicationRequestMessage, and CIMInitializeProviderRequestMessage.
353                                  // (These should be blocked when the provider module is disabled.)
354 kumpf           1.45     
355 kumpf           1.46             //
356                                  // Get the provider module instance to check for a disabled module
357                                  //
358                                  CIMInstance providerModule;
359 kumpf           1.45     
360 kumpf           1.58             // The provider ID container is added to the OperationContext
361                                  // by the CIMOperationRequestDispatcher for all CIM operation
362                                  // requests to providers, so it does not need to be added again.
363                                  // CIMInitializeProviderRequestMessage also has a provider ID
364                                  // container.
365                                  ProviderIdContainer pidc =
366                                      request->operationContext.get(ProviderIdContainer::NAME);
367                                  providerModule = pidc.getModule();
368 kumpf           1.38     
369 kumpf           1.45             //
370                                  // Check if the target provider is disabled
371                                  //
372                                  Boolean moduleDisabled = false;
373                                  Uint32 pos = providerModule.findProperty(CIMName("OperationalStatus"));
374                                  PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
375                                  Array<Uint16> operationalStatus;
376                                  providerModule.getProperty(pos).getValue().get(operationalStatus);
377                          
378                                  for(Uint32 i = 0; i < operationalStatus.size(); i++)
379                                  {
380 kumpf           1.50                 if ((operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED) ||
381                                          (operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING))
382 kumpf           1.45                 {
383                                          moduleDisabled = true;
384                                          break;
385                                      }
386                                  }
387                          
388                                  if (moduleDisabled)
389                                  {
390                                      //
391                                      // Send a "provider blocked" response
392                                      //
393                                      CIMResponseMessage* cimResponse = request->buildResponse();
394                                      cimResponse->cimException = PEGASUS_CIM_EXCEPTION_L(
395                                          CIM_ERR_ACCESS_DENIED,
396                                          MessageLoaderParms(
397                                              "ProviderManager.ProviderManagerService.PROVIDER_BLOCKED",
398                                              "provider blocked."));
399                                      response = cimResponse;
400                                  }
401                                  else
402                                  {
403 kumpf           1.45                 //
404                                      // Forward the request to the appropriate ProviderManagerRouter
405                                      //
406                                      response = _providerManagerRouter->processMessage(request);
407                                  }
408 schuur          1.19         }
409 kumpf           1.38         else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE)
410                              {
411                                  // Handle CIMEnableModuleRequestMessage
412                                  CIMEnableModuleRequestMessage * emReq =
413                                      dynamic_cast<CIMEnableModuleRequestMessage*>(request);
414                          
415                                  CIMInstance providerModule = emReq->providerModule;
416 dj.gorey        1.31     
417 kumpf           1.38             try
418                                  {
419 kumpf           1.39                 // Forward the request to the ProviderManager
420                                      response = _providerManagerRouter->processMessage(request);
421 kumpf           1.38     
422                                      // If successful, update provider module status to OK
423                                      // ATTN: Use CIMEnableModuleResponseMessage operationalStatus?
424                                      CIMEnableModuleResponseMessage * emResp =
425                                          dynamic_cast<CIMEnableModuleResponseMessage*>(response);
426                                      if (emResp->cimException.getCode() == CIM_ERR_SUCCESS)
427                                      {
428                                          _updateProviderModuleStatus(
429 kumpf           1.50                         providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPED, 
430                                              CIM_MSE_OPSTATUS_VALUE_OK);
431 kumpf           1.38                 }
432                                  }
433                                  catch (Exception& e)
434                                  {
435                                      // Get the OperationalStatus property from the provider module
436                                      Array<Uint16> operationalStatus;
437                                      CIMValue itValue = emReq->providerModule.getProperty(
438                                          emReq->providerModule.findProperty("OperationalStatus"))
439                                              .getValue();
440                                      itValue.get(operationalStatus);
441                          
442                                      if (response != 0)
443                                      {
444                                          delete response;
445                                      }
446                          
447                                      response = new CIMEnableModuleResponseMessage(
448                                          request->messageId,
449                                          CIMException(CIM_ERR_FAILED, e.getMessage()),
450                                          request->queueIds.copyAndPop(),
451                                          operationalStatus);
452 kumpf           1.38             }
453                              }
454                              else if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE)
455                              {
456                                  // Handle CIMDisableModuleRequestMessage
457                                  CIMDisableModuleRequestMessage * dmReq =
458                                      dynamic_cast<CIMDisableModuleRequestMessage*>(request);
459                          
460                                  CIMInstance providerModule = dmReq->providerModule;
461                                  Boolean updateModuleStatus = !dmReq->disableProviderOnly;
462                          
463                                  try
464                                  {
465                                      // Change module status from OK to STOPPING
466                                      if (updateModuleStatus)
467                                      {
468                                          _updateProviderModuleStatus(
469 kumpf           1.50                         providerModule, CIM_MSE_OPSTATUS_VALUE_OK, 
470                                              CIM_MSE_OPSTATUS_VALUE_STOPPING);
471 kumpf           1.38                 }
472                          
473 kumpf           1.39                 // Forward the request to the ProviderManager
474                                      response = _providerManagerRouter->processMessage(request);
475 kumpf           1.38     
476                                      // Update provider module status based on success or failure
477                                      if (updateModuleStatus)
478                                      {
479                                          CIMDisableModuleResponseMessage * dmResp =
480                                              dynamic_cast<CIMDisableModuleResponseMessage*>(response);
481                                          if (dmResp->cimException.getCode() != CIM_ERR_SUCCESS)
482                                          {
483                                              // Disable operation failed.  Module not stopped.
484                                              _updateProviderModuleStatus(
485 kumpf           1.50                             providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPING, 
486                                                  CIM_MSE_OPSTATUS_VALUE_OK);
487 kumpf           1.38                     }
488                                          else
489                                          {
490                                              // Disable may or may not have been successful,
491                                              // depending on whether there are outstanding requests.
492                                              // Use last operationalStatus entry.
493                                              _updateProviderModuleStatus(
494 kumpf           1.50                             providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPING,
495 kumpf           1.38                             dmResp->operationalStatus[
496                                                      dmResp->operationalStatus.size()-1]);
497                                          }
498                                      }
499                                  }
500                                  catch (Exception& e)
501                                  {
502                                      // Get the OperationalStatus property from the provider module
503                                      Array<Uint16> operationalStatus;
504                                      CIMValue itValue = dmReq->providerModule.getProperty(
505                                          dmReq->providerModule.findProperty("OperationalStatus"))
506                                              .getValue();
507                                      itValue.get(operationalStatus);
508                          
509                                      if (response != 0)
510                                      {
511                                          delete response;
512                                      }
513                          
514                                      response = new CIMDisableModuleResponseMessage(
515                                          request->messageId,
516 kumpf           1.38                     CIMException(CIM_ERR_FAILED, e.getMessage()),
517                                          request->queueIds.copyAndPop(),
518                                          operationalStatus);
519                                  }
520                              }
521                              else
522                              {
523 kumpf           1.39             response = _providerManagerRouter->processMessage(request);
524 schuur          1.23         }
525 chip            1.13     
526 schuur          1.19         AsyncLegacyOperationResult * async_result =
527                                  new AsyncLegacyOperationResult(
528                                  async->getKey(),
529                                  async->getRouting(),
530                                  op,
531                                  response);
532 chip            1.13     
533 schuur          1.19         _complete_op_node(op, ASYNC_OPSTATE_COMPLETE, 0, 0);
534 chip            1.13     
535 schuur          1.19         PEG_METHOD_EXIT();
536                          }
537 chip            1.13     
538 kumpf           1.44     void ProviderManagerService::unloadIdleProviders()
539                          {
540                              PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
541                                  "ProviderManagerService::unloadIdleProviders");
542 denise.eckstein 1.59.2.1     ThreadStatus rtn = PEGASUS_THREAD_OK;
543 kumpf           1.44         // Ensure that only one _unloadIdleProvidersHandler thread runs at a time
544                              _unloadIdleProvidersBusy++;
545                              if ((_unloadIdleProvidersBusy.value() == 1) &&
546 denise.eckstein 1.59.2.1         ((rtn = _thread_pool->allocate_and_awaken(
547                                       (void*)this, ProviderManagerService::_unloadIdleProvidersHandler))
548                                       ==PEGASUS_THREAD_OK))
549 kumpf           1.44         {
550                                  // _unloadIdleProvidersBusy is decremented in
551                                  // _unloadIdleProvidersHandler
552                              }
553                              else
554                              {
555                                  // If we fail to allocate a thread, don't retry now.
556                                  _unloadIdleProvidersBusy--;
557                              }
558 denise.eckstein 1.59.2.1     if (rtn != PEGASUS_THREAD_OK)
559                              {
560                                  Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
561                                          "Not enough threads to unload idle providers.");
562 kumpf           1.44     
563 denise.eckstein 1.59.2.1         Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
564                                          "Could not allocate thread for %s to unload idle providers.",
565                                          getQueueName());
566                              }
567 kumpf           1.44         PEG_METHOD_EXIT();
568                          }
569                          
570                          PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL
571                          ProviderManagerService::_unloadIdleProvidersHandler(void* arg) throw()
572 chip            1.1      {
573 kumpf           1.44         try
574                              {
575                                  PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
576                                      "ProviderManagerService::unloadIdleProvidersHandler");
577                          
578                                  ProviderManagerService* myself =
579                                      reinterpret_cast<ProviderManagerService*>(arg);
580                          
581                                  try
582                                  {
583                                      myself->_providerManagerRouter->unloadIdleProviders();
584                                  }
585                                  catch (...)
586                                  {
587                                      // Ignore errors
588                                      PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
589                                          "Unexpected exception in _unloadIdleProvidersHandler");
590                                  }
591                          
592                                  myself->_unloadIdleProvidersBusy--;
593                                  PEG_METHOD_EXIT();
594 kumpf           1.44         }
595                              catch (...)
596                              {
597                                  // Ignore errors
598                                  PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
599                                      "Unexpected exception in _unloadIdleProvidersHandler");
600                              }
601                          
602                              return(PEGASUS_THREAD_RETURN(0));
603 kumpf           1.38     }
604                          
605                          // Updates the providerModule instance and the ProviderRegistrationManager
606                          void ProviderManagerService::_updateProviderModuleStatus(
607                              CIMInstance& providerModule,
608                              Uint16 fromStatus,
609                              Uint16 toStatus)
610                          {
611                              PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
612                                  "ProviderManagerService::_updateProviderModuleStatus");
613                          
614                              Array<Uint16> operationalStatus;
615                              String providerModuleName;
616                          
617                              Uint32 pos = providerModule.findProperty(CIMName("Name"));
618                              PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
619                              providerModule.getProperty(pos).getValue().get(providerModuleName);
620                          
621                              //
622                              // get operational status
623                              //
624 kumpf           1.38         pos = providerModule.findProperty(CIMName("OperationalStatus"));
625                              PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
626                              CIMProperty operationalStatusProperty = providerModule.getProperty(pos);
627                              CIMValue operationalStatusValue = operationalStatusProperty.getValue();
628                          
629                              if (!operationalStatusValue.isNull())
630                              {
631                                  operationalStatusValue.get(operationalStatus);
632                              }
633                          
634                              //
635                              // update module status
636                              //
637                              for (Uint32 i = operationalStatus.size(); i > 0; i--)
638                              {
639                                  if (operationalStatus[i-1] == fromStatus)
640                                  {
641                                      operationalStatus.remove(i-1);
642                                  }
643                              }
644                          
645 kumpf           1.38         operationalStatus.append(toStatus);
646                          
647                              if (_providerRegistrationManager->setProviderModuleStatus(
648                                      providerModuleName, operationalStatus) == false)
649                              {
650                                  throw PEGASUS_CIM_EXCEPTION_L(
651                                      CIM_ERR_FAILED,
652                                      MessageLoaderParms(
653                                          "ProviderManager.ProviderManagerService."
654                                              "SET_MODULE_STATUS_FAILED",
655                                          "set module status failed."));
656                              }
657                          
658                              operationalStatusProperty.setValue(CIMValue(operationalStatus));
659                          
660                              PEG_METHOD_EXIT();
661 kumpf           1.39     }
662                          
663                          void ProviderManagerService::indicationCallback(
664                              CIMProcessIndicationRequestMessage* request)
665                          {
666 se.gupta        1.52      	try
667                          	{
668                          		AcceptLanguageListContainer cntr = request->operationContext.get(AcceptLanguageListContainer::NAME);
669 david.dillard   1.55     	}catch(const Exception &)
670 se.gupta        1.52     	{
671                          		request->operationContext.insert(AcceptLanguageListContainer(AcceptLanguages::EMPTY));
672                          	}    
673                          	
674                          	if (_indicationServiceQueueId == PEG_NOT_FOUND)
675 kumpf           1.39         {
676                                  Array<Uint32> serviceIds;
677                          
678                                  providerManagerService->find_services(
679                                      PEGASUS_QUEUENAME_INDICATIONSERVICE, 0, 0, &serviceIds);
680                                  PEGASUS_ASSERT(serviceIds.size() != 0);
681                          
682                                  _indicationServiceQueueId = serviceIds[0];
683                              }
684                          
685                              request->queueIds = QueueIdStack(
686                                  _indicationServiceQueueId, providerManagerService->getQueueId());
687                          
688                              AsyncLegacyOperationStart * asyncRequest =
689                                  new AsyncLegacyOperationStart(
690                                  providerManagerService->get_next_xid(),
691                                  0,
692                                  _indicationServiceQueueId,
693                                  request,
694                                  _indicationServiceQueueId);
695                          
696 kumpf           1.39         providerManagerService->SendForget(asyncRequest);
697 chip            1.1      }
698                          
699 a.arora         1.37     PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2