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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2