1 karl 1.41 //%2004////////////////////////////////////////////////////////////////////////
|
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 mday 1.1 //
10 // Permission is hereby granted, free of charge, to any person obtaining a copy
11 // of this software and associated documentation files (the "Software"), to
12 // deal in the Software without restriction, including without limitation the
13 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
14 // sell copies of the Software, and to permit persons to whom the Software is
15 // furnished to do so, subject to the following conditions:
|
16 karl 1.39 //
|
17 mday 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
18 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
19 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
20 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 //
26 //==============================================================================
27 //
28 // Author: Mike Day (mdday@us.ibm.com)
29 //
30 // Modified By:
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34 #ifndef Pegasus_MessageQueue_Service_h
35 #define Pegasus_MessageQueue_Service_h
36
37 #include <Pegasus/Common/Config.h>
38 mday 1.1 #include <Pegasus/Common/Message.h>
|
39 kumpf 1.34 #include <Pegasus/Common/InternalException.h>
|
40 mday 1.1 #include <Pegasus/Common/IPC.h>
41 #include <Pegasus/Common/Thread.h>
42 #include <Pegasus/Common/AsyncOpNode.h>
43 #include <Pegasus/Common/Cimom.h>
44 #include <Pegasus/Common/CimomMessage.h>
|
45 kumpf 1.33 #include <Pegasus/Common/Linkage.h>
|
46 mday 1.1
47 PEGASUS_NAMESPACE_BEGIN
48
|
49 mday 1.10 extern const Uint32 CIMOM_Q_ID;
|
50 mday 1.9
|
51 mday 1.3 class message_module;
52
|
53 mday 1.1 class PEGASUS_COMMON_LINKAGE MessageQueueService : public MessageQueue
54 {
55 public:
56
57 typedef MessageQueue Base;
58
|
59 kumpf 1.23 MessageQueueService(const char *name,
60 Uint32 queueID = MessageQueue::getNextQueueId(),
|
61 mday 1.10 Uint32 capabilities = 0,
62 Uint32 mask = message_mask::type_cimom |
63 message_mask::type_service |
64 message_mask::ha_request |
65 message_mask::ha_reply |
66 message_mask::ha_async ) ;
|
67 mday 1.1
68 virtual ~MessageQueueService(void);
|
69 mday 1.20
|
70 mday 1.10 virtual Boolean isAsync(void) { return true; }
|
71 kumpf 1.40
72 // enqueue may throw an IPCException
73 virtual void enqueue(Message *);
|
74 mday 1.15
|
75 mday 1.3 AsyncReply *SendWait(AsyncRequest *request);
|
76 mday 1.14 Boolean SendAsync(AsyncOpNode *op,
77 Uint32 destination,
|
78 mday 1.18 void (*callback)(AsyncOpNode *, MessageQueue *, void *),
79 MessageQueue *callback_q,
80 void *callback_ptr);
|
81 mday 1.24
82 Boolean SendAsync(Message *msg,
83 Uint32 destination,
84 void (*callback)(Message *response, void *handle, void *parameter),
85 void *handle,
86 void *parameter);
87
|
88 mday 1.25 Uint32 get_pending_callback_count(void);
89
|
90 mday 1.12 Boolean SendForget(Message *msg);
|
91 mday 1.17 Boolean ForwardOp(AsyncOpNode *, Uint32 destination);
92
|
93 mday 1.19
|
94 mday 1.1 Boolean register_service(String name, Uint32 capabilities, Uint32 mask);
95 Boolean update_service(Uint32 capabilities, Uint32 mask);
96 Boolean deregister_service(void);
|
97 mday 1.6 virtual void _shutdown_incoming_queue(void);
|
98 mday 1.20
|
99 mday 1.1 void find_services(String name,
100 Uint32 capabilities,
101 Uint32 mask,
102 Array<Uint32> *results);
103 void enumerate_service(Uint32 queue, message_module *result);
104 Uint32 get_next_xid(void);
|
105 mday 1.27 static AsyncOpNode *get_op(void);
|
106 mday 1.1 void return_op(AsyncOpNode *op);
|
107 mday 1.15
|
108 mday 1.27 Boolean operator ==(const MessageQueueService & svce)
109 {
110 return operator==((const void *)&svce);
111 }
112 Boolean operator ==(const void *svce)
113 {
114 if((void *)this == svce)
115 return true;
116 return false;
117 }
118
119 static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL polling_routine(void *);
|
120 mday 1.36 static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL kill_idle_threads(void *);
|
121 mday 1.27 static int pooled_threads(void)
122 {
|
123 mday 1.29 return _thread_pool->running_count() + _thread_pool->dead_count() + _thread_pool->pool_count();
|
124 mday 1.27 }
|
125 mday 1.36 static ThreadPool *get_thread_pool(void);
|
126 mday 1.38 static void force_shutdown(Boolean destroy_flag = false);
|
127 mday 1.27
|
128 mday 1.1 Uint32 _mask;
129 AtomicInt _die;
130 protected:
|
131 mday 1.19 virtual Boolean accept_async(AsyncOpNode *op);
132 virtual Boolean messageOK(const Message *msg) ;
|
133 mday 1.16 virtual void handleEnqueue(void) = 0;
134 virtual void handleEnqueue(Message *) = 0;
135 Boolean _enqueueResponse(Message *, Message *);
|
136 mday 1.22 // virtual void _handle_incoming_operation(AsyncOpNode *operation, Thread *thread, MessageQueue *queue);
137 virtual void _handle_incoming_operation(AsyncOpNode *);
138
|
139 mday 1.3 virtual void _handle_async_request(AsyncRequest *req);
|
140 mday 1.15 virtual void _handle_async_callback(AsyncOpNode *operation);
|
141 mday 1.12 virtual void _make_response(Message *req, Uint32 code);
|
142 mday 1.13
|
143 mday 1.19
144 virtual void handle_heartbeat_request(AsyncRequest *req);
145 virtual void handle_heartbeat_reply(AsyncReply *rep);
146
147 virtual void handle_AsyncIoctl(AsyncIoctl *req);
148 virtual void handle_CimServiceStart(CimServiceStart *req);
149 virtual void handle_CimServiceStop(CimServiceStop *req);
150 virtual void handle_CimServicePause(CimServicePause *req);
151 virtual void handle_CimServiceResume(CimServiceResume *req);
152
153 virtual void handle_AsyncOperationStart(AsyncOperationStart *req);
154 virtual void handle_AsyncOperationResult(AsyncOperationResult *rep);
155 virtual void handle_AsyncLegacyOperationStart(AsyncLegacyOperationStart *req);
156 virtual void handle_AsyncLegacyOperationResult(AsyncLegacyOperationResult *rep);
157
158 void _completeAsyncResponse(AsyncRequest *request,
159 AsyncReply *reply,
160 Uint32 state,
161 Uint32 flag);
|
162 mday 1.20 void _complete_op_node(AsyncOpNode *, Uint32, Uint32, Uint32);
163
|
164 mday 1.19
|
165 mday 1.10 static cimom *_meta_dispatcher;
166 static AtomicInt _service_count;
167 static Mutex _meta_dispatcher_mutex;
168
|
169 mday 1.1 private:
|
170 mday 1.12
|
171 mday 1.5 AsyncDQueue<AsyncOpNode> _incoming;
|
172 mday 1.24 DQueue<AsyncOpNode> _callback;
|
173 kumpf 1.31 static Thread* _polling_thread;
|
174 mday 1.27 static Semaphore _polling_sem;
175 static AtomicInt _stop_polling;
|
176 mday 1.36 static AtomicInt _check_idle_flag;
|
177 mday 1.27
178 static DQueue<MessageQueueService> _polling_list;
|
179 mday 1.20
|
180 mday 1.3 static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL _req_proc(void *);
|
181 mday 1.24 static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL _callback_proc(void *);
182
|
183 mday 1.21 static void _sendwait_callback(AsyncOpNode *, MessageQueue *, void *);
|
184 mday 1.30
|
185 mday 1.6 AtomicInt _incoming_queue_shutdown;
|
186 mday 1.24 Semaphore _callback_ready;
187
|
188 mday 1.3 Thread _req_thread;
|
189 mday 1.24 Thread _callback_thread;
|
190 mday 1.27 protected:
|
191 mday 1.29 static ThreadPool *_thread_pool;
|
192 mday 1.27 private:
|
193 mday 1.1 struct timeval _default_op_timeout;
194 static AtomicInt _xid;
|
195 mday 1.19 friend class cimom;
|
196 mday 1.36 friend class CIMServer;
|
197 mday 1.37 friend class monitor_2;
198
|
199 mday 1.1 };
200
201 PEGASUS_NAMESPACE_END
202
203 #endif /* Pegasus_MessageQueue_Service_h */
204
205
|