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