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 konrad.r 1.66 catch (const Exception& e)
299 {
300 PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
301 "Unexpected exception in handleCimOperation: " + e.getMessage());
302 }
303 catch (...)
304 {
305 PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
306 "Unexpected exception in handleCimOperation.");
307 }
|
308 chip 1.1
309 PEG_METHOD_EXIT();
310
311 return(PEGASUS_THREAD_RETURN(0));
312 }
313
|
314 kumpf 1.39 void ProviderManagerService::handleCimRequest(
315 AsyncOpNode * op,
316 Message * message)
|
317 chip 1.1 {
|
318 kumpf 1.39 PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
319 "ProviderManagerService::handleCimRequest");
|
320 chip 1.1
|
321 kumpf 1.38 CIMRequestMessage * request = dynamic_cast<CIMRequestMessage *>(message);
322 PEGASUS_ASSERT(request != 0);
|
323 chip 1.1
324 // get request from op node
325 AsyncRequest * async = static_cast<AsyncRequest *>(op->_request.next(0));
|
326 kumpf 1.38 PEGASUS_ASSERT(async != 0);
327
328 Message * response = 0;
|
329 kumpf 1.58 Boolean consumerLookupFailed = false;
|
330 chip 1.1
|
331 kumpf 1.58 if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE)
332 {
333 //
334 // Get a ProviderIdContainer for ExportIndicationRequestMessage.
335 // Note: This can be removed when the CIMExportRequestDispatcher
336 // is updated to add the ProviderIdContainer to the message.
337 //
338 CIMInstance providerModule;
339 CIMInstance provider;
340 const CIMExportIndicationRequestMessage* expRequest =
341 dynamic_cast<const CIMExportIndicationRequestMessage*>(request);
342 if (_providerRegistrationManager->lookupIndicationConsumer(
343 expRequest->destinationPath, provider, providerModule))
344 {
345 request->operationContext.insert(
346 ProviderIdContainer(providerModule, provider));
347 }
348 else
349 {
350 consumerLookupFailed = true;
351 }
352 kumpf 1.58 }
353
354 if (consumerLookupFailed)
355 {
356 CIMResponseMessage* cimResponse = request->buildResponse();
357 cimResponse->cimException = PEGASUS_CIM_EXCEPTION(
358 CIM_ERR_NOT_SUPPORTED, String::EMPTY);
359 response = cimResponse;
360 }
361 else if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) ||
|
362 kumpf 1.46 (dynamic_cast<CIMIndicationRequestMessage*>(request) != 0) ||
|
363 kumpf 1.40 (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) ||
|
364 kumpf 1.45 (request->getType() == CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE))
|
365 kumpf 1.38 {
|
366 kumpf 1.45 // Handle CIMOperationRequestMessage, CIMExportIndicationRequestMessage,
|
367 kumpf 1.46 // CIMIndicationRequestMessage, and CIMInitializeProviderRequestMessage.
368 // (These should be blocked when the provider module is disabled.)
|
369 kumpf 1.45
|
370 kumpf 1.46 //
371 // Get the provider module instance to check for a disabled module
372 //
373 CIMInstance providerModule;
|
374 kumpf 1.45
|
375 kumpf 1.58 // The provider ID container is added to the OperationContext
376 // by the CIMOperationRequestDispatcher for all CIM operation
377 // requests to providers, so it does not need to be added again.
378 // CIMInitializeProviderRequestMessage also has a provider ID
379 // container.
380 ProviderIdContainer pidc =
381 request->operationContext.get(ProviderIdContainer::NAME);
382 providerModule = pidc.getModule();
|
383 kumpf 1.38
|
384 kumpf 1.45 //
385 // Check if the target provider is disabled
386 //
387 Boolean moduleDisabled = false;
388 Uint32 pos = providerModule.findProperty(CIMName("OperationalStatus"));
389 PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
390 Array<Uint16> operationalStatus;
391 providerModule.getProperty(pos).getValue().get(operationalStatus);
392
393 for(Uint32 i = 0; i < operationalStatus.size(); i++)
394 {
|
395 kumpf 1.50 if ((operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED) ||
396 (operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING))
|
397 kumpf 1.45 {
398 moduleDisabled = true;
399 break;
400 }
401 }
402
403 if (moduleDisabled)
404 {
405 //
406 // Send a "provider blocked" response
407 //
408 CIMResponseMessage* cimResponse = request->buildResponse();
409 cimResponse->cimException = PEGASUS_CIM_EXCEPTION_L(
410 CIM_ERR_ACCESS_DENIED,
411 MessageLoaderParms(
412 "ProviderManager.ProviderManagerService.PROVIDER_BLOCKED",
413 "provider blocked."));
414 response = cimResponse;
415 }
416 else
417 {
418 kumpf 1.45 //
419 // Forward the request to the appropriate ProviderManagerRouter
420 //
|
421 kumpf 1.62 response = _processMessage(request);
|
422 kumpf 1.45 }
|
423 schuur 1.19 }
|
424 kumpf 1.38 else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE)
425 {
426 // Handle CIMEnableModuleRequestMessage
427 CIMEnableModuleRequestMessage * emReq =
428 dynamic_cast<CIMEnableModuleRequestMessage*>(request);
429
430 CIMInstance providerModule = emReq->providerModule;
|
431 dj.gorey 1.31
|
432 kumpf 1.38 try
433 {
|
434 kumpf 1.39 // Forward the request to the ProviderManager
|
435 kumpf 1.62 response = _processMessage(request);
|
436 kumpf 1.38
437 // If successful, update provider module status to OK
438 // ATTN: Use CIMEnableModuleResponseMessage operationalStatus?
439 CIMEnableModuleResponseMessage * emResp =
440 dynamic_cast<CIMEnableModuleResponseMessage*>(response);
441 if (emResp->cimException.getCode() == CIM_ERR_SUCCESS)
442 {
443 _updateProviderModuleStatus(
|
444 kumpf 1.50 providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPED,
445 CIM_MSE_OPSTATUS_VALUE_OK);
|
446 kumpf 1.38 }
447 }
448 catch (Exception& e)
449 {
450 // Get the OperationalStatus property from the provider module
451 Array<Uint16> operationalStatus;
452 CIMValue itValue = emReq->providerModule.getProperty(
453 emReq->providerModule.findProperty("OperationalStatus"))
454 .getValue();
455 itValue.get(operationalStatus);
456
457 if (response != 0)
458 {
459 delete response;
460 }
461
462 response = new CIMEnableModuleResponseMessage(
463 request->messageId,
464 CIMException(CIM_ERR_FAILED, e.getMessage()),
465 request->queueIds.copyAndPop(),
466 operationalStatus);
467 kumpf 1.38 }
468 }
469 else if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE)
470 {
471 // Handle CIMDisableModuleRequestMessage
472 CIMDisableModuleRequestMessage * dmReq =
473 dynamic_cast<CIMDisableModuleRequestMessage*>(request);
474
475 CIMInstance providerModule = dmReq->providerModule;
476 Boolean updateModuleStatus = !dmReq->disableProviderOnly;
477
478 try
479 {
480 // Change module status from OK to STOPPING
481 if (updateModuleStatus)
482 {
483 _updateProviderModuleStatus(
|
484 kumpf 1.50 providerModule, CIM_MSE_OPSTATUS_VALUE_OK,
485 CIM_MSE_OPSTATUS_VALUE_STOPPING);
|
486 kumpf 1.38 }
487
|
488 kumpf 1.39 // Forward the request to the ProviderManager
|
489 kumpf 1.62 response = _processMessage(request);
|
490 kumpf 1.38
491 // Update provider module status based on success or failure
492 if (updateModuleStatus)
493 {
494 CIMDisableModuleResponseMessage * dmResp =
495 dynamic_cast<CIMDisableModuleResponseMessage*>(response);
496 if (dmResp->cimException.getCode() != CIM_ERR_SUCCESS)
497 {
498 // Disable operation failed. Module not stopped.
499 _updateProviderModuleStatus(
|
500 kumpf 1.50 providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPING,
501 CIM_MSE_OPSTATUS_VALUE_OK);
|
502 kumpf 1.38 }
503 else
504 {
505 // Disable may or may not have been successful,
506 // depending on whether there are outstanding requests.
507 // Use last operationalStatus entry.
508 _updateProviderModuleStatus(
|
509 kumpf 1.50 providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPING,
|
510 kumpf 1.38 dmResp->operationalStatus[
511 dmResp->operationalStatus.size()-1]);
512 }
513 }
514 }
515 catch (Exception& e)
516 {
517 // Get the OperationalStatus property from the provider module
518 Array<Uint16> operationalStatus;
519 CIMValue itValue = dmReq->providerModule.getProperty(
520 dmReq->providerModule.findProperty("OperationalStatus"))
521 .getValue();
522 itValue.get(operationalStatus);
523
524 if (response != 0)
525 {
526 delete response;
527 }
528
529 response = new CIMDisableModuleResponseMessage(
530 request->messageId,
531 kumpf 1.38 CIMException(CIM_ERR_FAILED, e.getMessage()),
532 request->queueIds.copyAndPop(),
533 operationalStatus);
534 }
535 }
536 else
537 {
|
538 kumpf 1.62 response = _processMessage(request);
|
539 schuur 1.23 }
|
540 chip 1.13
|
541 schuur 1.19 AsyncLegacyOperationResult * async_result =
542 new AsyncLegacyOperationResult(
543 async->getKey(),
544 async->getRouting(),
545 op,
546 response);
|
547 chip 1.13
|
548 schuur 1.19 _complete_op_node(op, ASYNC_OPSTATE_COMPLETE, 0, 0);
|
549 chip 1.13
|
550 schuur 1.19 PEG_METHOD_EXIT();
551 }
|
552 chip 1.13
|
553 brian.campbell 1.60 void
554 ProviderManagerService::handleCimResponse(CIMRequestMessage &request,
555 CIMResponseMessage &response)
556 {
557 CIMStatusCode code = CIM_ERR_SUCCESS;
558 String message;
559
560 try
561 {
562 // only incomplete messages are processed because the caller ends up
563 // sending the complete() stage
564 PEGASUS_ASSERT(response.isComplete() == false);
565
566 AsyncLegacyOperationStart *requestAsync =
567 dynamic_cast<AsyncLegacyOperationStart *>(request._async);
568 PEGASUS_ASSERT(requestAsync);
569 AsyncOpNode *op = requestAsync->op;
570 PEGASUS_ASSERT(op);
571 PEGASUS_ASSERT(! response._async);
572 response._async = new AsyncLegacyOperationResult
573 (requestAsync->getKey(), requestAsync->getRouting(), op, &response);
574 brian.campbell 1.60
575 // set the destination
576 op->_op_dest = op->_callback_response_q;
577
578 MessageQueueService *service =
579 dynamic_cast<MessageQueueService *>(op->_callback_response_q);
580
581 PEGASUS_ASSERT(service);
582
583 // the last chunk MUST be sent last, so use execute the callback
584 // not all chunks are going through the dispatcher's chunk
585 // resequencer, so this must be a synchronous call here
586 // After the call is done, response and asyncResponse are now invalid
587 // as they have been sent and deleted externally
588
589 op->_async_callback(op, service, op->_callback_ptr);
590 }
591
592 catch(CIMException &e)
593 {
594 code = e.getCode();
595 brian.campbell 1.60 message = e.getMessage();
596 }
597 catch(Exception &e)
598 {
599 code = CIM_ERR_FAILED;
600 message = e.getMessage();
601 }
602 catch(...)
603 {
604 code = CIM_ERR_FAILED;
605 message = cimStatusCodeToString(code);
606 }
607
608 if (code != CIM_ERR_SUCCESS)
609 response.cimException = PEGASUS_CIM_EXCEPTION(code, message);
610 }
611
|
612 kumpf 1.62 Message* ProviderManagerService::_processMessage(CIMRequestMessage* request)
613 {
614 Message* response = 0;
615
616 if ((request->getType() == CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE) ||
|
617 carolann.graves 1.64 (request->getType() ==
618 CIM_SUBSCRIPTION_INIT_COMPLETE_REQUEST_MESSAGE) ||
|
619 kumpf 1.62 (request->getType() == CIM_NOTIFY_CONFIG_CHANGE_REQUEST_MESSAGE))
620 {
621 if (_basicProviderManagerRouter)
622 {
623 response = _basicProviderManagerRouter->processMessage(request);
624 }
625
626 if (_oopProviderManagerRouter)
627 {
628 // Note: These responses do not contain interesting data, so just
629 // use the last one.
630 if (response)
631 {
632 delete response;
633 }
634
635 response = _oopProviderManagerRouter->processMessage(request);
636 }
637 }
638 else
639 {
640 kumpf 1.62 CIMInstance providerModule;
641
642 if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE)
643 {
644 CIMEnableModuleRequestMessage* emReq =
645 dynamic_cast<CIMEnableModuleRequestMessage*>(request);
646 providerModule = emReq->providerModule;
647 }
648 else if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE)
649 {
650 CIMDisableModuleRequestMessage* dmReq =
651 dynamic_cast<CIMDisableModuleRequestMessage*>(request);
652 providerModule = dmReq->providerModule;
653 }
654 else
655 {
656 ProviderIdContainer pidc =
657 request->operationContext.get(ProviderIdContainer::NAME);
658 providerModule = pidc.getModule();
659 }
660
661 kumpf 1.62 Uint16 userContext = 0;
662 Uint32 pos = providerModule.findProperty(
663 PEGASUS_PROPERTYNAME_MODULE_USERCONTEXT);
664 if (pos != PEG_NOT_FOUND)
665 {
666 providerModule.getProperty(pos).getValue().get(userContext);
667 }
668
669 // Forward the request to the appropriate ProviderManagerRouter, based
670 // on the CIM Server configuration and the UserContext setting.
671
672 ConfigManager* configManager = ConfigManager::getInstance();
673 Boolean forceProviderProcesses = String::equal(
674 configManager->getCurrentValue("forceProviderProcesses"), "true");
675
676 if (forceProviderProcesses
677 #ifndef PEGASUS_DISABLE_PROV_USERCTXT
678 || (userContext == PG_PROVMODULE_USERCTXT_REQUESTOR)
679 || (userContext == PG_PROVMODULE_USERCTXT_DESIGNATED)
680 || ((userContext == PG_PROVMODULE_USERCTXT_PRIVILEGED) &&
681 !System::isPrivilegedUser(System::getEffectiveUserName()))
682 kumpf 1.62 #endif
683 )
684 {
685 response = _oopProviderManagerRouter->processMessage(request);
686 }
687 else
688 {
689 response = _basicProviderManagerRouter->processMessage(request);
690 }
691 }
692
693 return response;
694 }
695
|
696 kumpf 1.44 void ProviderManagerService::unloadIdleProviders()
697 {
698 PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
699 "ProviderManagerService::unloadIdleProviders");
700
701 // Ensure that only one _unloadIdleProvidersHandler thread runs at a time
702 _unloadIdleProvidersBusy++;
703 if ((_unloadIdleProvidersBusy.value() == 1) &&
704 (_thread_pool->allocate_and_awaken(
705 (void*)this, ProviderManagerService::_unloadIdleProvidersHandler)))
706 {
707 // _unloadIdleProvidersBusy is decremented in
708 // _unloadIdleProvidersHandler
709 }
710 else
711 {
712 // If we fail to allocate a thread, don't retry now.
713 _unloadIdleProvidersBusy--;
714 }
715
716 PEG_METHOD_EXIT();
717 kumpf 1.44 }
718
719 PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL
720 ProviderManagerService::_unloadIdleProvidersHandler(void* arg) throw()
|
721 chip 1.1 {
|
722 kumpf 1.44 try
723 {
724 PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
725 "ProviderManagerService::unloadIdleProvidersHandler");
726
727 ProviderManagerService* myself =
728 reinterpret_cast<ProviderManagerService*>(arg);
729
|
730 kumpf 1.62 if (myself->_basicProviderManagerRouter)
|
731 kumpf 1.44 {
|
732 kumpf 1.62 try
733 {
734 myself->_basicProviderManagerRouter->unloadIdleProviders();
735 }
736 catch (...)
737 {
738 // Ignore errors
739 PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
740 "Unexpected exception from "
741 "BasicProviderManagerRouter::_unloadIdleProviders");
742 }
|
743 kumpf 1.44 }
|
744 kumpf 1.62
745 if (myself->_oopProviderManagerRouter)
|
746 kumpf 1.44 {
|
747 kumpf 1.62 try
748 {
749 myself->_oopProviderManagerRouter->unloadIdleProviders();
750 }
751 catch (...)
752 {
753 // Ignore errors
754 PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
755 "Unexpected exception from "
756 "OOPProviderManagerRouter::_unloadIdleProviders");
757 }
|
758 kumpf 1.44 }
759
760 myself->_unloadIdleProvidersBusy--;
761 PEG_METHOD_EXIT();
762 }
763 catch (...)
764 {
765 // Ignore errors
766 PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
767 "Unexpected exception in _unloadIdleProvidersHandler");
768 }
769
770 return(PEGASUS_THREAD_RETURN(0));
|
771 kumpf 1.38 }
772
773 // Updates the providerModule instance and the ProviderRegistrationManager
774 void ProviderManagerService::_updateProviderModuleStatus(
775 CIMInstance& providerModule,
776 Uint16 fromStatus,
777 Uint16 toStatus)
778 {
779 PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
780 "ProviderManagerService::_updateProviderModuleStatus");
781
782 Array<Uint16> operationalStatus;
783 String providerModuleName;
784
785 Uint32 pos = providerModule.findProperty(CIMName("Name"));
786 PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
787 providerModule.getProperty(pos).getValue().get(providerModuleName);
788
789 //
790 // get operational status
791 //
792 kumpf 1.38 pos = providerModule.findProperty(CIMName("OperationalStatus"));
793 PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
794 CIMProperty operationalStatusProperty = providerModule.getProperty(pos);
795 CIMValue operationalStatusValue = operationalStatusProperty.getValue();
796
797 if (!operationalStatusValue.isNull())
798 {
799 operationalStatusValue.get(operationalStatus);
800 }
801
802 //
803 // update module status
804 //
805 for (Uint32 i = operationalStatus.size(); i > 0; i--)
806 {
807 if (operationalStatus[i-1] == fromStatus)
808 {
809 operationalStatus.remove(i-1);
810 }
811 }
812
813 kumpf 1.38 operationalStatus.append(toStatus);
814
815 if (_providerRegistrationManager->setProviderModuleStatus(
816 providerModuleName, operationalStatus) == false)
817 {
818 throw PEGASUS_CIM_EXCEPTION_L(
819 CIM_ERR_FAILED,
820 MessageLoaderParms(
821 "ProviderManager.ProviderManagerService."
822 "SET_MODULE_STATUS_FAILED",
823 "set module status failed."));
824 }
825
826 operationalStatusProperty.setValue(CIMValue(operationalStatus));
827
828 PEG_METHOD_EXIT();
|
829 kumpf 1.39 }
830
831 void ProviderManagerService::indicationCallback(
832 CIMProcessIndicationRequestMessage* request)
833 {
|
834 se.gupta 1.52 try
835 {
836 AcceptLanguageListContainer cntr = request->operationContext.get(AcceptLanguageListContainer::NAME);
|
837 david.dillard 1.55 }catch(const Exception &)
|
838 se.gupta 1.52 {
839 request->operationContext.insert(AcceptLanguageListContainer(AcceptLanguages::EMPTY));
840 }
841
842 if (_indicationServiceQueueId == PEG_NOT_FOUND)
|
843 kumpf 1.39 {
844 Array<Uint32> serviceIds;
845
846 providerManagerService->find_services(
847 PEGASUS_QUEUENAME_INDICATIONSERVICE, 0, 0, &serviceIds);
848 PEGASUS_ASSERT(serviceIds.size() != 0);
849
850 _indicationServiceQueueId = serviceIds[0];
851 }
852
853 request->queueIds = QueueIdStack(
854 _indicationServiceQueueId, providerManagerService->getQueueId());
855
856 AsyncLegacyOperationStart * asyncRequest =
857 new AsyncLegacyOperationStart(
858 providerManagerService->get_next_xid(),
859 0,
860 _indicationServiceQueueId,
861 request,
862 _indicationServiceQueueId);
863
864 kumpf 1.39 providerManagerService->SendForget(asyncRequest);
|
865 chip 1.1 }
866
|
867 a.arora 1.37 PEGASUS_NAMESPACE_END
|