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 karl 1.39 //
|
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 // Modified By:
33 //
34 //%/////////////////////////////////////////////////////////////////////////////
35
36 #ifndef Pegasus_MessageQueue_Service_h
37 #define Pegasus_MessageQueue_Service_h
38
39 #include <Pegasus/Common/Config.h>
40 mday 1.1 #include <Pegasus/Common/Message.h>
|
41 kumpf 1.34 #include <Pegasus/Common/InternalException.h>
|
42 mday 1.1 #include <Pegasus/Common/IPC.h>
43 #include <Pegasus/Common/Thread.h>
44 #include <Pegasus/Common/AsyncOpNode.h>
45 #include <Pegasus/Common/Cimom.h>
46 #include <Pegasus/Common/CimomMessage.h>
|
47 kumpf 1.33 #include <Pegasus/Common/Linkage.h>
|
48 mday 1.1
49 PEGASUS_NAMESPACE_BEGIN
50
|
51 mday 1.10 extern const Uint32 CIMOM_Q_ID;
|
52 mday 1.9
|
53 mday 1.3 class message_module;
54
|
55 mday 1.1 class PEGASUS_COMMON_LINKAGE MessageQueueService : public MessageQueue
56 {
57 public:
58
59 typedef MessageQueue Base;
60
|
61 kumpf 1.23 MessageQueueService(const char *name,
62 Uint32 queueID = MessageQueue::getNextQueueId(),
|
63 mday 1.10 Uint32 capabilities = 0,
64 Uint32 mask = message_mask::type_cimom |
65 message_mask::type_service |
66 message_mask::ha_request |
67 message_mask::ha_reply |
68 message_mask::ha_async ) ;
|
69 mday 1.1
70 virtual ~MessageQueueService(void);
|
71 mday 1.20
|
72 mday 1.10 virtual Boolean isAsync(void) { return true; }
|
73 kumpf 1.40
74 // enqueue may throw an IPCException
75 virtual void enqueue(Message *);
|
76 mday 1.15
|
77 mday 1.3 AsyncReply *SendWait(AsyncRequest *request);
|
78 mday 1.14 Boolean SendAsync(AsyncOpNode *op,
79 Uint32 destination,
|
80 mday 1.18 void (*callback)(AsyncOpNode *, MessageQueue *, void *),
81 MessageQueue *callback_q,
82 void *callback_ptr);
|
83 mday 1.24
84 Boolean SendAsync(Message *msg,
85 Uint32 destination,
86 void (*callback)(Message *response, void *handle, void *parameter),
87 void *handle,
88 void *parameter);
89
|
90 mday 1.25 Uint32 get_pending_callback_count(void);
91
|
92 mday 1.12 Boolean SendForget(Message *msg);
|
93 mday 1.17 Boolean ForwardOp(AsyncOpNode *, Uint32 destination);
94
|
95 mday 1.19
|
96 mday 1.1 Boolean register_service(String name, Uint32 capabilities, Uint32 mask);
97 Boolean update_service(Uint32 capabilities, Uint32 mask);
98 Boolean deregister_service(void);
|
99 mday 1.6 virtual void _shutdown_incoming_queue(void);
|
100 mday 1.20
|
101 mday 1.1 void find_services(String name,
102 Uint32 capabilities,
103 Uint32 mask,
104 Array<Uint32> *results);
105 void enumerate_service(Uint32 queue, message_module *result);
106 Uint32 get_next_xid(void);
|
107 mday 1.27 static AsyncOpNode *get_op(void);
|
108 mday 1.1 void return_op(AsyncOpNode *op);
|
109 mday 1.15
|
110 mday 1.27 Boolean operator ==(const MessageQueueService & svce)
111 {
112 return operator==((const void *)&svce);
113 }
114 Boolean operator ==(const void *svce)
115 {
116 if((void *)this == svce)
117 return true;
118 return false;
119 }
120
121 static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL polling_routine(void *);
|
122 mday 1.36 static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL kill_idle_threads(void *);
|
123 mday 1.27 static int pooled_threads(void)
124 {
|
125 mday 1.29 return _thread_pool->running_count() + _thread_pool->dead_count() + _thread_pool->pool_count();
|
126 mday 1.27 }
|
127 mday 1.36 static ThreadPool *get_thread_pool(void);
|
128 mday 1.38 static void force_shutdown(Boolean destroy_flag = false);
|
129 mday 1.27
|
130 mday 1.1 Uint32 _mask;
131 AtomicInt _die;
132 protected:
|
133 mday 1.19 virtual Boolean accept_async(AsyncOpNode *op);
134 virtual Boolean messageOK(const Message *msg) ;
|
135 mday 1.16 virtual void handleEnqueue(void) = 0;
136 virtual void handleEnqueue(Message *) = 0;
137 Boolean _enqueueResponse(Message *, Message *);
|
138 mday 1.22 // virtual void _handle_incoming_operation(AsyncOpNode *operation, Thread *thread, MessageQueue *queue);
139 virtual void _handle_incoming_operation(AsyncOpNode *);
140
|
141 mday 1.3 virtual void _handle_async_request(AsyncRequest *req);
|
142 mday 1.15 virtual void _handle_async_callback(AsyncOpNode *operation);
|
143 mday 1.12 virtual void _make_response(Message *req, Uint32 code);
|
144 mday 1.13
|
145 mday 1.19
146 virtual void handle_heartbeat_request(AsyncRequest *req);
147 virtual void handle_heartbeat_reply(AsyncReply *rep);
148
149 virtual void handle_AsyncIoctl(AsyncIoctl *req);
150 virtual void handle_CimServiceStart(CimServiceStart *req);
151 virtual void handle_CimServiceStop(CimServiceStop *req);
152 virtual void handle_CimServicePause(CimServicePause *req);
153 virtual void handle_CimServiceResume(CimServiceResume *req);
154
155 virtual void handle_AsyncOperationStart(AsyncOperationStart *req);
156 virtual void handle_AsyncOperationResult(AsyncOperationResult *rep);
157 virtual void handle_AsyncLegacyOperationStart(AsyncLegacyOperationStart *req);
158 virtual void handle_AsyncLegacyOperationResult(AsyncLegacyOperationResult *rep);
159
160 void _completeAsyncResponse(AsyncRequest *request,
161 AsyncReply *reply,
162 Uint32 state,
163 Uint32 flag);
|
164 mday 1.20 void _complete_op_node(AsyncOpNode *, Uint32, Uint32, Uint32);
165
|
166 mday 1.19
|
167 mday 1.10 static cimom *_meta_dispatcher;
168 static AtomicInt _service_count;
169 static Mutex _meta_dispatcher_mutex;
170
|
171 mday 1.1 private:
|
172 mday 1.12
|
173 mday 1.5 AsyncDQueue<AsyncOpNode> _incoming;
|
174 mday 1.24 DQueue<AsyncOpNode> _callback;
|
175 kumpf 1.31 static Thread* _polling_thread;
|
176 mday 1.27 static Semaphore _polling_sem;
177 static AtomicInt _stop_polling;
|
178 mday 1.36 static AtomicInt _check_idle_flag;
|
179 mday 1.27
180 static DQueue<MessageQueueService> _polling_list;
|
181 mday 1.20
|
182 mday 1.3 static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL _req_proc(void *);
|
183 mday 1.24 static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL _callback_proc(void *);
184
|
185 mday 1.21 static void _sendwait_callback(AsyncOpNode *, MessageQueue *, void *);
|
186 mday 1.30
|
187 mday 1.6 AtomicInt _incoming_queue_shutdown;
|
188 mday 1.24 Semaphore _callback_ready;
189
|
190 mday 1.3 Thread _req_thread;
|
191 mday 1.24 Thread _callback_thread;
|
192 mday 1.27 protected:
|
193 mday 1.29 static ThreadPool *_thread_pool;
|
194 mday 1.27 private:
|
195 mday 1.1 struct timeval _default_op_timeout;
196 static AtomicInt _xid;
|
197 mday 1.19 friend class cimom;
|
198 mday 1.36 friend class CIMServer;
|
199 mday 1.37 friend class monitor_2;
200
|
201 mday 1.1 };
202
203 PEGASUS_NAMESPACE_END
204
205 #endif /* Pegasus_MessageQueue_Service_h */
206
207
|