2 //=============================================================================
4 * @file RedGreen_Test.h
6 * Performance test to show improvement in Notify performance by picking the
7 * correcting configuration.
9 * @author Pradeep Gore <pradeep@cs.wustl.edu>
11 //=============================================================================
14 #ifndef NOTIFY_RedGreen_Test_CLIENT_H
15 #define NOTIFY_RedGreen_Test_CLIENT_H
17 #include "orbsvcs/CosNotifyChannelAdminS.h"
18 #include "orbsvcs/CosNotifyCommC.h"
19 #include "orbsvcs/CosNamingC.h"
21 #include "ace/Stats.h"
22 #include "ace/Throughput_Stats.h"
23 #include "ace/High_Res_Timer.h"
24 #include "ace/Sched_Params.h"
28 #pragma warning(disable:4250)
31 class RedGreen_Test_StructuredPushConsumer
;
32 class RedGreen_Test_StructuredPushSupplier
;
37 * @brief Run a server thread
39 * Use the ACE_Task_Base class to run server threads
41 class Worker
: public ACE_Task_Base
47 void orb (CORBA::ORB_ptr orb
);
49 /// The thread entry point.
61 * @class RedGreen_Test
63 * @brief RedGreen_Test
65 * Shows how consumers RedGreen_Test for events.
73 int parse_args (int argc
,
78 /// Initialize the Client.
85 /// Called when all events we are waiting for have occurred.
88 /// Destroy from the EC
96 /// Initializes the ORB.
97 void init_ORB (int argc
,
100 /// Try to get hold of a running naming service.
101 void resolve_naming_service ();
103 /// Try to resolve the Notify factory from the Naming service.
104 void resolve_Notify_factory ();
109 /// Create the Supplier Admin.
110 void create_supplieradmin();
112 /// Create the Consumer Admin.
113 void create_consumeradmin ();
115 /// Create and initialize the consumers.
116 void create_consumers ();
118 /// create and initialize the suppliers.
119 void create_suppliers ();
125 /// Reference to the root poa.
126 PortableServer::POA_var root_poa_
;
128 /// The ORB that we use.
131 /// Handle to the name service.
132 CosNaming::NamingContext_var naming_context_
;
135 CosNotifyChannelAdmin::EventChannelFactory_var notify_factory_
;
137 /// The one channel that we create using the factory.
138 CosNotifyChannelAdmin::EventChannel_var ec_
;
140 /// The group operator between admin-proxy's.
141 CosNotifyChannelAdmin::InterFilterGroupOperator ifgop_
;
143 /// Initial qos specified to the factory when creating the EC.
144 CosNotification::QoSProperties initial_qos_
;
146 /// Initial admin props specified to the factory when creating the EC.
147 CosNotification::AdminProperties initial_admin_
;
149 /// The consumer admin used by consumers.
150 CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin_
;
152 /// The supplier admin used by suppliers.
153 CosNotifyChannelAdmin::SupplierAdmin_var supplier_admin_
;
155 RedGreen_Test_StructuredPushConsumer
* normal_consumer_
;
156 RedGreen_Test_StructuredPushConsumer
* slow_consumer_
;
158 RedGreen_Test_StructuredPushSupplier
* supplier_
;
161 /*****************************************************************/
162 class RedGreen_Test_StructuredPushConsumer
163 : public POA_CosNotifyComm::StructuredPushConsumer
166 // RedGreen_Test_StructuredPushConsumer
169 // Consumer for the RedGreen_Test example.
173 RedGreen_Test_StructuredPushConsumer (RedGreen_Test
* RedGreen_Test
);
175 /// Connect the Consumer to the EventChannel.
176 /// Creates a new proxy supplier and connects to it.
177 void connect (CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin
);
179 /// Disconnect from the supplier.
180 virtual void disconnect ();
182 /// Accessor for the Proxy that we're connected to.
183 CosNotifyChannelAdmin::StructuredProxyPushSupplier_ptr
get_proxy_supplier ();
185 /// Accumulate the throughput statistics into <throughput>
186 void accumulate_into (ACE_Throughput_Stats
&throughput
) const;
188 /// Accumulate the throughput statistics into <throughput>
189 void dump_stats (const ACE_TCHAR
* msg
,
190 ACE_High_Res_Timer::global_scale_factor_type gsf
);
194 /// The proxy that we are connected to.
195 CosNotifyChannelAdmin::StructuredProxyPushSupplier_var proxy_supplier_
;
197 /// The proxy_supplier id.
198 CosNotifyChannelAdmin::ProxyID proxy_supplier_id_
;
201 RedGreen_Test
* RedGreen_Test_
;
203 /// Protect internal state
204 TAO_SYNCH_MUTEX lock_
;
208 /// Used for reporting stats
209 ACE_Throughput_Stats throughput_
;
213 virtual ~RedGreen_Test_StructuredPushConsumer ();
215 // = NotifyPublish method
216 virtual void offer_change (
217 const CosNotification::EventTypeSeq
& added
,
218 const CosNotification::EventTypeSeq
& removed
);
220 // = StructuredPushSupplier methods
221 virtual void push_structured_event (
222 const CosNotification::StructuredEvent
& notification
);
224 virtual void disconnect_structured_push_consumer ();
227 /*****************************************************************/
229 class SlowConsumer
: public RedGreen_Test_StructuredPushConsumer
232 SlowConsumer (RedGreen_Test
* RedGreen_Test
);
234 virtual void push_structured_event (
235 const CosNotification::StructuredEvent
& notification
);
238 /*****************************************************************/
239 class RedGreen_Test_StructuredPushSupplier
240 : public POA_CosNotifyComm::StructuredPushSupplier
243 // RedGreen_Test_StructuredPushSupplier
246 // Supplier for the RedGreen_Test example.
250 RedGreen_Test_StructuredPushSupplier ();
252 /// Connect the Supplier to the EventChannel.
253 /// Creates a new proxy supplier and connects to it.
254 void connect (CosNotifyChannelAdmin::SupplierAdmin_ptr supplier_admin
);
256 /// Disconnect from the supplier.
260 virtual void send_event (CosNotification::StructuredEvent
& event
);
262 /// Accumulate the throughput statistics into <throughput>
263 void accumulate_into (ACE_Throughput_Stats
&throughput
) const;
265 /// Accumulate the throughput statistics into <throughput>
266 void dump_stats (const ACE_TCHAR
* msg
,
267 ACE_High_Res_Timer::global_scale_factor_type gsf
);
271 /// The proxy that we are connected to.
272 CosNotifyChannelAdmin::StructuredProxyPushConsumer_var proxy_consumer_
;
274 /// This supplier's id.
275 CosNotifyChannelAdmin::ProxyID proxy_consumer_id_
;
277 /// Measure the elapsed time spent while sending the events.
278 ACE_Throughput_Stats throughput_
;
280 // = Protected Methods
282 virtual ~RedGreen_Test_StructuredPushSupplier ();
284 // = NotifyRedGreen_Test
285 virtual void subscription_change (
286 const CosNotification::EventTypeSeq
& added
,
287 const CosNotification::EventTypeSeq
& removed
);
289 // = StructuredPushSupplier method
290 virtual void disconnect_structured_push_supplier ();
293 /*****************************************************************/
295 #if defined(_MSC_VER)
297 #endif /* _MSC_VER */
299 #endif /* NOTIFY_RedGreen_Test_CLIENT_H */