(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 brian.campbell 1.60 #include <Pegasus/ProviderManager2/OperationResponseHandler.h>
 58 chip           1.17 
 59 chip           1.1  PEGASUS_NAMESPACE_BEGIN
 60                     
 61 chip           1.11 inline Boolean _isSupportedRequestType(const Message * message)
 62                     {
 63                         // ATTN: needs implementation
 64                     
 65                         // for now, assume all requests are valid
 66                     
 67                         return(true);
 68 chip           1.3  }
 69                     
 70                     inline Boolean _isSupportedResponseType(const Message * message)
 71                     {
 72 chip           1.11     // ATTN: needs implementation
 73                     
 74                         // for now, assume all responses are invalid
 75 chip           1.3  
 76 chip           1.11     return(false);
 77 chip           1.3  }
 78                     
 79 schuur         1.19 ProviderManagerService* ProviderManagerService::providerManagerService=NULL;
 80 kumpf          1.39 Uint32 ProviderManagerService::_indicationServiceQueueId = PEG_NOT_FOUND;
 81 schuur         1.19 
 82 chip           1.1  ProviderManagerService::ProviderManagerService(void)
 83                         : MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP)
 84                     {
 85 schuur         1.19     providerManagerService=this;
 86 chip           1.1  }
 87                     
 88 schuur         1.25 ProviderManagerService::ProviderManagerService(
 89                             ProviderRegistrationManager * providerRegistrationManager,
 90                             CIMRepository * repository)
 91 chip           1.1      : MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP)
 92                     {
 93 schuur         1.19     providerManagerService=this;
 94 schuur         1.25     _repository=repository;
 95 dj.gorey       1.31 
 96 kumpf          1.38     _providerRegistrationManager = providerRegistrationManager;
 97 kumpf          1.44 
 98                         _unloadIdleProvidersBusy = 0;
 99                     
100 kumpf          1.51     // Determine whether Out-of-Process Provider support is enabled
101                         ConfigManager* configManager = ConfigManager::getInstance();
102                         if (String::equal(
103                             configManager->getCurrentValue("enableProviderProcesses"), "true"))
104                         {
105                             _providerManagerRouter =
106                                 new OOPProviderManagerRouter(indicationCallback);
107                         }
108                         else
109                         {
110                             _providerManagerRouter =
111                                 new BasicProviderManagerRouter(indicationCallback);
112                         }
113 chip           1.1  }
114                     
115                     ProviderManagerService::~ProviderManagerService(void)
116                     {
117 kumpf          1.39     delete _providerManagerRouter;
118 schuur         1.19     providerManagerService=NULL;
119 chip           1.1  }
120                     
121                     Boolean ProviderManagerService::messageOK(const Message * message)
122                     {
123                         PEGASUS_ASSERT(message != 0);
124                     
125 chip           1.3      if(_isSupportedRequestType(message))
126 chip           1.1      {
127 chip           1.3          return(MessageQueueService::messageOK(message));
128 chip           1.1      }
129                     
130 chip           1.3      return(false);
131 chip           1.1  }
132                     
133                     void ProviderManagerService::handleEnqueue(void)
134                     {
135                         Message * message = dequeue();
136                     
137                         handleEnqueue(message);
138                     }
139                     
140                     void ProviderManagerService::handleEnqueue(Message * message)
141                     {
142                         PEGASUS_ASSERT(message != 0);
143                     
144                         AsyncLegacyOperationStart * asyncRequest;
145                     
146                         if(message->_async != NULL)
147                         {
148                             asyncRequest = static_cast<AsyncLegacyOperationStart *>(message->_async);
149                         }
150                         else
151                         {
152 chip           1.1          asyncRequest = new AsyncLegacyOperationStart(
153                                 get_next_xid(),
154                                 0,
155                                 this->getQueueId(),
156                                 message,
157                                 this->getQueueId());
158                         }
159                     
160                         _handle_async_request(asyncRequest);
161                     }
162                     
163                     void ProviderManagerService::_handle_async_request(AsyncRequest * request)
164                     {
165                         PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
166                             "ProviderManagerService::_handle_async_request");
167                     
168                         PEGASUS_ASSERT((request != 0) && (request->op != 0));
169                     
170                         if(request->getType() == async_messages::ASYNC_LEGACY_OP_START)
171                         {
172                             request->op->processing();
173 chip           1.1  
174                             _incomingQueue.enqueue(request->op);
175                     
176 schuur         1.32          while (!_thread_pool->allocate_and_awaken(
177                                          (void *)this, ProviderManagerService::handleCimOperation))
178                              {
179                                  pegasus_yield();
180                              }
181 chip           1.1      }
182                         else
183                         {
184                             // pass all other operations to the default handler
185                             MessageQueueService::_handle_async_request(request);
186                         }
187                     
188                         PEG_METHOD_EXIT();
189                     
190                         return;
191                     }
192                     
193 kumpf          1.57 // Note: This method should not throw an exception.  It is used as a thread
194                     // entry point, and any exceptions thrown are ignored.
195 kumpf          1.39 PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL
196 se.gupta       1.56 ProviderManagerService::handleCimOperation(void * arg) 
197 chip           1.1  {
198 kumpf          1.39     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
199                             "ProviderManagerService::handleCimOperation");
200 chip           1.1  
201 chip           1.8      if(arg == 0)
202                         {
203                             // thread started with invalid argument.
204                             return(PEGASUS_THREAD_RETURN(1));
205                         }
206                     
207 chip           1.1      // get the service from argument
208 kumpf          1.39     ProviderManagerService * service =
209                             reinterpret_cast<ProviderManagerService *>(arg);
210 chip           1.1  
211                         if(service->_incomingQueue.size() == 0)
212                         {
213                             PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4,
214 kumpf          1.39             "ProviderManagerService::handleCimOperation() called with no "
215                                     "op node in queue");
216 chip           1.1  
217                             PEG_METHOD_EXIT();
218                     
219                             // thread started with no message in queue.
220                             return(PEGASUS_THREAD_RETURN(1));
221                         }
222                     
223                         AsyncOpNode * op = service->_incomingQueue.dequeue();
224                     
225 chip           1.8      if((op == 0) || (op->_request.count() == 0))
226 chip           1.1      {
227 kumpf          1.39         // ATTN: This may dereference a null pointer!
228 chip           1.1          MessageQueue * queue = MessageQueue::lookup(op->_source_queue);
229                     
230                             PEGASUS_ASSERT(queue != 0);
231                     
232                             PEG_METHOD_EXIT();
233                     
234                             // no request in op node
235                             return(PEGASUS_THREAD_RETURN(1));
236                         }
237                     
238                         AsyncRequest * request = static_cast<AsyncRequest *>(op->_request.next(0));
239                     
240 kumpf          1.39     if ((request == 0) ||
241                             (request->getType() != async_messages::ASYNC_LEGACY_OP_START))
242 chip           1.1      {
243                             // reply with NAK
244                             PEG_METHOD_EXIT();
245                             return(PEGASUS_THREAD_RETURN(0));
246                         }
247                     
248 chip           1.8      try
249 chip           1.1      {
250 kumpf          1.39         Message* legacy =
251                                 static_cast<AsyncLegacyOperationStart *>(request)->get_action();
252 chip           1.1  
253 chip           1.8          if(_isSupportedRequestType(legacy))
254 chip           1.1          {
255 a.arora        1.37             AutoPtr<Message> xmessage(legacy);
256 chip           1.1  
257 chip           1.8              // Set the client's requested language into this service thread.
258                                 // This will allow functions in this service to return messages
259                                 // in the correct language.
260 kumpf          1.39             CIMMessage* msg = dynamic_cast<CIMMessage *>(legacy);
261 chip           1.8  
262 kumpf          1.39             if (msg != 0)
263 chip           1.8              {
264 se.gupta       1.48 		        AcceptLanguages* langs =
265                                         new AcceptLanguages(((AcceptLanguageListContainer)msg->operationContext.get
266                     											(AcceptLanguageListContainer::NAME)).getLanguages());
267 chip           1.8                  Thread::setLanguages(langs);
268                                 }
269                                 else
270                                 {
271                                     Thread::clearLanguages();
272                                 }
273 chip           1.1  
274                                 service->handleCimRequest(op, legacy);
275 chip           1.3          }
276 chip           1.8      }
277                         catch(...)
278                         {
279                             // ATTN: log error
280 chip           1.1      }
281                     
282                         PEG_METHOD_EXIT();
283                     
284                         return(PEGASUS_THREAD_RETURN(0));
285                     }
286                     
287 kumpf          1.39 void ProviderManagerService::handleCimRequest(
288                         AsyncOpNode * op,
289                         Message * message)
290 chip           1.1  {
291 kumpf          1.39     PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
292                             "ProviderManagerService::handleCimRequest");
293 chip           1.1  
294 kumpf          1.38     CIMRequestMessage * request = dynamic_cast<CIMRequestMessage *>(message);
295                         PEGASUS_ASSERT(request != 0);
296 chip           1.1  
297                         // get request from op node
298                         AsyncRequest * async = static_cast<AsyncRequest *>(op->_request.next(0));
299 kumpf          1.38     PEGASUS_ASSERT(async != 0);
300                     
301                         Message * response = 0;
302 kumpf          1.58     Boolean consumerLookupFailed = false;
303 chip           1.1  
304 kumpf          1.58     if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE)
305                         {
306                             //
307                             // Get a ProviderIdContainer for ExportIndicationRequestMessage.
308                             // Note: This can be removed when the CIMExportRequestDispatcher
309                             // is updated to add the ProviderIdContainer to the message.
310                             //
311                             CIMInstance providerModule;
312                             CIMInstance provider;
313                             const CIMExportIndicationRequestMessage* expRequest =
314                                 dynamic_cast<const CIMExportIndicationRequestMessage*>(request);
315                             if (_providerRegistrationManager->lookupIndicationConsumer(
316                                     expRequest->destinationPath, provider, providerModule))
317                             {
318                                 request->operationContext.insert(
319                                     ProviderIdContainer(providerModule, provider));
320                             }
321                             else
322                             {
323                                 consumerLookupFailed = true;
324                             }
325 kumpf          1.58     }
326                     
327                         if (consumerLookupFailed)
328                         {
329                             CIMResponseMessage* cimResponse = request->buildResponse();
330                             cimResponse->cimException = PEGASUS_CIM_EXCEPTION(
331                                 CIM_ERR_NOT_SUPPORTED, String::EMPTY);
332                             response = cimResponse;
333                         }
334                         else if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) ||
335 kumpf          1.46         (dynamic_cast<CIMIndicationRequestMessage*>(request) != 0) ||
336 kumpf          1.40         (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) ||
337 kumpf          1.45         (request->getType() == CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE))
338 kumpf          1.38     {
339 kumpf          1.45         // Handle CIMOperationRequestMessage, CIMExportIndicationRequestMessage,
340 kumpf          1.46         // CIMIndicationRequestMessage, and CIMInitializeProviderRequestMessage.
341                             // (These should be blocked when the provider module is disabled.)
342 kumpf          1.45 
343 kumpf          1.46         //
344                             // Get the provider module instance to check for a disabled module
345                             //
346                             CIMInstance providerModule;
347 kumpf          1.45 
348 kumpf          1.58         // The provider ID container is added to the OperationContext
349                             // by the CIMOperationRequestDispatcher for all CIM operation
350                             // requests to providers, so it does not need to be added again.
351                             // CIMInitializeProviderRequestMessage also has a provider ID
352                             // container.
353                             ProviderIdContainer pidc =
354                                 request->operationContext.get(ProviderIdContainer::NAME);
355                             providerModule = pidc.getModule();
356 kumpf          1.38 
357 kumpf          1.45         //
358                             // Check if the target provider is disabled
359                             //
360                             Boolean moduleDisabled = false;
361                             Uint32 pos = providerModule.findProperty(CIMName("OperationalStatus"));
362                             PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
363                             Array<Uint16> operationalStatus;
364                             providerModule.getProperty(pos).getValue().get(operationalStatus);
365                     
366                             for(Uint32 i = 0; i < operationalStatus.size(); i++)
367                             {
368 kumpf          1.50             if ((operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED) ||
369                                     (operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING))
370 kumpf          1.45             {
371                                     moduleDisabled = true;
372                                     break;
373                                 }
374                             }
375                     
376                             if (moduleDisabled)
377                             {
378                                 //
379                                 // Send a "provider blocked" response
380                                 //
381                                 CIMResponseMessage* cimResponse = request->buildResponse();
382                                 cimResponse->cimException = PEGASUS_CIM_EXCEPTION_L(
383                                     CIM_ERR_ACCESS_DENIED,
384                                     MessageLoaderParms(
385                                         "ProviderManager.ProviderManagerService.PROVIDER_BLOCKED",
386                                         "provider blocked."));
387                                 response = cimResponse;
388                             }
389                             else
390                             {
391 kumpf          1.45             //
392                                 // Forward the request to the appropriate ProviderManagerRouter
393                                 //
394                                 response = _providerManagerRouter->processMessage(request);
395                             }
396 schuur         1.19     }
397 kumpf          1.38     else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE)
398                         {
399                             // Handle CIMEnableModuleRequestMessage
400                             CIMEnableModuleRequestMessage * emReq =
401                                 dynamic_cast<CIMEnableModuleRequestMessage*>(request);
402                     
403                             CIMInstance providerModule = emReq->providerModule;
404 dj.gorey       1.31 
405 kumpf          1.38         try
406                             {
407 kumpf          1.39             // Forward the request to the ProviderManager
408                                 response = _providerManagerRouter->processMessage(request);
409 kumpf          1.38 
410                                 // If successful, update provider module status to OK
411                                 // ATTN: Use CIMEnableModuleResponseMessage operationalStatus?
412                                 CIMEnableModuleResponseMessage * emResp =
413                                     dynamic_cast<CIMEnableModuleResponseMessage*>(response);
414                                 if (emResp->cimException.getCode() == CIM_ERR_SUCCESS)
415                                 {
416                                     _updateProviderModuleStatus(
417 kumpf          1.50                     providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPED, 
418                                         CIM_MSE_OPSTATUS_VALUE_OK);
419 kumpf          1.38             }
420                             }
421                             catch (Exception& e)
422                             {
423                                 // Get the OperationalStatus property from the provider module
424                                 Array<Uint16> operationalStatus;
425                                 CIMValue itValue = emReq->providerModule.getProperty(
426                                     emReq->providerModule.findProperty("OperationalStatus"))
427                                         .getValue();
428                                 itValue.get(operationalStatus);
429                     
430                                 if (response != 0)
431                                 {
432                                     delete response;
433                                 }
434                     
435                                 response = new CIMEnableModuleResponseMessage(
436                                     request->messageId,
437                                     CIMException(CIM_ERR_FAILED, e.getMessage()),
438                                     request->queueIds.copyAndPop(),
439                                     operationalStatus);
440 kumpf          1.38         }
441                         }
442                         else if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE)
443                         {
444                             // Handle CIMDisableModuleRequestMessage
445                             CIMDisableModuleRequestMessage * dmReq =
446                                 dynamic_cast<CIMDisableModuleRequestMessage*>(request);
447                     
448                             CIMInstance providerModule = dmReq->providerModule;
449                             Boolean updateModuleStatus = !dmReq->disableProviderOnly;
450                     
451                             try
452                             {
453                                 // Change module status from OK to STOPPING
454                                 if (updateModuleStatus)
455                                 {
456                                     _updateProviderModuleStatus(
457 kumpf          1.50                     providerModule, CIM_MSE_OPSTATUS_VALUE_OK, 
458                                         CIM_MSE_OPSTATUS_VALUE_STOPPING);
459 kumpf          1.38             }
460                     
461 kumpf          1.39             // Forward the request to the ProviderManager
462                                 response = _providerManagerRouter->processMessage(request);
463 kumpf          1.38 
464                                 // Update provider module status based on success or failure
465                                 if (updateModuleStatus)
466                                 {
467                                     CIMDisableModuleResponseMessage * dmResp =
468                                         dynamic_cast<CIMDisableModuleResponseMessage*>(response);
469                                     if (dmResp->cimException.getCode() != CIM_ERR_SUCCESS)
470                                     {
471                                         // Disable operation failed.  Module not stopped.
472                                         _updateProviderModuleStatus(
473 kumpf          1.50                         providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPING, 
474                                             CIM_MSE_OPSTATUS_VALUE_OK);
475 kumpf          1.38                 }
476                                     else
477                                     {
478                                         // Disable may or may not have been successful,
479                                         // depending on whether there are outstanding requests.
480                                         // Use last operationalStatus entry.
481                                         _updateProviderModuleStatus(
482 kumpf          1.50                         providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPING,
483 kumpf          1.38                         dmResp->operationalStatus[
484                                                 dmResp->operationalStatus.size()-1]);
485                                     }
486                                 }
487                             }
488                             catch (Exception& e)
489                             {
490                                 // Get the OperationalStatus property from the provider module
491                                 Array<Uint16> operationalStatus;
492                                 CIMValue itValue = dmReq->providerModule.getProperty(
493                                     dmReq->providerModule.findProperty("OperationalStatus"))
494                                         .getValue();
495                                 itValue.get(operationalStatus);
496                     
497                                 if (response != 0)
498                                 {
499                                     delete response;
500                                 }
501                     
502                                 response = new CIMDisableModuleResponseMessage(
503                                     request->messageId,
504 kumpf          1.38                 CIMException(CIM_ERR_FAILED, e.getMessage()),
505                                     request->queueIds.copyAndPop(),
506                                     operationalStatus);
507                             }
508                         }
509                         else
510                         {
511 kumpf          1.39         response = _providerManagerRouter->processMessage(request);
512 schuur         1.23     }
513 chip           1.13 
514 schuur         1.19     AsyncLegacyOperationResult * async_result =
515                             new AsyncLegacyOperationResult(
516                             async->getKey(),
517                             async->getRouting(),
518                             op,
519                             response);
520 chip           1.13 
521 schuur         1.19     _complete_op_node(op, ASYNC_OPSTATE_COMPLETE, 0, 0);
522 chip           1.13 
523 schuur         1.19     PEG_METHOD_EXIT();
524                     }
525 chip           1.13 
526 brian.campbell 1.60 void 
527                     ProviderManagerService::handleCimResponse(CIMRequestMessage &request,
528                     																					CIMResponseMessage &response)
529                     {
530                     	CIMStatusCode code = CIM_ERR_SUCCESS;
531                     	String message;
532                     
533                     	try
534                     	{
535                     		// only incomplete messages are processed because the caller ends up
536                     		// sending the complete() stage
537                     		PEGASUS_ASSERT(response.isComplete() == false);
538                     		
539                     		AsyncLegacyOperationStart *requestAsync = 
540                     			dynamic_cast<AsyncLegacyOperationStart *>(request._async);
541                     		PEGASUS_ASSERT(requestAsync);
542                     		AsyncOpNode *op = requestAsync->op;
543                     		PEGASUS_ASSERT(op);
544                     		PEGASUS_ASSERT(! response._async);
545                     		response._async = new AsyncLegacyOperationResult
546                     			(requestAsync->getKey(), requestAsync->getRouting(), op, &response);
547 brian.campbell 1.60 		
548                     		// set the destination
549                     		op->_op_dest = op->_callback_response_q;
550                     		
551                     		MessageQueueService *service = 	
552                     			dynamic_cast<MessageQueueService *>(op->_callback_response_q);
553                     
554                     		PEGASUS_ASSERT(service);
555                     
556                     		// the last chunk MUST be sent last, so use execute the callback
557                     		// not all chunks are going through the dispatcher's chunk 
558                     		// resequencer, so this must be a synchronous call here
559                     		// After the call is done, response and asyncResponse are now invalid 
560                     		// as they have been sent and deleted externally
561                     		
562                     		op->_async_callback(op, service, op->_callback_ptr);
563                     	}
564                     
565                     	catch(CIMException &e)
566                     	{
567                     		code = e.getCode();
568 brian.campbell 1.60 		message = e.getMessage();
569                     	}
570                     	catch(Exception &e)
571                     	{
572                     		code = CIM_ERR_FAILED;
573                     		message = e.getMessage();
574                     	}
575                     	catch(...)
576                     	{
577                     		code = CIM_ERR_FAILED;
578                     		message = cimStatusCodeToString(code);
579                     	}
580                     
581                     	if (code !=  CIM_ERR_SUCCESS)
582                     		response.cimException = PEGASUS_CIM_EXCEPTION(code, message);
583                     }
584                     
585 kumpf          1.44 void ProviderManagerService::unloadIdleProviders()
586                     {
587                         PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
588                             "ProviderManagerService::unloadIdleProviders");
589                     
590                         // Ensure that only one _unloadIdleProvidersHandler thread runs at a time
591                         _unloadIdleProvidersBusy++;
592                         if ((_unloadIdleProvidersBusy.value() == 1) &&
593                             (_thread_pool->allocate_and_awaken(
594                                  (void*)this, ProviderManagerService::_unloadIdleProvidersHandler)))
595                         {
596                             // _unloadIdleProvidersBusy is decremented in
597                             // _unloadIdleProvidersHandler
598                         }
599                         else
600                         {
601                             // If we fail to allocate a thread, don't retry now.
602                             _unloadIdleProvidersBusy--;
603                         }
604                     
605                         PEG_METHOD_EXIT();
606 kumpf          1.44 }
607                     
608                     PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL
609                     ProviderManagerService::_unloadIdleProvidersHandler(void* arg) throw()
610 chip           1.1  {
611 kumpf          1.44     try
612                         {
613                             PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
614                                 "ProviderManagerService::unloadIdleProvidersHandler");
615                     
616                             ProviderManagerService* myself =
617                                 reinterpret_cast<ProviderManagerService*>(arg);
618                     
619                             try
620                             {
621                                 myself->_providerManagerRouter->unloadIdleProviders();
622                             }
623                             catch (...)
624                             {
625                                 // Ignore errors
626                                 PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
627                                     "Unexpected exception in _unloadIdleProvidersHandler");
628                             }
629                     
630                             myself->_unloadIdleProvidersBusy--;
631                             PEG_METHOD_EXIT();
632 kumpf          1.44     }
633                         catch (...)
634                         {
635                             // Ignore errors
636                             PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
637                                 "Unexpected exception in _unloadIdleProvidersHandler");
638                         }
639                     
640                         return(PEGASUS_THREAD_RETURN(0));
641 kumpf          1.38 }
642                     
643                     // Updates the providerModule instance and the ProviderRegistrationManager
644                     void ProviderManagerService::_updateProviderModuleStatus(
645                         CIMInstance& providerModule,
646                         Uint16 fromStatus,
647                         Uint16 toStatus)
648                     {
649                         PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
650                             "ProviderManagerService::_updateProviderModuleStatus");
651                     
652                         Array<Uint16> operationalStatus;
653                         String providerModuleName;
654                     
655                         Uint32 pos = providerModule.findProperty(CIMName("Name"));
656                         PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
657                         providerModule.getProperty(pos).getValue().get(providerModuleName);
658                     
659                         //
660                         // get operational status
661                         //
662 kumpf          1.38     pos = providerModule.findProperty(CIMName("OperationalStatus"));
663                         PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
664                         CIMProperty operationalStatusProperty = providerModule.getProperty(pos);
665                         CIMValue operationalStatusValue = operationalStatusProperty.getValue();
666                     
667                         if (!operationalStatusValue.isNull())
668                         {
669                             operationalStatusValue.get(operationalStatus);
670                         }
671                     
672                         //
673                         // update module status
674                         //
675                         for (Uint32 i = operationalStatus.size(); i > 0; i--)
676                         {
677                             if (operationalStatus[i-1] == fromStatus)
678                             {
679                                 operationalStatus.remove(i-1);
680                             }
681                         }
682                     
683 kumpf          1.38     operationalStatus.append(toStatus);
684                     
685                         if (_providerRegistrationManager->setProviderModuleStatus(
686                                 providerModuleName, operationalStatus) == false)
687                         {
688                             throw PEGASUS_CIM_EXCEPTION_L(
689                                 CIM_ERR_FAILED,
690                                 MessageLoaderParms(
691                                     "ProviderManager.ProviderManagerService."
692                                         "SET_MODULE_STATUS_FAILED",
693                                     "set module status failed."));
694                         }
695                     
696                         operationalStatusProperty.setValue(CIMValue(operationalStatus));
697                     
698                         PEG_METHOD_EXIT();
699 kumpf          1.39 }
700                     
701                     void ProviderManagerService::indicationCallback(
702                         CIMProcessIndicationRequestMessage* request)
703                     {
704 se.gupta       1.52  	try
705                     	{
706                     		AcceptLanguageListContainer cntr = request->operationContext.get(AcceptLanguageListContainer::NAME);
707 david.dillard  1.55 	}catch(const Exception &)
708 se.gupta       1.52 	{
709                     		request->operationContext.insert(AcceptLanguageListContainer(AcceptLanguages::EMPTY));
710                     	}    
711                     	
712                     	if (_indicationServiceQueueId == PEG_NOT_FOUND)
713 kumpf          1.39     {
714                             Array<Uint32> serviceIds;
715                     
716                             providerManagerService->find_services(
717                                 PEGASUS_QUEUENAME_INDICATIONSERVICE, 0, 0, &serviceIds);
718                             PEGASUS_ASSERT(serviceIds.size() != 0);
719                     
720                             _indicationServiceQueueId = serviceIds[0];
721                         }
722                     
723                         request->queueIds = QueueIdStack(
724                             _indicationServiceQueueId, providerManagerService->getQueueId());
725                     
726                         AsyncLegacyOperationStart * asyncRequest =
727                             new AsyncLegacyOperationStart(
728                             providerManagerService->get_next_xid(),
729                             0,
730                             _indicationServiceQueueId,
731                             request,
732                             _indicationServiceQueueId);
733                     
734 kumpf          1.39     providerManagerService->SendForget(asyncRequest);
735 chip           1.1  }
736                     
737 a.arora        1.37 PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2