2 //=============================================================================
6 * @author Carlos O'Ryan (coryan@cs.wustl.edu)
8 //=============================================================================
14 #include "ectest_export.h"
16 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 #endif /* ACE_LACKS_PRAGMA_ONCE */
20 #include "orbsvcs/RtecEventChannelAdminS.h"
22 #include "ace/Stats.h"
24 #include "ace/Throughput_Stats.h"
26 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
27 class TAO_EC_Event_Channel_Attributes
;
28 TAO_END_VERSIONED_NAMESPACE_DECL
30 class TAO_Module_Factory
;
34 #define EC_DISABLE_REMOTE_EC
35 #define EC_DISABLE_OLD_EC
37 #if !defined(EC_DISABLE_REMOTE_EC)
38 #include "orbsvcs/CosNamingC.h"
44 * @brief Defines the interface of a test driver
46 * Abstract base class for the test driver, this let us implement a
47 * collocated and a non-collocated test, and to write generic
48 * consumers and suppliers that can call back the driver.
50 class EC_Test_Export EC_Driver
57 virtual ~EC_Driver (void);
59 /// Flag to indicate in the test should be verbose.
60 int verbose (void) const;
63 virtual int run (int argc
, ACE_TCHAR
* argv
[]);
65 /// The initialization section
66 virtual void run_init (int& argc
, ACE_TCHAR
* argv
[]);
68 /// The cleanup section
69 virtual void run_cleanup (void);
71 /// Initialize the ORB and obtain the RootPOA object
72 virtual void initialize_orb_and_poa (int& argc
, ACE_TCHAR
* argv
[]);
74 /// Parse the common command-line arguments for all tests
75 virtual int parse_args (int& argc
, ACE_TCHAR
* argv
[]);
77 /// Print the usage method
78 virtual void print_usage (void);
80 /// Print out the arguments
81 virtual void print_args (void) const;
83 /// Run the test in the real-time class, return -1 on error.
84 virtual int move_to_rt_class (void);
86 /// Construct the EC and its helper objects, also activates the EC in
88 virtual void initialize_ec_impl (void);
90 /// By default connect the consumers and then the suppliers, other
91 /// orders should work too.
92 virtual void connect_clients (void);
94 /// By default disconnect the suppliers and then the consumers, other
95 /// orders should work too.
96 virtual void disconnect_clients (void);
98 /// By default deactivate the suppliers and then the consumers, other
99 /// orders should work too.
100 virtual void shutdown_clients (void);
102 /// Connect all the consumers, by default it lets each consumer
104 virtual void connect_consumers (void);
106 /// Connect consumer number <i> using the consumer_admin provided.
107 virtual void connect_consumer (
108 RtecEventChannelAdmin::ConsumerAdmin_ptr consumer_admin
,
111 /// Build the QoS requirements for consumer <i>
112 virtual void build_consumer_qos (
114 RtecEventChannelAdmin::ConsumerQOS
& qos
,
115 int& shutdown_event_type
);
117 /// Connect all the suppliers, by default it lets each supplier
119 virtual void connect_suppliers (void);
121 /// Connect supplier number <i> using the supplier_admin provided.
122 virtual void connect_supplier (
123 RtecEventChannelAdmin::SupplierAdmin_ptr supplier_admin
,
126 /// Build the QoS requirements for supplier <i>
127 virtual void build_supplier_qos (
129 RtecEventChannelAdmin::SupplierQOS
& qos
,
130 int& shutdown_event_type
);
132 /// Execute the test, by default simply call activate_suppliers()
133 virtual void execute_test (void);
136 * Dump the results, i.e. invoke dump_results on all the suppliers
137 * and consumers, collect the latency and throughput results for
138 * each and print the totals too.
140 virtual void dump_results (void);
142 /// Disconnect all the consumers.
143 virtual void disconnect_consumers (void);
145 /// Disconnect all the suppliers.
146 virtual void disconnect_suppliers (void);
148 /// Deactivate all the consumers.
149 virtual void shutdown_consumers (void);
151 /// Deactivate all the suppliers.
152 virtual void shutdown_suppliers (void);
155 virtual void destroy_ec (void);
157 /// De-activate the EC (and its helper classes).
158 virtual void deactivate_ec (void);
160 /// Cleanup the resources
161 virtual void cleanup_ec (void);
162 virtual void cleanup_tasks (void);
163 virtual void cleanup_consumers (void);
164 virtual void cleanup_suppliers (void);
166 /// Allow modifications of the default EC attributes
167 virtual void modify_attributes (TAO_EC_Event_Channel_Attributes
& attr
);
169 /// Returns the index of the consumer for @a cookie
170 virtual int decode_consumer_cookie (void* cookie
) const;
172 /// Returns the index of the supplier for @a cookie
173 virtual int decode_supplier_cookie (void* cookie
) const;
175 /// One of the consumers in the test has received an event
176 virtual void consumer_push (void* consumer_cookie
,
177 const RtecEventComm::EventSet
& event
);
179 /// One of the consumers has received a shutdown event
180 virtual void consumer_shutdown (void* consumer_cookie
);
182 /// One of the consumers in the test has been disconnected from the EC
183 virtual void consumer_disconnect (void* consumer_cookie
);
185 /// One of the suppliers in the test has been disconnected from the EC
186 virtual void supplier_disconnect (void* supplier_cookie
);
188 #if !defined(EC_DISABLE_REMOTE_EC)
189 /// Obtain the EC from the Naming service
190 virtual void obtain_remote_ec (void);
192 virtual CosNaming::NamingContext_ptr
193 get_naming_context (void);
196 /// Initialize the EC using the new implementation
197 virtual void initialize_new_ec (void);
199 /// Allocate the suppliers and the consumers
200 virtual int allocate_consumers (void);
201 virtual int allocate_suppliers (void);
203 /// Allocate one consumer or supplier
204 virtual EC_Consumer
* allocate_consumer (int i
);
205 virtual EC_Supplier
* allocate_supplier (int i
);
207 /// Allocate one task for supplier number <i>
208 virtual int allocate_tasks (void);
209 virtual ACE_Task_Base
* allocate_task (int i
);
211 /// Activate all the tasks, by default runs each supplier on its
213 virtual void activate_tasks (void);
220 PortableServer::POA_var root_poa_
;
222 /// The number of consumers
226 EC_Consumer
** consumers_
;
228 /// The number of suppliers
232 EC_Supplier
** suppliers_
;
234 /// The tasks for each supplier
235 ACE_Task_Base
** tasks_
;
237 /// How many bursts we will send from each supplier.
240 /// The number of events
243 /// The size of the payload on each event.
246 /// The time between each event burst, in microseconds.
250 * The consumers subscribe to different sets of events, as follows:
252 * Consumer0: [start , start + count)
253 * Consumer1: [start + 1*shift, start + 1*shift + count)
254 * Consumer2: [start + 2*shift, start + 2*shift + count)
258 * Some sub-tests may choose other configurations, but this is good
261 int consumer_type_start_
;
262 int consumer_type_count_
;
263 int consumer_type_shift_
;
266 * The suppliers generate different sets of events, as follows:
268 * Supplier0: [start , start + count)
269 * Supplier1: [start + 1*shift, start + 1*shift + count)
270 * Supplier2: [start + 2*shift, start + 2*shift + count)
274 * Some sub-tests may choose other configurations, but this is good
277 int supplier_type_start_
;
278 int supplier_type_count_
;
279 int supplier_type_shift_
;
281 /// The name of a file where the process stores its pid
282 const ACE_TCHAR
* pid_file_name_
;
288 * The flags used to create threads, by default we attempt:
290 * THR_SCHED_FIFO|THR_BOUND|THR_NEW_LWP
292 * but if we don't have enough privileges we fall back to
297 int thr_create_flags_
;
299 /// Use a remote event channel. If this flag is enabled it
300 /// superseedes any options for the event channel implementation.
303 /// The name of the remote event service
304 const ACE_TCHAR
*event_service_name_
;
306 /// The event channel implementation
307 POA_RtecEventChannelAdmin::EventChannel
*ec_impl_
;
309 /// The event channel object reference
310 RtecEventChannelAdmin::EventChannel_var event_channel_
;
314 #if defined (__ACE_INLINE__)
315 #include "Driver.inl"
316 #endif /* __ACE_INLINE__ */
318 #endif /* ECT_CONSUMER_H */