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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2