1 karl 1.50 //%2006////////////////////////////////////////////////////////////////////////
|
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 karl 1.50 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mday 1.1 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.50 //
|
21 mday 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34 #ifndef Pegasus_MessageQueue_Service_h
35 #define Pegasus_MessageQueue_Service_h
36
37 #include <Pegasus/Common/Config.h>
38 #include <Pegasus/Common/Message.h>
|
39 kumpf 1.34 #include <Pegasus/Common/InternalException.h>
|
40 mday 1.1 #include <Pegasus/Common/Thread.h>
|
41 mike 1.54 #include <Pegasus/Common/ThreadPool.h>
|
42 mday 1.1 #include <Pegasus/Common/AsyncOpNode.h>
43 #include <Pegasus/Common/Cimom.h>
|
44 mike 1.51 #include <Pegasus/Common/Mutex.h>
|
45 mday 1.1 #include <Pegasus/Common/CimomMessage.h>
|
46 kumpf 1.33 #include <Pegasus/Common/Linkage.h>
|
47 mike 1.54 #include <Pegasus/Common/Mutex.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 marek 1.56 class cimom;
|
55 mday 1.3
|
56 mike 1.51
|
57 kumpf 1.59 class PEGASUS_COMMON_LINKAGE MessageQueueService :
|
58 mike 1.51 public Linkable, public MessageQueue
|
59 mday 1.1 {
|
60 david.dillard 1.45 public:
61
62 typedef MessageQueue Base;
|
63 mday 1.1
|
64 kumpf 1.55 MessageQueueService(
|
65 kumpf 1.59 const char* name,
|
66 kumpf 1.55 Uint32 queueID = MessageQueue::getNextQueueId(),
67 Uint32 capabilities = 0,
|
68 venkat.puvvada 1.60 Uint32 mask = MessageMask::ha_request |
|
69 kumpf 1.55 MessageMask::ha_reply |
70 MessageMask::ha_async);
|
71 david.dillard 1.45
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 kumpf 1.59 AsyncReply* SendWait(AsyncRequest* request);
80 Boolean SendAsync(AsyncOpNode* op,
81 Uint32 destination,
82 void (*callback)(AsyncOpNode*, MessageQueue*, void*),
83 MessageQueue* callback_q,
84 void* callback_ptr);
|
85 david.dillard 1.45
86 Boolean SendAsync(Message *msg,
|
87 kumpf 1.59 Uint32 destination,
88 void (*callback)(Message* response, void* handle, void* parameter),
89 void* handle,
90 void* parameter);
|
91 david.dillard 1.45
|
92 kumpf 1.59 Boolean SendForget(Message* msg);
|
93 david.dillard 1.45
94
95 Boolean register_service(String name, Uint32 capabilities, Uint32 mask);
96 Boolean update_service(Uint32 capabilities, Uint32 mask);
97 Boolean deregister_service();
98
|
99 kumpf 1.59 void find_services(
100 String name,
101 Uint32 capabilities,
102 Uint32 mask,
103 Array<Uint32>* results);
104 void enumerate_service(Uint32 queue, message_module* result);
105 static AsyncOpNode* get_op();
106 void return_op(AsyncOpNode* op);
|
107 david.dillard 1.45
|
108 kumpf 1.59 static ThreadPool* get_thread_pool();
|
109 david.dillard 1.45
110 Uint32 _mask;
111 AtomicInt _die;
|
112 kumpf 1.59 AtomicInt _threads;
113 Uint32 getIncomingCount() {return _incoming.count(); }
|
114 david.dillard 1.45
115 protected:
|
116 kumpf 1.61 virtual void _shutdown_incoming_queue();
|
117 kumpf 1.59 virtual Boolean accept_async(AsyncOpNode* op);
118 virtual Boolean messageOK(const Message* msg);
|
119 david.dillard 1.45 virtual void handleEnqueue() = 0;
120 virtual void handleEnqueue(Message *) = 0;
121 Boolean _enqueueResponse(Message *, Message *);
|
122 kumpf 1.59 // virtual void _handle_incoming_operation(
123 // AsyncOpNode* operation,
124 // Thread* thread,
125 // MessageQueue* queue);
|
126 david.dillard 1.45 virtual void _handle_incoming_operation(AsyncOpNode *);
127
|
128 kumpf 1.59 virtual void _handle_async_request(AsyncRequest* req);
129 virtual void _handle_async_callback(AsyncOpNode* operation);
130 virtual void _make_response(Message* req, Uint32 code);
131
132 virtual void handle_heartbeat_request(AsyncRequest* req);
133 virtual void handle_heartbeat_reply(AsyncReply* rep);
134
135 virtual void handle_AsyncIoctl(AsyncIoctl* req);
136 virtual void handle_CimServiceStart(CimServiceStart* req);
137 virtual void handle_CimServiceStop(CimServiceStop* req);
138 virtual void handle_CimServicePause(CimServicePause* req);
139 virtual void handle_CimServiceResume(CimServiceResume* req);
140
141 virtual void handle_AsyncOperationStart(AsyncOperationStart* req);
142 virtual void handle_AsyncOperationResult(AsyncOperationResult* rep);
143
144 void _completeAsyncResponse(
145 AsyncRequest* request,
146 AsyncReply* reply,
147 Uint32 state,
148 Uint32 flag);
|
149 david.dillard 1.45 void _complete_op_node(AsyncOpNode *, Uint32, Uint32, Uint32);
150
|
151 kumpf 1.59 static cimom* _meta_dispatcher;
|
152 david.dillard 1.45 static AtomicInt _service_count;
153 static Mutex _meta_dispatcher_mutex;
|
154 kumpf 1.59 static ThreadPool* _thread_pool;
|
155 david.dillard 1.45
156 private:
|
157 kumpf 1.57 static ThreadReturnType PEGASUS_THREAD_CDECL polling_routine(void *);
158
|
159 mike 1.51 AsyncQueue<AsyncOpNode> _incoming;
|
160 david.dillard 1.45 static Thread* _polling_thread;
161 static Semaphore _polling_sem;
162 static AtomicInt _stop_polling;
163
|
164 mike 1.54 typedef List<MessageQueueService, Mutex> PollingList;
|
165 mike 1.51 static PollingList* _polling_list;
166 static Mutex _polling_list_mutex;
167
168 PollingList* _get_polling_list();
|
169 david.dillard 1.45
|
170 mike 1.54 static ThreadReturnType PEGASUS_THREAD_CDECL _req_proc(void *);
|
171 david.dillard 1.45
172 static void _sendwait_callback(AsyncOpNode *, MessageQueue *, void *);
173
174 AtomicInt _incoming_queue_shutdown;
175
|
176 kumpf 1.57 struct timeval _default_op_timeout;
|
177 david.dillard 1.45
178 friend class cimom;
|
179 mday 1.1 };
180
181 PEGASUS_NAMESPACE_END
182
183 #endif /* Pegasus_MessageQueue_Service_h */
|