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 jim.wunderlich 1.49 // Jim Wunderlich (Jim_Wunderlich@prodigy.net)
|
35 mday 1.1 //
36 //%/////////////////////////////////////////////////////////////////////////////
37
38 #ifndef Pegasus_MessageQueue_Service_h
39 #define Pegasus_MessageQueue_Service_h
40
41 #include <Pegasus/Common/Config.h>
42 #include <Pegasus/Common/Message.h>
|
43 kumpf 1.34 #include <Pegasus/Common/InternalException.h>
|
44 mday 1.1 #include <Pegasus/Common/IPC.h>
45 #include <Pegasus/Common/Thread.h>
46 #include <Pegasus/Common/AsyncOpNode.h>
47 #include <Pegasus/Common/Cimom.h>
48 #include <Pegasus/Common/CimomMessage.h>
|
49 kumpf 1.33 #include <Pegasus/Common/Linkage.h>
|
50 mday 1.1
51 PEGASUS_NAMESPACE_BEGIN
52
|
53 mday 1.10 extern const Uint32 CIMOM_Q_ID;
|
54 mday 1.9
|
55 mday 1.3 class message_module;
56
|
57 mday 1.1 class PEGASUS_COMMON_LINKAGE MessageQueueService : public MessageQueue
58 {
|
59 david.dillard 1.45 public:
60
61 typedef MessageQueue Base;
|
62 mday 1.1
|
63 david.dillard 1.45 MessageQueueService(const char *name,
64 Uint32 queueID = MessageQueue::getNextQueueId(),
65 Uint32 capabilities = 0,
66 Uint32 mask = message_mask::type_cimom |
67 message_mask::type_service |
68 message_mask::ha_request |
69 message_mask::ha_reply |
70 message_mask::ha_async );
71
72 virtual ~MessageQueueService();
73
74 virtual Boolean isAsync() const { return true; }
75
76 // enqueue may throw an IPCException
77 virtual void enqueue(Message *);
78
79 AsyncReply *SendWait(AsyncRequest *request);
80 Boolean SendAsync(AsyncOpNode *op,
81 Uint32 destination,
82 void (*callback)(AsyncOpNode *, MessageQueue *, void *),
83 MessageQueue *callback_q,
84 david.dillard 1.45 void *callback_ptr);
85
86 Boolean SendAsync(Message *msg,
87 Uint32 destination,
88 void (*callback)(Message *response, void *handle, void *parameter),
89 void *handle,
90 void *parameter);
91
92 Boolean SendForget(Message *msg);
93 Boolean ForwardOp(AsyncOpNode *, Uint32 destination);
94
95
96 Boolean register_service(String name, Uint32 capabilities, Uint32 mask);
97 Boolean update_service(Uint32 capabilities, Uint32 mask);
98 Boolean deregister_service();
99 virtual void _shutdown_incoming_queue();
100
101 void find_services(String name,
102 Uint32 capabilities,
103 Uint32 mask,
104 Array<Uint32> *results);
105 david.dillard 1.45 void enumerate_service(Uint32 queue, message_module *result);
106 Uint32 get_next_xid();
107 static AsyncOpNode *get_op();
108 void return_op(AsyncOpNode *op);
109
110 Boolean operator ==(const MessageQueueService & svce) const
111 {
112 return operator==((const void *)&svce);
113 }
114
115 Boolean operator ==(const void *svce) const
116 {
117 if((const void *)this == svce)
118 return true;
119 return false;
120 }
121
122 static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL polling_routine(void *);
123 static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL kill_idle_threads(void *);
124 static ThreadPool *get_thread_pool();
125
126 david.dillard 1.45 Uint32 _mask;
127 AtomicInt _die;
|
128 konrad.r 1.48 AtomicInt _threads;
|
129 jim.wunderlich 1.49 Uint32 getIncomingCount() {return _incoming.count(); }
|
130 david.dillard 1.45
131 protected:
132 virtual Boolean accept_async(AsyncOpNode *op);
133 virtual Boolean messageOK(const Message *msg);
134 virtual void handleEnqueue() = 0;
135 virtual void handleEnqueue(Message *) = 0;
136 Boolean _enqueueResponse(Message *, Message *);
|
137 mday 1.22 // virtual void _handle_incoming_operation(AsyncOpNode *operation, Thread *thread, MessageQueue *queue);
|
138 david.dillard 1.45 virtual void _handle_incoming_operation(AsyncOpNode *);
139
140 virtual void _handle_async_request(AsyncRequest *req);
141 virtual void _handle_async_callback(AsyncOpNode *operation);
142 virtual void _make_response(Message *req, Uint32 code);
143
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 david.dillard 1.45 AsyncReply *reply,
160 Uint32 state,
161 Uint32 flag);
162 void _complete_op_node(AsyncOpNode *, Uint32, Uint32, Uint32);
163
164 static cimom *_meta_dispatcher;
165 static AtomicInt _service_count;
166 static Mutex _meta_dispatcher_mutex;
167
168 private:
169 AsyncDQueue<AsyncOpNode> _incoming;
170 static Thread* _polling_thread;
171 static Semaphore _polling_sem;
172 static AtomicInt _stop_polling;
173 static AtomicInt _check_idle_flag;
174
175 static DQueue<MessageQueueService> _polling_list;
176
177 static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL _req_proc(void *);
178
179 static void _sendwait_callback(AsyncOpNode *, MessageQueue *, void *);
180 david.dillard 1.45
181 AtomicInt _incoming_queue_shutdown;
182
183 protected:
184 static ThreadPool *_thread_pool;
185
186 private:
187 struct timeval _default_op_timeout;
188 static AtomicInt _xid;
189 friend class cimom;
190 friend class CIMServer;
|
191 mday 1.1 };
192
193 PEGASUS_NAMESPACE_END
194
195 #endif /* Pegasus_MessageQueue_Service_h */
|