1 karl 1.37 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.30 // 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.28 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.30 // 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.31 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.37 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.2 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 chip 1.5 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
18 mike 1.2 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 kumpf 1.21 //
|
21 chip 1.5 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 mike 1.2 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
24 chip 1.5 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
27 mike 1.2 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
33 //
34 // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
|
35 kumpf 1.22 // Carol Ann Krug Graves, Hewlett-Packard Company
36 // (carolann_graves@hp.com)
|
37 kumpf 1.26 // Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
|
38 vijay.eli 1.34 // Vijay Eli, IBM (vijayeli@in.ibm.com)
|
39 j.alex 1.36 // John Alex, IBM (johnalex@us.ibm.com) - Bug#2290
|
40 mike 1.2 //
41 //%/////////////////////////////////////////////////////////////////////////////
42
43 #include <Pegasus/Common/Config.h>
|
44 kumpf 1.13 #include <Pegasus/Common/Constants.h>
|
45 mike 1.2 #include <Pegasus/Common/HTTPMessage.h>
|
46 kumpf 1.15 #include <Pegasus/Common/PegasusVersion.h>
|
47 kumpf 1.19 #include <Pegasus/Common/Tracer.h>
|
48 kumpf 1.26 #include <Pegasus/Common/MessageQueueService.h>
49 #include <Pegasus/Server/CIMOperationRequestDispatcher.h>
|
50 mike 1.2
51 #include "CIMExportRequestDispatcher.h"
52
53 PEGASUS_USING_STD;
54
55 PEGASUS_NAMESPACE_BEGIN
56
57 CIMExportRequestDispatcher::CIMExportRequestDispatcher(
|
58 mday 1.7 Boolean dynamicReg, Boolean staticConsumers, Boolean persistence)
|
59 kumpf 1.13 : Base(PEGASUS_QUEUENAME_EXPORTREQDISPATCHER),
|
60 chip 1.11 _dynamicReg(dynamicReg),
61 _staticConsumers(staticConsumers),
|
62 mday 1.7 _persistence(persistence)
|
63 mike 1.2 {
|
64 kumpf 1.19 PEG_METHOD_ENTER(TRC_EXP_REQUEST_DISP,
65 "CIMExportRequestDispatcher::CIMExportRequestDispatcher");
66 PEG_METHOD_EXIT();
|
67 kumpf 1.6 }
|
68 mike 1.2
|
69 kumpf 1.6 CIMExportRequestDispatcher::CIMExportRequestDispatcher()
|
70 s.hills 1.27 : Base(PEGASUS_QUEUENAME_EXPORTREQDISPATCHER),
71 _dynamicReg( true ),
72 _staticConsumers( false ),
73 _persistence( false )
|
74 kumpf 1.6 {
|
75 kumpf 1.19 PEG_METHOD_ENTER(TRC_EXP_REQUEST_DISP,
76 "CIMExportRequestDispatcher::CIMExportRequestDispatcher");
|
77 mday 1.7
|
78 kumpf 1.19 PEG_METHOD_EXIT();
|
79 mike 1.2 }
80
81 CIMExportRequestDispatcher::~CIMExportRequestDispatcher()
82 {
|
83 kumpf 1.19 PEG_METHOD_ENTER(TRC_EXP_REQUEST_DISP,
84 "CIMExportRequestDispatcher::~CIMExportRequestDispatcher");
|
85 mike 1.2
|
86 kumpf 1.19 PEG_METHOD_EXIT();
|
87 mike 1.2 }
88
|
89 kumpf 1.8 void CIMExportRequestDispatcher::_handle_async_request(AsyncRequest *req)
|
90 mike 1.2 {
|
91 kumpf 1.19 PEG_METHOD_ENTER(TRC_EXP_REQUEST_DISP,
92 "CIMExportRequestDispatcher::_handle_async_request");
93
|
94 kumpf 1.29 PEGASUS_ASSERT(req != 0 && req->op != 0 );
95
|
96 kumpf 1.8 if ( req->getType() == async_messages::CIMSERVICE_STOP )
97 {
98 req->op->processing();
99 handle_CimServiceStop(static_cast<CimServiceStop *>(req));
100 }
101 else if ( req->getType() == async_messages::ASYNC_LEGACY_OP_START )
102 {
103 req->op->processing();
|
104 kumpf 1.29 Message *legacy =
105 (static_cast<AsyncLegacyOperationStart *>(req)->get_action());
106 if (legacy->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE)
107 {
108 Message* legacy_response = _handleExportIndicationRequest(
109 (CIMExportIndicationRequestMessage*) legacy);
110 AsyncLegacyOperationResult *async_result =
111 new AsyncLegacyOperationResult(
112 req->getKey(),
113 req->getRouting(),
114 req->op,
115 legacy_response);
116
117 _complete_op_node(req->op, ASYNC_OPSTATE_COMPLETE, 0, 0);
118 delete legacy;
119 }
120 else
121 {
122 Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
123 "CIMExportRequestDispatcher::_handle_async_request got "
124 "unexpected legacy message type '%u'", legacy->getType());
125 kumpf 1.29 _make_response(req, async_results::CIM_NAK);
126 delete legacy;
127 }
|
128 kumpf 1.8 }
129 else
|
130 kumpf 1.19 {
|
131 kumpf 1.8 Base::_handle_async_request(req);
|
132 kumpf 1.19 }
133 PEG_METHOD_EXIT();
|
134 kumpf 1.8 }
|
135 mike 1.2
|
136 kumpf 1.29 // This callback method is currently unused. ExportIndication messages
137 // are passed to the ProviderManager using SendWait rather than SendAsync
138 // so the responses can be routed correctly.
|
139 kumpf 1.26 void CIMExportRequestDispatcher::_forwardRequestCallback(AsyncOpNode *op,
140 MessageQueue *q,
141 void *parm)
142 {
|
143 kumpf 1.29 PEGASUS_ASSERT(0);
144 #if 0
|
145 kumpf 1.26 CIMExportRequestDispatcher *service =
146 static_cast<CIMExportRequestDispatcher *>(q);
147
148 AsyncRequest *asyncRequest = static_cast<AsyncRequest *>(op->get_request());
149 AsyncReply *asyncReply = static_cast<AsyncReply *>(op->get_response());
150
151 CIMResponseMessage *response;
152
153 Uint32 msgType = asyncReply->getType();
154
155 if(msgType == async_messages::ASYNC_LEGACY_OP_RESULT)
156 {
|
157 kumpf 1.29 response = reinterpret_cast<CIMResponseMessage *>(
158 (static_cast<AsyncLegacyOperationResult *>(asyncReply))->
159 get_result());
|
160 kumpf 1.26 }
161 else if(msgType == async_messages::ASYNC_MODULE_OP_RESULT)
162 {
|
163 kumpf 1.29 response = reinterpret_cast<CIMResponseMessage *>(
164 (static_cast<AsyncModuleOperationResult *>(asyncReply))->
165 get_result());
|
166 kumpf 1.26 }
167 else
168 {
169 // Error
|
170 kumpf 1.29 Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
171 "CIMExportRequestDispatcher::_forwardRequestCallback got "
172 "unexpected message type '%u'", msgType);
|
173 kumpf 1.26 }
174
175 PEGASUS_ASSERT(response != 0);
176 // ensure that the destination queue is in response->dest
|
177 w.otsuka 1.33 #ifdef PEGASUS_POINTER_64BIT
|
178 kumpf 1.26 response->dest = (Uint64)parm;
179 #elif PEGASUS_PLATFORM_AIX_RS_IBMCXX
180 // We cast to unsigned long
181 // because sizeof(void *) == sizeof(unsigned long)
182 response->dest = (unsigned long)parm;
183 #else
184 response->dest = (Uint32)parm;
185 #endif
186
187 if(parm != 0 )
188 service->SendForget(response);
189 else
190 delete response;
191
192 delete asyncRequest;
193 delete asyncReply;
194 op->release();
195 service->return_op(op);
|
196 kumpf 1.29 #endif
|
197 kumpf 1.26 }
198
|
199 mday 1.9 void CIMExportRequestDispatcher::handleEnqueue(Message* message)
|
200 kumpf 1.8 {
|
201 kumpf 1.19 PEG_METHOD_ENTER(TRC_EXP_REQUEST_DISP,
202 "CIMExportRequestDispatcher::handleEnqueue");
|
203 mike 1.2
|
204 mday 1.10 if( ! message)
|
205 kumpf 1.19 {
206 PEG_METHOD_EXIT();
|
207 mday 1.10 return;
|
208 kumpf 1.19 }
|
209 chip 1.11
|
210 kumpf 1.8 switch (message->getType())
|
211 mike 1.2 {
212 case CIM_EXPORT_INDICATION_REQUEST_MESSAGE:
|
213 kumpf 1.29 {
214 CIMExportIndicationResponseMessage* response =
215 _handleExportIndicationRequest(
216 (CIMExportIndicationRequestMessage*) message);
|
217 j.alex 1.36
218 Tracer::trace(
219 TRC_HTTP,
220 Tracer::LEVEL3,
221 "_CIMExportRequestDispatcher::handleEnqueue(message) - message->getCloseConnect() returned %d",
222 message->getCloseConnect());
223
224 response->setCloseConnect(message->getCloseConnect());
225
|
226 kumpf 1.29 SendForget(response);
|
227 mike 1.2 break;
|
228 kumpf 1.29 }
|
229 kumpf 1.8
230 default:
|
231 kumpf 1.29 Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
232 "CIMExportRequestDispatcher::handleEnqueue got unexpected "
233 "message type '%u'", message->getType());
|
234 kumpf 1.8 break;
|
235 mike 1.2 }
|
236 kumpf 1.8 delete message;
|
237 mike 1.2
|
238 kumpf 1.19 PEG_METHOD_EXIT();
|
239 mike 1.2 }
|
240 mday 1.10
241
242 void CIMExportRequestDispatcher::handleEnqueue()
243 {
|
244 kumpf 1.19 PEG_METHOD_ENTER(TRC_EXP_REQUEST_DISP,
245 "CIMExportRequestDispatcher::handleEnqueue");
246
|
247 mday 1.10 Message *message = dequeue();
248 if(message)
249 handleEnqueue(message);
|
250 chip 1.11
|
251 kumpf 1.19 PEG_METHOD_EXIT();
|
252 mday 1.10 }
253
|
254 mike 1.2
|
255 kumpf 1.29 CIMExportIndicationResponseMessage*
256 CIMExportRequestDispatcher::_handleExportIndicationRequest(
|
257 mike 1.2 CIMExportIndicationRequestMessage* request)
258 {
|
259 kumpf 1.19 PEG_METHOD_ENTER(TRC_EXP_REQUEST_DISP,
|
260 vijay.eli 1.34 "CIMExportRequestDispatcher::_handleExportIndicationRequest");
|
261 kumpf 1.19
|
262 mike 1.2 OperationContext context;
263
|
264 kumpf 1.12 CIMException cimException;
|
265 mike 1.2
|
266 kumpf 1.26 Array<Uint32> serviceIds;
267 find_services(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP, 0, 0, &serviceIds);
268 PEGASUS_ASSERT(serviceIds.size() != 0);
269
270 AsyncOpNode * op = this->get_op();
271
272 AsyncLegacyOperationStart * asyncRequest =
273 new AsyncLegacyOperationStart(
274 get_next_xid(),
275 op,
276 serviceIds[0],
|
277 kumpf 1.29 new CIMExportIndicationRequestMessage(*request),
|
278 kumpf 1.26 this->getQueueId());
279
280 asyncRequest->dest = serviceIds[0];
281
|
282 kumpf 1.29 //SendAsync(op,
283 // serviceIds[0],
284 // CIMExportRequestDispatcher::_forwardRequestCallback,
285 // this,
286 // (void *)request->queueIds.top());
287 AsyncReply *asyncReply = SendWait(asyncRequest);
288
289 CIMExportIndicationResponseMessage* response =
290 reinterpret_cast<CIMExportIndicationResponseMessage *>(
291 (static_cast<AsyncLegacyOperationResult *>(
292 asyncReply))->get_result());
293 response->dest = request->queueIds.top();
294 response->synch_response(request);
295
296 delete asyncReply; // Recipient deletes request
297 op->release();
298 this->return_op(op);
299
|
300 kumpf 1.19 PEG_METHOD_EXIT();
|
301 kumpf 1.29 return response;
|
302 mike 1.2 }
303
304 PEGASUS_NAMESPACE_END
|