1 karl 1.42 //%2005////////////////////////////////////////////////////////////////////////
|
2 mday 1.1 //
|
3 karl 1.41 // 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.39 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.41 // 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.42 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 mday 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 david.dillard 1.45 //
|
19 mday 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: Mike Day (mdday@us.ibm.com)
31 //
|
32 david.dillard 1.45 // Modified By: David Dillard, VERITAS Software Corp.
33 // (david.dillard@veritas.com)
|
34 mday 1.1 //
35 //%/////////////////////////////////////////////////////////////////////////////
36
37 #ifndef Pegasus_MessageQueue_Service_h
38 #define Pegasus_MessageQueue_Service_h
39
40 #include <Pegasus/Common/Config.h>
41 #include <Pegasus/Common/Message.h>
|
42 kumpf 1.34 #include <Pegasus/Common/InternalException.h>
|
43 mday 1.1 #include <Pegasus/Common/IPC.h>
44 #include <Pegasus/Common/Thread.h>
45 #include <Pegasus/Common/AsyncOpNode.h>
46 #include <Pegasus/Common/Cimom.h>
47 #include <Pegasus/Common/CimomMessage.h>
|
48 kumpf 1.33 #include <Pegasus/Common/Linkage.h>
|
49 mday 1.1
50 PEGASUS_NAMESPACE_BEGIN
51
|
52 mday 1.10 extern const Uint32 CIMOM_Q_ID;
|
53 mday 1.9
|
54 mday 1.3 class message_module;
55
|
56 mday 1.1 class PEGASUS_COMMON_LINKAGE MessageQueueService : public MessageQueue
57 {
|
58 david.dillard 1.45 public:
59
60 typedef MessageQueue Base;
|
61 mday 1.1
|
62 david.dillard 1.45 MessageQueueService(const char *name,
63 Uint32 queueID = MessageQueue::getNextQueueId(),
64 Uint32 capabilities = 0,
65 Uint32 mask = message_mask::type_cimom |
66 message_mask::type_service |
67 message_mask::ha_request |
68 message_mask::ha_reply |
69 message_mask::ha_async );
70
71 virtual ~MessageQueueService();
72
73 virtual Boolean isAsync() const { return true; }
74
75 // enqueue may throw an IPCException
76 virtual void enqueue(Message *);
77
78 AsyncReply *SendWait(AsyncRequest *request);
79 Boolean SendAsync(AsyncOpNode *op,
80 Uint32 destination,
81 void (*callback)(AsyncOpNode *, MessageQueue *, void *),
82 MessageQueue *callback_q,
83 david.dillard 1.45 void *callback_ptr);
84
85 Boolean SendAsync(Message *msg,
86 Uint32 destination,
87 void (*callback)(Message *response, void *handle, void *parameter),
88 void *handle,
89 void *parameter);
90
91 Boolean SendForget(Message *msg);
92 Boolean ForwardOp(AsyncOpNode *, Uint32 destination);
93
94
95 Boolean register_service(String name, Uint32 capabilities, Uint32 mask);
96 Boolean update_service(Uint32 capabilities, Uint32 mask);
97 Boolean deregister_service();
98 virtual void _shutdown_incoming_queue();
99
100 void find_services(String name,
101 Uint32 capabilities,
102 Uint32 mask,
103 Array<Uint32> *results);
104 david.dillard 1.45 void enumerate_service(Uint32 queue, message_module *result);
105 Uint32 get_next_xid();
106 static AsyncOpNode *get_op();
107 void return_op(AsyncOpNode *op);
108
109 Boolean operator ==(const MessageQueueService & svce) const
110 {
111 return operator==((const void *)&svce);
112 }
113
114 Boolean operator ==(const void *svce) const
115 {
116 if((const void *)this == svce)
117 return true;
118 return false;
119 }
120
121 static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL polling_routine(void *);
122 static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL kill_idle_threads(void *);
123 static ThreadPool *get_thread_pool();
124
125 david.dillard 1.45 Uint32 _mask;
126 AtomicInt _die;
|
127 konrad.r 1.48 AtomicInt _threads;
|
128 david.dillard 1.45
129 protected:
130 virtual Boolean accept_async(AsyncOpNode *op);
131 virtual Boolean messageOK(const Message *msg);
132 virtual void handleEnqueue() = 0;
133 virtual void handleEnqueue(Message *) = 0;
134 Boolean _enqueueResponse(Message *, Message *);
|
135 mday 1.22 // virtual void _handle_incoming_operation(AsyncOpNode *operation, Thread *thread, MessageQueue *queue);
|
136 david.dillard 1.45 virtual void _handle_incoming_operation(AsyncOpNode *);
137
138 virtual void _handle_async_request(AsyncRequest *req);
139 virtual void _handle_async_callback(AsyncOpNode *operation);
140 virtual void _make_response(Message *req, Uint32 code);
141
142 virtual void handle_heartbeat_request(AsyncRequest *req);
143 virtual void handle_heartbeat_reply(AsyncReply *rep);
144
145 virtual void handle_AsyncIoctl(AsyncIoctl *req);
146 virtual void handle_CimServiceStart(CimServiceStart *req);
147 virtual void handle_CimServiceStop(CimServiceStop *req);
148 virtual void handle_CimServicePause(CimServicePause *req);
149 virtual void handle_CimServiceResume(CimServiceResume *req);
150
151 virtual void handle_AsyncOperationStart(AsyncOperationStart *req);
152 virtual void handle_AsyncOperationResult(AsyncOperationResult *rep);
153 virtual void handle_AsyncLegacyOperationStart(AsyncLegacyOperationStart *req);
154 virtual void handle_AsyncLegacyOperationResult(AsyncLegacyOperationResult *rep);
155
156 void _completeAsyncResponse(AsyncRequest *request,
157 david.dillard 1.45 AsyncReply *reply,
158 Uint32 state,
159 Uint32 flag);
160 void _complete_op_node(AsyncOpNode *, Uint32, Uint32, Uint32);
161
162 static cimom *_meta_dispatcher;
163 static AtomicInt _service_count;
164 static Mutex _meta_dispatcher_mutex;
165
166 private:
167 AsyncDQueue<AsyncOpNode> _incoming;
168 static Thread* _polling_thread;
169 static Semaphore _polling_sem;
170 static AtomicInt _stop_polling;
171 static AtomicInt _check_idle_flag;
172
173 static DQueue<MessageQueueService> _polling_list;
174
175 static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL _req_proc(void *);
176
177 static void _sendwait_callback(AsyncOpNode *, MessageQueue *, void *);
178 david.dillard 1.45
179 AtomicInt _incoming_queue_shutdown;
180
181 protected:
182 static ThreadPool *_thread_pool;
183
184 private:
185 struct timeval _default_op_timeout;
186 static AtomicInt _xid;
187 friend class cimom;
188 friend class CIMServer;
|
189 mday 1.1 };
190
191 PEGASUS_NAMESPACE_END
192
193 #endif /* Pegasus_MessageQueue_Service_h */
|