4 #include "orbsvcs/Event/EC_Event_Channel.h"
5 #include "ace/Get_Opt.h"
6 #include "ace/High_Res_Timer.h"
9 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
12 return driver
.run (argc
, argv
);
15 // ****************************************************************
17 EC_Reconnect::EC_Reconnect (void)
18 : allow_consumer_reconnect_ (0),
19 allow_supplier_reconnect_ (0),
20 disconnections_ (1000)
25 EC_Reconnect::parse_args (int& argc
, ACE_TCHAR
* argv
[])
27 if (this->EC_Driver::parse_args (argc
, argv
) != 0)
30 ACE_Get_Opt
get_opt (argc
, argv
, ACE_TEXT("scd:"));
33 while ((opt
= get_opt ()) != EOF
)
38 this->allow_consumer_reconnect_
= 1;
41 this->allow_supplier_reconnect_
= 1;
44 this->disconnections_
= ACE_OS::atoi (get_opt
.opt_arg ());
58 EC_Reconnect::print_args (void) const
60 this->EC_Driver::print_args ();
62 ACE_DEBUG ((LM_DEBUG
, "EC_Reconnect:\n"
63 " consumer_reconnect = %d\n"
64 " supplier_reconnect = %d\n"
65 " disconnect_count = %d\n",
66 this->allow_consumer_reconnect_
,
67 this->allow_supplier_reconnect_
,
68 this->disconnections_
));
72 EC_Reconnect::print_usage (void)
74 this->EC_Driver::print_usage ();
76 ACE_DEBUG ((LM_DEBUG
, "EC_Reconnect usage: [-s] [-c] [-d disc]\n"));
80 EC_Reconnect::modify_attributes (TAO_EC_Event_Channel_Attributes
& attr
)
82 attr
.consumer_reconnect
= this->allow_consumer_reconnect_
;
83 attr
.supplier_reconnect
= this->allow_supplier_reconnect_
;
87 EC_Reconnect::execute_test (void)
89 this->execute_consumer_test ();
90 this->execute_supplier_test ();
92 ACE_High_Res_Timer::global_scale_factor_type gsf
=
93 ACE_High_Res_Timer::global_scale_factor ();
94 this->consumer_reconnect_
.dump_results (ACE_TEXT("Reconnect/consumer"), gsf
);
95 this->supplier_reconnect_
.dump_results (ACE_TEXT("Reconnect/supplier"), gsf
);
97 // this->EC_Driver::execute_test ();
101 EC_Reconnect::dump_results (void)
106 EC_Reconnect::execute_consumer_test (void)
108 RtecEventChannelAdmin::ConsumerQOS qos
;
109 int shutdown_event_type
;
110 this->build_consumer_qos (0, qos
, shutdown_event_type
);
112 if (this->allow_consumer_reconnect_
)
114 ACE_hrtime_t start_time
= ACE_OS::gethrtime ();
115 for (int i
= 0; i
< this->disconnections_
; ++i
)
117 ACE_hrtime_t start
= ACE_OS::gethrtime ();
118 this->consumers_
[0]->connect (qos
,
119 shutdown_event_type
);
120 ACE_hrtime_t stop
= ACE_OS::gethrtime ();
121 this->consumer_reconnect_
.sample (stop
- start_time
,
129 this->consumers_
[0]->connect (qos
,
130 shutdown_event_type
);
132 ACE_DEBUG ((LM_ERROR
, "Expected exception\n"));
134 catch (const RtecEventChannelAdmin::AlreadyConnected
&)
138 catch (const CORBA::Exception
& ex
)
140 ex
._tao_print_exception ("Expected AlreadyConnected exception");
143 RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin
=
144 this->event_channel_
->for_consumers ();
146 ACE_hrtime_t start_time
= ACE_OS::gethrtime ();
147 for (int i
= 0; i
< this->disconnections_
; ++i
)
149 ACE_hrtime_t start
= ACE_OS::gethrtime ();
150 this->consumers_
[0]->disconnect ();
151 this->consumers_
[0]->connect (consumer_admin
.in (),
153 shutdown_event_type
);
154 ACE_hrtime_t stop
= ACE_OS::gethrtime ();
155 this->consumer_reconnect_
.sample (stop
- start_time
,
162 EC_Reconnect::execute_supplier_test (void)
164 RtecEventChannelAdmin::SupplierQOS qos
;
165 int shutdown_event_type
;
166 this->build_supplier_qos (0, qos
, shutdown_event_type
);
168 if (this->allow_supplier_reconnect_
)
170 ACE_hrtime_t start_time
= ACE_OS::gethrtime ();
171 for (int i
= 0; i
< this->disconnections_
; ++i
)
173 ACE_hrtime_t start
= ACE_OS::gethrtime ();
174 this->suppliers_
[0]->connect (qos
, shutdown_event_type
);
175 ACE_hrtime_t stop
= ACE_OS::gethrtime ();
176 this->supplier_reconnect_
.sample (stop
- start_time
,
184 this->suppliers_
[0]->connect (qos
, shutdown_event_type
);
186 ACE_DEBUG ((LM_ERROR
, "Expected exception\n"));
188 catch (const RtecEventChannelAdmin::AlreadyConnected
&)
192 catch (const CORBA::Exception
& ex
)
194 ex
._tao_print_exception ("Expected AlreadyConnected exception");
197 RtecEventChannelAdmin::SupplierAdmin_var supplier_admin
=
198 this->event_channel_
->for_suppliers ();
200 ACE_hrtime_t start_time
= ACE_OS::gethrtime ();
201 for (int i
= 0; i
< this->disconnections_
; ++i
)
203 ACE_hrtime_t start
= ACE_OS::gethrtime ();
204 this->suppliers_
[0]->disconnect ();
205 this->suppliers_
[0]->connect (supplier_admin
.in (),
207 shutdown_event_type
);
208 ACE_hrtime_t stop
= ACE_OS::gethrtime ();
209 this->supplier_reconnect_
.sample (stop
- start_time
,